Skip to content

A bot for claim daily free learning ebooks from packtpub.

License

Notifications You must be signed in to change notification settings

mtuanp/packtpubbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

packtpubbot

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.

Requirements

  • node.js, version 6.0.0+ (only tested on v6)

How to install

git clone https://github.com/mtuanp/packtpubbot.git

Configuration

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"
  }
}

informBy

Configure the desired notification platform, if leaves it blank will be output to console. Aceptable values:

  • telegram
  • pushbullet

downloadAfterClaim

Configure to download the ebook after claim. Default value: true Aceptable values:

  • true
  • false

outputDirectory

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

outputFormat

Configure the desired format to download the ebook. Default value: pdf Aceptable values:

  • pdf
  • epub
  • mobi

By seprating with ';', multiple file-formats can be downloaded. Example for downloading pdf and epub:

  • pdf;epub

packtpub

email

email to login into https://www.packtpub.com

password

password to login into https://www.packtpub.com

pushbullet

apiKey

apiKey provided by https://www.pushbullet.com

telegram

botToken

the bot token provided by botFather

receiverId

the telegram user id to receive the notification

How to use

After set up your config.json, you start the bot with following statements:

npm install # only on first run
npm start

Cron job

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

About

A bot for claim daily free learning ebooks from packtpub.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published