Vaccine Lad
Github Repository: github.com/KrishGoel/vaccine-lad
A Telegram Bot that performs the cron job of checking the CoWIN API Endpoints for any open vaccine slots. Built using GitHub Actions and Python.
I drove this code to the point where it was able to send notifications to my Telegram. The leftover code was just plain logic and the result, however satisfying, wouldn’t have been worth it. Hence, I abandoned the code (also because I had board exams at the time of this writing, they did get cancelled eventually but this code was a study break thing).
I have still attached all the resources you would need to take it up from here. Feel free to hit me up anytime in case you’d wanna discuss anything about this code.
Functioning
The idea is to scan through the response JSON obtained from the CoWIN APIs and filter the qualifying entries (in my case, min_age_limit
= 18 and available_capacity
> 5).
However, the issue that arises with this approach is that the CoWIN API returns a response for each district and each day, so anyone going around the whole town (Delhi for me) would have to run 77 searches (11 districts in Delhi x 7 days of the week) each time the Bot runs. This is where the code got boring for me and I left it, however it isn’t a big issue and can easily be worked out.
Once the program finds a qualifying entry, it will generate a message including the details of the venue, day, vaccine name, etc, and shoot it over Telegram. Which is again piss easy but demanding. I have already completed the notification segment of the code, you can see it at notify.py.
Resources used
Postman for testing POST and GET Requests
Setting up GitHub Actions with Python For reference, checkout
.github/workflows/main.yaml
Creating a Telegram Bot
- Open the Telegram app and search for @BotFather.
- Click on the start button or send “/start”.
- Send “/newbot” message to set up a name and a username.
- After setting-up the name and the username BotFather will give you an API token which is your bot token.
- For the next steps, I slacked out and used @get_id_bot to get a
CHAT_ID
. A much better method would be to usetelebot
andtelethon
as suggested in this article Send a message to Telegram user using Python by GeeksForGeeks.
A major shoutout to @plibither8 for helping me along the way and providing references.