This repository has been archived by the owner on Jul 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
80 lines (71 loc) · 2.13 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# SDBOTs: SDBOTs (https://github.com/Sadew451) (@Sadew451)
import os
import requests
from requests.utils import requote_uri
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
SDBOTS = Client(
"COVID-COVID",
bot_token = os.environ["BOT_TOKEN"],
api_id = int(os.environ["API_ID"]),
api_hash = os.environ["API_HASH"]
)
API = "https://api.sumanjay.cf/covid/?country="
START_TEXT = """
Hello 👋{}, I am a simple corona information of a country telegram bot.
Made by @Darkridersslk
"""
BUTTONS = InlineKeyboardMarkup(
[[
InlineKeyboardButton('⚙ Join Updates Channel ⚙', url='https://telegram.me/SDBOTs_Inifinity')
]]
)
@SDBOTS.on_message(filters.private & filters.command(["start"]))
async def start(bot, update):
text = START_TEXT.format(update.from_user.mention)
reply_markup = BUTTONS
await update.reply_text(
text=text,
disable_web_page_preview=True,
reply_markup=reply_markup,
quote=True
)
@SDBOTS.on_message(filters.private & filters.text)
async def reply_info(bot, update):
reply_markup = BUTTONS
await update.reply_text(
text=covid_info(update.text),
disable_web_page_preview=True,
quote=True,
reply_markup=reply_markup
)
def covid_info(country_name):
try:
r = requests.get(API + requote_uri(country_name.lower()))
info = r.json()
country = info['country'].capitalize()
active = info['active']
confirmed = info['confirmed']
deaths = info['deaths']
info_id = info['id']
last_update = info['last_update']
latitude = info['latitude']
longitude = info['longitude']
recovered = info['recovered']
covid_info = f"""
--**Covid 19 Information**--
Country : `{country}`
Actived : `{active}`
Confirmed : `{confirmed}`
Deaths : `{deaths}`
ID : `{info_id}`
Last Update : `{last_update}`
Latitude : `{latitude}`
Longitude : `{longitude}`
Recovered : `{recovered}`
Made by @Darkridersslk
"""
return covid_info
except Exception as error:
return error
SDBOTS.run()