A bot for claim daily free learning ebooks from packtpub. It also notify you over Pushbullet or Telegram. It can download the ebook after claim if you want. It's designed as cron job task on a Raspberry Pi.
- node.js, version 6.0.0+ (only tested on v6)
git clone https://github.com/mtuanp/packtpubbot.git
The bot uses a json configuration file for providing login credentials. Add file names config.json in your working directory where you cloned. Example of config.json:
{
"informBy": "",
"downloadAfterClaim": true,
"outputDirectory": null,
"packtpub": {
"email": "put your email here",
"password": "put your password here"
},
"pushbullet": {
"apiKey": "put your pushbullet api key here"
},
"telegram": {
"botToken" : "put your telegram bot token here",
"receiverId" : "put destination user id here"
}
}
Configure the desired notification platform, if leaves it blank will be output to console. Aceptable values:
- telegram
- pushbullet
Configure to download the ebook after claim. Default value: true Aceptable values:
- true
- false
Configure the desired directory to output the ebook. The ebook will be download at the same directory as the index.js if leaves this null Default value: null
Configure the desired format to download the ebook. Default value: pdf Aceptable values:
- epub
- mobi
By seprating with ';', multiple file-formats can be downloaded. Example for downloading pdf and epub:
- pdf;epub
email to login into https://www.packtpub.com
password to login into https://www.packtpub.com
apiKey provided by https://www.pushbullet.com
the bot token provided by botFather
the telegram user id to receive the notification
After set up your config.json, you start the bot with following statements:
npm install # only on first run
npm start
Find the absolute location of npm and copy it:
which node
Open cron job table with:
crontab -e
Add following statements for every day cron job at 9 am:
0 9 * * * <PATH_TO_NODE>/node <PATH_TO_REPO>/index.js >> /var/log/packtpub.log 2>&1