Skip to content

CLI command to continuously check for Vaccine appointments and get notified on WhatsApp/Telegram. You can even create a Telegram channel to notify your friends/relatives

License

Notifications You must be signed in to change notification settings

veenaypatil/Vaccine-Slot-Info

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Vaccine-Slot-Info

CLI to check for Covid Vaccine appointments pincode or district wise and get notified on WhatsApp/Telegram.

Pre-requisites

  1. Python 3.6+ , you can install it from https://www.python.org/downloads/
  2. Either Telegram Account (Recommended)
  3. Or Twilio Free Trail Account for whatsapp notification

Telegram Bot Configuration

  1. On Telegram, search @BotFather, click on START button or send /start message
  2. Send /newbot message and follow the instructions to set the name and username for your bot
  3. You will receive a token to access HTTP API, this token is your TELEGRAM_BOT_TOKEN
  4. Goto your bot name in Telegram and send /start message
  5. To get your chatId Open a new tab in browser, enter https://api.telegram.org/bot<token>/getUpdates You will get the response as
    "ok":true,"result":[{"update_id":334363465,
    "message":{"message_id":3,"from":{"id":130XXXXXX,"is_bot":false,"first_name":"Vinay",
    "language_code":"en"},
    "chat":{"id":130XXXXXX,"first_name":"Vinay","type":"private"},"date":1620703638,"text":"/start",
    "entities":[{"offset":0,"length":6,"type":"bot_command"}]}}]}
    
    TELEGRAM_BOT_CHAT_ID will be 130XXXXXX from the above response
  6. Export the following env variables on your terminal
export TELEGRAM_BOT_TOKEN=<from step 3 above>
export TELEGRAM_BOT_CHAT_ID=<from step 5 above>

Note: This method will send notification to your bot which will only be visible to you

Sending message to Channel using Telegram to notify your friends or relatives

  1. Create a new channel on Telegram and make custom bot created above as admin
  2. Got to https://web.telegram.org/#/im and select the channel created
  3. In the web url you will see something like https://web.telegram.org/#/im?p=c115xxxx_1234567890
  4. Copy the number before _ like c115xxxx and remove the starting character c
  5. Prefix -100 to this number as -100115xxxx
  6. Export the following variable
export TELEGRAM_BOT_TOKEN=<from step 3 of Telegram Bot Configuration>
export TELEGRAM_BOT_CHAT_ID=-100115xxxx

Note: Using this method you will notify all the members of your channel

Twilio Configuration for Whatsapp Notification

  1. Create a new Twilio Trail Account - www.twilio.com/referral/PfBNJy
  2. Follow the steps here https://www.twilio.com/console/sms/whatsapp/sandbox
  3. Export the following env variables on your terminal
export TWILIO_ACCOUNT_SID="twilio_account_sid" // you will get this here https://www.twilio.com/console
export TWILIO_AUTH_TOKEN="twilio_auth_token" // you will get this here https://www.twilio.com/console
export FROM_MOBILE_NUMBER="twilio_number" // you will get this number after following the steps https://www.twilio.com/console/sms/whatsapp/sandbox
export TO_MOBILE_NUMBER="your_mobile_number"

Note: Twilio Sandbox lasts for 72 hours after which notification to whatsapp will not come. You will have to again join the sandbox

Screenshot 2021-05-13 at 11 04 15 AM

Installation steps to use slotinfo command

  1. Download release directly by clicking on slotinfo-1.3.tar.gz here - https://github.com/veenaypatil/Vaccine-Slot-Info/releases/tag/v1.3
sudo pip install <downloaded_folder>/slotinfo-1.3.tar.gz
or 
sudo pip3 install <downloaded_folder>/slotinfo-1.3.tar.gz

Checkout how to install pip here - https://www.techgeekbuzz.com/how-to-install-python-pip-on-windows-mac-and-linux/

  1. Or Clone the code and install
python setup.py sdist
sudo pip install dist/slotinfo-1.3.tar.gz

CLI commands provided by this utility

  continuously-for-district
  continuously-for-district-next7days
  continuously-for-pincode
  continuously-for-pincode-next7days
  district-wise
  district-wise-next7days
  pincode-wise
  pincode-wise-next7days
  get-district-id
  get-state-id

CLI commands usage

1. Get the State ID
slotinfo get-state-id --state_name Maharashtra

2. Get the District ID
slotinfo get-district-id --state_id 21 --district_name Pune

3. Check available appointment slots district wise
slotinfo district-wise --district_id 334 --date 10-05-2021 --age_filter 18 --notify_on whatsapp --vaccine_type covishield --vaccine_type covaxin --dose_number 1

4. Check available appointment slots district wise for next 7 days
slotinfo district-wise-next7days --district_id 334 --date 10-05-2021 --age_filter 18 --notify_on whatsapp --vaccine_type covishield --vaccine_type covaxin --dose_number 2

5. Check available appointment slots pincode wise
slotinfo pincode-wise-next7days -pin 411015 --date 10-05-2021 --age_filter 45 --notify_on telegram --vaccine_type covishield --vaccine_type covaxin --dose_number 1

6. Check available appointment slots pincode wise
slotinfo pincode-wise -pin 411015 --date 10-05-2021 --age_filter 45 --notify_on telegram --vaccine_type covishield --vaccine_type covaxin --dose_number 1

7. Run the cmd continously to check for available appointments in a district after evey x(seconds) interval
slotinfo continuously-for-district --district_id 363 --date 10-05-2021 --age_filter 18 --interval 2 --notify_on telegram --vaccine_type covishield --vaccine_type covaxin --dose_number 1

8. Run the cmd continously to check for available appointments in a district for next 7 days after evey x(seconds) interval
slotinfo continuously-for-district-next7days --district_id 363 --date 10-05-2021 --age_filter 18 --interval 2 --notify_on telegram --vaccine_type covishield --vaccine_type covaxin --dose_number 2

9. Run the cmd continously to check for available appointments in pin code after evey x(seconds) interval
slotinfo continuously-for-pincode --pin_code 41105 --date 10-05-2021 --age_filter 18 --interval 2 --notify_on whatsapp --vaccine_type covishield --vaccine_type covaxin --dose_number 1

10. Run the cmd continously to check for available appointments in pin code for next 7 days after evey x(seconds) interval
slotinfo continuously-for-pincode-next7days --pin_code 411015 --date 10-05-2021 --age_filter 18 --interval 2 --notify_on whatsapp --vaccine_type covishield --vaccine_type covaxin --dose_number 2

Note: --vaccine_type, dose_number and age_filter are optinal fields

To get the help of any command use --help option with command name

Usage: slotinfo continuously-for-district-next7days [OPTIONS]

  Continuously check for available slots in district for next 7 days after
  every x interval seconds and notify on whatsapp/telegram

Options:
  -dId, --district_id TEXT        Provide district Id to check for
                                  appointments  [required]
  -d, --date TEXT                 Date for which appointments are to be
                                  checked for next 7 days  [required]
  -af, --age_filter [18|45]       Filter only 18 plus or 45 plus appointments
  -i, --interval INTEGER          Interval in seconds  [required]
  -n, --notify_on [whatsapp|telegram]
                                  Receive notification on whatsapp/telegram
                                  [required]
  -vt, --vaccine_type [covishield|covaxin]
                                  Vaccine type for which appointments are to
                                  be checked
  -dn, --dose_number [1|2]        Dose number for which appointments are to be
                                  checked
  --help                          Show this message and exit.

Whatsapp Notification Sample

Screenshot 2021-05-09 at 10 01 03 PM

Telegram Notification Sample

Screenshot 2021-05-11 at 11 11 05 AM