-
Notifications
You must be signed in to change notification settings - Fork 83
/
covid.py
64 lines (60 loc) · 2.92 KB
/
covid.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
# corona virus stats for catuserbot
from userbot.plugins import catub, covidindia, edit_delete, edit_or_reply
from covid import Covid
plugin_category = "extra"
@catub.cat_cmd(
pattern="covid(?:\s|$)([\s\S]*)",
command=("covid", plugin_category),
info={
"header": "To get latest information about covid-19.",
"description": "Get information about covid-19 data in the given country/state(only Indian States).",
"usage": "{tr}covid <state_name/country_name>",
"examples": ["{tr}covid andhra pradesh", "{tr}covid india", "{tr}covid world"],
},
)
async def corona(event):
"To get latest information about covid-19."
input_str = event.pattern_match.group(1)
country = (input_str).title() if input_str else "World"
catevent = await edit_or_reply(event, "`Collecting data...`")
covid = Covid(source="worldometers")
try:
country_data = covid.get_status_by_country_name(country)
except ValueError:
country_data = ""
if country_data:
hmm1 = country_data["confirmed"] + country_data["new_cases"]
hmm2 = country_data["deaths"] + country_data["new_deaths"]
data = ""
data += f"\n⚠️ Confirmed : <code>{hmm1}</code>"
data += f"\n😔 Active : <code>{country_data['active']}</code>"
data += f"\n⚰️ Deaths : <code>{hmm2}</code>"
data += f"\n🤕 Critical : <code>{country_data['critical']}</code>"
data += f"\n😊 Recovered : <code>{country_data['recovered']}</code>"
data += f"\n💉 Total tests : <code>{country_data['total_tests']}</code>"
data += f"\n🥺 New Cases : <code>{country_data['new_cases']}</code>"
data += f"\n😟 New Deaths : <code>{country_data['new_deaths']}</code>"
await catevent.edit(
f"<b>Corona Virus Info of {country}:\n{data}</b>", parse_mode="html"
)
else:
data = await covidindia(country)
if data:
cat1 = int(data["new_positive"]) - int(data["positive"])
cat2 = int(data["new_death"]) - int(data["death"])
cat3 = int(data["new_cured"]) - int(data["cured"])
result = f"<b>Corona virus info of {data['state_name']}\
\n\n⚠️ Confirmed : <code>{data['new_positive']}</code>\
\n😔 Active : <code>{data['new_active']}</code>\
\n⚰️ Deaths : <code>{data['new_death']}</code>\
\n😊 Recovered : <code>{data['new_cured']}</code>\
\n🥺 New Cases : <code>{cat1}</code>\
\n😟 New Deaths : <code>{cat2}</code>\
\n😃 New cured : <code>{cat3}</code> </b>"
await catevent.edit(result, parse_mode="html")
else:
await edit_delete(
catevent,
f"`Corona Virus Info of {country} is not avaiable or unable to fetch`",
5,
)