refactor(stars_bot): rename modules and await notification bot calls

This commit is contained in:
2026-07-29 21:06:41 +05:00
parent 1d4226c580
commit 961f2d544c
3 changed files with 12 additions and 10 deletions
+1 -1
View File
@@ -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__)
@@ -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:
+10 -8
View File
@@ -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,