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)