Skip to content

Vaccine Availability Discord Bot. A bot to check vaccine availability for specific district/pincodes & notify on Discord via webhooks

License

Notifications You must be signed in to change notification settings

RAvengineer/vad-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VAD-Bot

🤖 Vaccine Availability Discord Bot


Features

  • Discord notification
  • Search-by mode customization
  • Search for list of pincodes
  • Randomized intevals of requests
  • Logging

👨‍💻 How to use?

  1. Clone the repository :octocat:
    git clone https://github.com/RAvengineer/vad-bot.git
    cd vad-bot
  2. Create a webhook in the desired Discord channel. Follow this Intro to Webhooks official guide for learning how to create & manage a webhook.
  3. Follow the guidelines for .env file provided below (next section) ⏬
  4. (Optional) Create a virtual environment [Requires Python 3+]
    python -m venv venv
    source ./venv/bin/activate
  5. Install required libraries
    pip install -r requirements.txt
  6. Execute in terminal
    python vad-bot.py

📓 Guidelines: .env file

Create file named .env in the root directory of the project & paste the content provided below

# Discord Webhook URL for the channel in which you want notifications
DISCORD_WEBHOOK_URL = YOUR-DISCORD-CHANNEL-URL-HERE

# Search centers by District or List of Pincodes
# Comment out the mode you are not using
#SEARCH_BY = DISTRICT
SEARCH_BY = PINCODE

# Set District ID, if SEARCH_BY mode chosen as DISTRICT
# (Ex.: 391)
DISTRICT_ID = YOUR-3-DIGIT-DISTRICT-ID-HERE

# List Pincodes, if SEARCH_BY mode chosen as PINCODE
LIST_OF_PINCODES = [201301, 301233, 401408, 501209, 801301, 901304]

💻 Setup .env file from terminal (For Linux/MacOS users):

  1. Type the following
    nano .env
  2. Use Ctrl + Shift + V to paste the copied text contents
  3. Press Ctrl + S, followed by Ctrl + X to save & exit the file

❓ How to find your DISTRICT_ID?

  1. Open this link containing the list of state_id & state_name
  2. Press Ctrl+F and type your State name. You will be find you state in the form of
    {"state_id":21,"state_name":"Maharashtra"}
  3. Note down the State ID, for the above example it is 21.
  4. Copy & paste https://cdn-api.co-vin.in/api/v2/admin/location/districts/state_id in your address bar (Don't hit search/Enter/Return yet!)
  5. Replace state_id in the above link with the State ID noted down in the 4th step. Then, hit Enter/Return/search
  6. Again, there will be a list of districts displayed with district_id & district_name
  7. Press Ctrl+F and type your District name. You will be find you district in the form of
    {"district_id":395,"district_name":"Mumbai"}
  8. Replace YOUR-3-DIGIT-DISTRICT-ID-HERE in .env file with the District ID found in the previous step

Note for PINCODE mode users

TL;DR: In PINCODE mode, limit the number of pincodes in the list to 6

... The appointment availability data is cached and may be upto 30 minutes old. Further, these APIs are subject to a rate limit of 100 API calls per 5 minutes per IP ... [Updated on 5 May 2021] Source: API Setu

Considering the above limit & the fact that this bot requests data from the API in an interval decided by a psudo-random function which returns values between 20 to 40 inclusively, it is evident that number of Pincodes provided in the list should NOT exceed 6. Explanation:

$$5 minutes = 5 * 60 seconds = 300 seconds$$

In worst case scenario, the psudo-random function returns the value 20 on every call. Thus, the fetchData function will be called

$$300/20 = 15 times$$

Now, each pincode requires a seperate request. Therefore, number of possible pincodes to avoid your IP being blocked are \lfloor100/15\rfloor = 6 pincodes


🔗 References:

About

Vaccine Availability Discord Bot. A bot to check vaccine availability for specific district/pincodes & notify on Discord via webhooks

Topics

Resources

License

Stars

Watchers

Forks

Languages