-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathazan.py
44 lines (40 loc) · 1.8 KB
/
azan.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
# ported from uniborg
# https://github.com/muhammedfurkan/UniBorg/blob/master/stdplugins/ezanvakti.py
import json
import requests
from userbot.plugins import catub, edit_delete, edit_or_reply
from userbot.sql_helper.globals import gvarstatus
plugin_category = "extra"
@catub.cat_cmd(
pattern="azan(?:\s|$)([\s\S]*)",
command=("azan", plugin_category),
info={
"header": "Shows you the Islamic prayer times of the given city name.",
"note": "you can set default city by using {tr}setcity command.",
"usage": "{tr}azan <city name>",
"examples": "{tr}azan hyderabad",
},
)
async def get_adzan(adzan):
"Shows you the Islamic prayer times of the given city name"
input_str = adzan.pattern_match.group(1)
LOKASI = input_str or gvarstatus("DEFCITY") or "Delhi"
url = f"http://muslimsalat.com/{LOKASI}.json?key=bd099c5825cbedb9aa934e255a81a5fc"
request = requests.get(url)
if request.status_code != 200:
return await edit_delete(
adzan, f"`Couldn't fetch any data about the city {LOKASI}`", 5
)
result = json.loads(request.text)
catresult = f"<b>Islamic prayer times </b>\
\n\n<b>City : </b><i>{result['query']}</i>\
\n<b>Country : </b><i>{result['country']}</i>\
\n<b>Date : </b><i>{result['items'][0]['date_for']}</i>\
\n<b>Fajr : </b><i>{result['items'][0]['fajr']}</i>\
\n<b>Shurooq : </b><i>{result['items'][0]['shurooq']}</i>\
\n<b>Dhuhr : </b><i>{result['items'][0]['dhuhr']}</i>\
\n<b>Asr : </b><i>{result['items'][0]['asr']}</i>\
\n<b>Maghrib : </b><i>{result['items'][0]['maghrib']}</i>\
\n<b>Isha : </b><i>{result['items'][0]['isha']}</i>\
"
await edit_or_reply(adzan, catresult, "html")