-
Notifications
You must be signed in to change notification settings - Fork 83
/
cricket.py
82 lines (76 loc) · 2.95 KB
/
cricket.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
81
82
"""
Created by @Jisan7509
plugin for Cat_Userbot
"""
from telethon.errors.rpcerrorlist import YouBlockedUserError
from userbot.plugins import catub, edit_or_reply, reply_id
plugin_category = "extra"
@catub.cat_cmd(
pattern="score$",
command=("score", plugin_category),
info={
"header": "To see the score of an ongoing match.",
"usage": "{tr}score",
},
)
async def _(event):
"To see the score of an ongoing match."
chat = "@cricbuzz_bot"
reply_to_id = await reply_id(event)
catevent = await edit_or_reply(event, "```Gathering info...```")
async with event.client.conversation(chat) as conv:
try:
msg_start = await conv.send_message("/start")
response = await conv.get_response()
msg = await conv.send_message("/score")
respond = await conv.get_response()
await event.client.send_read_acknowledge(conv.chat_id)
except YouBlockedUserError:
await catevent.edit("Unblock @cricbuzz_bot & try again")
return
if respond.text.startswith("I can't find that"):
await catevent.edit("sorry i can't find it")
else:
await catevent.delete()
await event.client.send_message(
event.chat_id, respond.message, reply_to=reply_to_id
)
await event.client.delete_messages(
conv.chat_id, [msg_start.id, msg.id, response.id, respond.id]
)
@catub.cat_cmd(
pattern="cric ([\s\S]*)",
command=("cric", plugin_category),
info={
"header": "To see the scoreboard or commentary of a match",
"description": "To check commands showed in {tr}score cmd that is for getting scoreboard or commentary.",
"usage": "{tr}cric <command showed in {tr}score>",
"examples": "{tr}cric /scorecard_30....",
},
)
async def _(event):
"To see the scoreboard or commentary of a match"
details = event.pattern_match.group(1)
chat = "@cricbuzz_bot"
reply_to_id = await reply_id(event)
catevent = await edit_or_reply(event, "```Gathering info...```")
async with event.client.conversation(chat) as conv:
try:
msg_start = await conv.send_message("/start")
response = await conv.get_response()
msg = await conv.send_message(f"{details}")
respond = await conv.get_response()
await event.client.send_read_acknowledge(conv.chat_id)
except YouBlockedUserError:
await catevent.edit("Unblock @cricbuzz_bot & try again")
return
if respond.text.startswith("I can't find that"):
await catevent.edit("sorry i can't find it")
else:
await catevent.delete()
await event.client.send_message(
event.chat_id, respond.message, reply_to=reply_to_id
)
await event.client.delete_messages(
conv.chat_id, [msg_start.id, msg.id, response.id, respond.id]
)