Skip to content

PSaiSurya/PyCowinTelegram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PyCowinTelegram

Queries Cowin public API, then sends the details of new slots in your district to your Telegram Channel or Group.

Made with ❤️ using Python 🐍.

Get started with your District ID and Chat ID of your Telegram Channel/Group.

Requires Python 3.9+

Tested working on Windows 10 .

Works only in India (🇮🇳) due to Geofencing of the API.

Getting Started

Creating a Virtual Environment (Optional, Can be Skipped)

  • Install Anaconda

  • Use Anaconda to create a virtual environment and Activate it

    For detailed steps, see here

Installing Requirements

pip install requirements.txt

District ID from Cowin Portal

Use the following code to get your district ID

import requests
import json
from fake_useragent import UserAgent

Agent = UserAgent()
browser_header = {"User-Agent":Agent.random}
for states in range(1,40):
  print("State Code: ",states)
  response = requests.get(f"https://cdn-api.co-vin.in/api/v2/admin/location/districts/{states}", headers=browser_header)
  json_data = json.loads(response.text)
  for state in json_data["districts"]:
    print(state["district_id"],'\t', state["district_name"])
  print("\n")

Chat ID from Telegram

1. Creating a Telegram Bot

To set up a new bot, start the conversation with BotFather (@BotFather). BotFather will help us in creating the new bot.

  • Search for @botfather in Telegram.
  • Start your conversation by pressing the Start button.
  • Create the bot by running /newbot command
  • Enter the Display Name and User Name for the bot.
  • BotFather will send you a message with the token

DISCLAIMER — Keep access token of the bot securely. Anyone with your token can manipulate this bot.

2. Telegram Bot and Chat ID

  • Create a new Telegram Channel or group (It can be Public/Private)
  • Add your bot to the Channel/Group
  • Send a sample message to your Channel
  • Forward the same to @JsonDumpBot
  • Get the ID

DISCLAIMER — I'm not an affiliate and @JsonDumpBot is not my bot. alt text

FAQ

1. I do not want to use Telegram and view the details of new slots in the Output Screen(Terminal/CMD/Powershell) instead. What to do?

  • Uncomment Line 150 in main.py
  • Comment Lines 151,152 in main.py


Feel free to use this code in your application 😃

Show your ❤️ by ⭐ this Repository

Hits

About

Queries Cowin public API and notifies in Telegram, if new slots open

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages