def process_message(self, msg: Message):
command, text = self.parse_message(msg)
if text.lower() in self.help_words:
return await msg.answer("??????:\n" + "\n".join(self.description) + "\n\n????????? ????:\n" +
', '.join([k.capitalize() for k in self.news.keys()]))
url = self.news["???????"]
if text.lower() in self.news:
url = self.news[text]
async with aiohttp.ClientSession() as sess:
async with sess.get(url) as resp:
xml = xmltodict.parse(await resp.text())
if "rss" not in xml or "channel" not in xml["rss"] or "item" not in xml["rss"]["channel"]:
return await msg.answer(self.error)
items = xml["rss"]["channel"]["item"]
item = choice(items)
if "title" not in item or "description" not in item:
return await msg.answer(self.error)
return await msg.answer(f'?? {item["title"]}\n'
f'?? {item["description"]}')
评论列表
文章目录