diff --git a/main.py b/main.py index ee25015..4fe8728 100644 --- a/main.py +++ b/main.py @@ -3,7 +3,7 @@ import asyncio import logging from config import Config -from modules.telegram import TelegramStarsBot +from modules.stars_bot import TelegramStarsBot logger = logging.getLogger(__name__) diff --git a/modules/bot.py b/modules/notification_bot.py similarity index 99% rename from modules/bot.py rename to modules/notification_bot.py index 578fe88..a5baeb5 100644 --- a/modules/bot.py +++ b/modules/notification_bot.py @@ -32,7 +32,7 @@ class NotificationBot: keyboard = None if link: keyboard = InlineKeyboardMarkup( - inline_keyboard=[[InlineKeyboardButton(text=f"Перейти")]] + inline_keyboard=[[InlineKeyboardButton(text=f"Перейти", url=link)]] ) if not reply_to: diff --git a/modules/telegram.py b/modules/stars_bot.py similarity index 96% rename from modules/telegram.py rename to modules/stars_bot.py index ea585b5..55cd8ad 100644 --- a/modules/telegram.py +++ b/modules/stars_bot.py @@ -11,7 +11,7 @@ from typing import List, Optional, Dict, Any from config import Config from modules.lolz import Lolz -from modules.bot import NotificationBot +from modules.notification_bot import NotificationBot from modules.misc import ProcessedPostsManager logger = logging.getLogger(__name__) @@ -167,7 +167,7 @@ class TelegramStarsBot: self.processed_manager.mark_processed(post_id) if self.notification_bot: - self.notification_bot.failure( + await self.notification_bot.failure( post=post, reason=f"пост уже имеет комментарии", post_message_id=post_message_id, @@ -181,7 +181,7 @@ class TelegramStarsBot: self.processed_manager.mark_processed(post_id) if self.notification_bot: - self.notification_bot.failure( + await self.notification_bot.failure( post=post, reason=f"у поста отсутствует содержимое", post_message_id=post_message_id, @@ -195,7 +195,7 @@ class TelegramStarsBot: self.processed_manager.mark_processed(post_id) if self.notification_bot: - self.notification_bot.failure( + await self.notification_bot.failure( post=post, reason=f"в посте не найдено ссылок Telegram", post_message_id=post_message_id, @@ -205,7 +205,9 @@ class TelegramStarsBot: logger.info(f"В посте {post_id} найдено ссылок: {len(links)}.") if self.notification_bot: - post_message_id = self.notification_bot.new_post(post=post, links=links) + post_message_id = await self.notification_bot.new_post( + post=post, links=links + ) successful_reactions = 0 for link in links: @@ -232,7 +234,7 @@ class TelegramStarsBot: await self.lolz_api.create_comment(post_id, reply_message) if self.notification_bot: - self.notification_bot.success( + await self.notification_bot.success( link=parsed_link, post_message_id=post_message_id ) @@ -242,7 +244,7 @@ class TelegramStarsBot: ) if self.notification_bot: - self.notification_bot.failure( + await self.notification_bot.failure( post=post, reason=f"poster_user_id отсутствует", post_message_id=post_message_id, @@ -254,7 +256,7 @@ class TelegramStarsBot: ) if self.notification_bot: - self.notification_bot.failure( + await self.notification_bot.failure( post=post, reason=f"ни одна звезда не была отправлена успешно", post_message_id=post_message_id,