deadzilla 4a40f705d4 fix: resolve issue #3 (deduplication) and fix coroutine handling
- Create utils/news.py with shared RSS parsing and formatting logic
- Refactor commands/news.py and console_commands/news.py to use utils/news.py
- Fix bot.py to handle async console commands (news, pogoda)
- Fix utils/pogoda.py to fall back to Open-Meteo on requests.RequestException
- Mark issue #3 as resolved in ISSUES.md
2026-05-26 13:58:35 +05:00

26 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from utils.news import fetch_rss, format_articles, RSS_URL_ARTICLES, RSS_URL_POSTS
async def news(stop_event, bot):
"""Вывести топ-5 свежих статей по AI с Habr"""
articles = await fetch_rss(RSS_URL_ARTICLES)
if articles is None:
print("Не удалось получить новости.")
return
if not articles:
print("Новостей пока нет.")
return
lines = format_articles(articles, "Лучшие статьи за сутки / Искусственный интеллект / Хабr",
"https://habr.com/ru/hubs/artificial_intelligence/articles/top/daily/")
posts = await fetch_rss(RSS_URL_POSTS)
if posts:
lines.append("")
lines.extend(format_articles(posts, "Лучшие новости за сутки / Искусственный интеллект / Хабr",
"https://habr.com/ru/hubs/artificial_intelligence/news/top/daily/"))
for line in lines:
print(line)