-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathscore.py
38 lines (31 loc) · 1.17 KB
/
score.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
from utils.scripts import import_library
from utils.misc import modules_help, prefix
from pyrogram import Client, filters
from pyrogram.types import Message
from bs4 import BeautifulSoup
from typing import Union
aiohttp = import_library("aiohttp")
def get_text(message: Message) -> Union[str, None]:
"""Extract Text From Commands"""
if message.text is None:
return
if " " not in message.text:
return
try:
return message.text.split(None, 1)[1]
except IndexError:
pass
@Client.on_message(filters.command("score", prefix) & filters.me)
async def score(_, message: Message):
score_page = "http://static.cricinfo.com/rss/livescores.xml"
async with aiohttp.ClientSession() as session:
async with session.get(score_page) as resp:
page = await resp.text()
soup = BeautifulSoup(page, "html.parser")
result = soup.find_all("description")
sed = "".join(match.get_text() + "\n\n" for match in result)
await message.edit(
f"<b>Match information:</b><u> Credits Friday team</u>\n\n\n<code>{sed}</code>",
parse_mode="html",
)
modules_help["score"] = {"score": "get live cricket scores"}