Refactor imports across multiple files to improve code organization and readability.
All checks were successful
CI pipeline / Test & Code Quality (push) Successful in 34s
All checks were successful
CI pipeline / Test & Code Quality (push) Successful in 34s
This commit is contained in:
@@ -12,6 +12,7 @@ from typing import Any, Callable, Dict, Protocol, Union
|
||||
# Third-party imports
|
||||
from aiogram import types
|
||||
from aiogram.types import FSInputFile
|
||||
|
||||
from database.models import TelegramPost, User
|
||||
from helper_bot.keyboards import get_reply_keyboard_for_post
|
||||
|
||||
@@ -171,7 +172,9 @@ class UserService:
|
||||
Returns:
|
||||
Отформатированное сообщение для админов
|
||||
"""
|
||||
safe_full_name = html.escape(full_name) if full_name else "Неизвестный пользователь"
|
||||
safe_full_name = (
|
||||
html.escape(full_name) if full_name else "Неизвестный пользователь"
|
||||
)
|
||||
safe_username = html.escape(username) if username else None
|
||||
safe_message_text = html.escape(message_text) if message_text else ""
|
||||
|
||||
@@ -198,7 +201,9 @@ class UserService:
|
||||
# Получаем дату регистрации
|
||||
user_info = await self.db.get_user_by_id(user_id)
|
||||
if user_info and user_info.date_added:
|
||||
date_added = datetime.fromtimestamp(user_info.date_added).strftime("%d.%m.%Y")
|
||||
date_added = datetime.fromtimestamp(user_info.date_added).strftime(
|
||||
"%d.%m.%Y"
|
||||
)
|
||||
else:
|
||||
date_added = "Неизвестно"
|
||||
|
||||
@@ -332,9 +337,7 @@ class PostService:
|
||||
if self.scoring_manager:
|
||||
await self.scoring_manager.add_submitted_post(text, post_id, rag_score)
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"PostService: Ошибка добавления поста в submitted: {e}"
|
||||
)
|
||||
logger.warning(f"PostService: Ошибка добавления поста в submitted: {e}")
|
||||
|
||||
async def _get_scores_with_error_handling(self, text: str) -> tuple:
|
||||
"""
|
||||
@@ -526,7 +529,9 @@ class PostService:
|
||||
# Сохраняем скоры если есть
|
||||
if ml_scores_json:
|
||||
asyncio.create_task(
|
||||
self._save_scores_background(sent_message.message_id, ml_scores_json)
|
||||
self._save_scores_background(
|
||||
sent_message.message_id, ml_scores_json
|
||||
)
|
||||
)
|
||||
|
||||
# Индексируем пост в RAG
|
||||
@@ -544,7 +549,9 @@ class PostService:
|
||||
text="Твой пост был выложен🥰",
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"PostService: Не удалось уведомить автора {author_id}: {e}")
|
||||
logger.warning(
|
||||
f"PostService: Не удалось уведомить автора {author_id}: {e}"
|
||||
)
|
||||
|
||||
logger.info(
|
||||
f"PostService: Пост авто-опубликован в {self.settings.main_public}, "
|
||||
@@ -562,7 +569,9 @@ class PostService:
|
||||
try:
|
||||
await self.scoring_manager.on_post_declined(original_text)
|
||||
except Exception as e:
|
||||
logger.warning(f"PostService: Ошибка обучения RAG на отклоненном посте: {e}")
|
||||
logger.warning(
|
||||
f"PostService: Ошибка обучения RAG на отклоненном посте: {e}"
|
||||
)
|
||||
|
||||
# Уведомляем автора
|
||||
try:
|
||||
@@ -1471,8 +1480,6 @@ class AutoModerationService:
|
||||
text=message_text,
|
||||
parse_mode="HTML",
|
||||
)
|
||||
logger.info(
|
||||
f"AutoModeration: Лог отправлен в IMPORTANT_LOGS ({action})"
|
||||
)
|
||||
logger.info(f"AutoModeration: Лог отправлен в IMPORTANT_LOGS ({action})")
|
||||
except Exception as e:
|
||||
logger.error(f"AutoModeration: Ошибка отправки лога: {e}")
|
||||
|
||||
Reference in New Issue
Block a user