Астат ты не вознесешься
This commit is contained in:
@@ -623,6 +623,98 @@ class BanWordsManager:
|
||||
await session.rollback()
|
||||
return False
|
||||
|
||||
# === AUTO COMMENTS ===
|
||||
|
||||
async def get_auto_comment_settings(self, channel_id: int) -> dict:
|
||||
"""
|
||||
Получает настройки автокомментариев для канала.
|
||||
|
||||
Args:
|
||||
channel_id: ID канала
|
||||
|
||||
Returns:
|
||||
dict: Настройки или значения по умолчанию
|
||||
"""
|
||||
from configs import settings
|
||||
|
||||
auto_comment = await self.repo.get_auto_comment(channel_id)
|
||||
|
||||
if auto_comment and auto_comment.is_enabled:
|
||||
return {
|
||||
'text': auto_comment.text,
|
||||
'button_text': auto_comment.button_text,
|
||||
'button_url': auto_comment.button_url,
|
||||
'photo_url': auto_comment.photo_url,
|
||||
'is_enabled': auto_comment.is_enabled,
|
||||
}
|
||||
|
||||
# Возвращаем настройки по умолчанию из .env
|
||||
return {
|
||||
'text': settings.AUTO_COMMENT_TEXT,
|
||||
'button_text': settings.AUTO_COMMENT_BUTTON_TEXT,
|
||||
'button_url': settings.AUTO_COMMENT_BUTTON_URL,
|
||||
'photo_url': settings.AUTO_COMMENT_PHOTO_URL,
|
||||
'is_enabled': False, # По умолчанию выключено
|
||||
}
|
||||
|
||||
async def save_auto_comment_settings(
|
||||
self,
|
||||
channel_id: int,
|
||||
text: str,
|
||||
button_text: str,
|
||||
button_url: str,
|
||||
photo_url: str,
|
||||
updated_by: Optional[int] = None
|
||||
) -> bool:
|
||||
"""Сохраняет настройки автокомментариев"""
|
||||
return await self.repo.set_auto_comment(
|
||||
channel_id=channel_id,
|
||||
text=text,
|
||||
button_text=button_text,
|
||||
button_url=button_url,
|
||||
photo_url=photo_url,
|
||||
updated_by=updated_by,
|
||||
is_enabled=True
|
||||
)
|
||||
|
||||
async def update_auto_comment_text(
|
||||
self,
|
||||
channel_id: int,
|
||||
text: str,
|
||||
updated_by: Optional[int] = None
|
||||
) -> bool:
|
||||
"""Обновляет текст автокомментария"""
|
||||
return await self.repo.update_auto_comment_field(
|
||||
channel_id, 'text', text, updated_by
|
||||
)
|
||||
|
||||
async def update_auto_comment_button(
|
||||
self,
|
||||
channel_id: int,
|
||||
button_text: str,
|
||||
button_url: str,
|
||||
updated_by: Optional[int] = None
|
||||
) -> bool:
|
||||
"""Обновляет кнопку автокомментария"""
|
||||
success_text = await self.repo.update_auto_comment_field(
|
||||
channel_id, 'button_text', button_text, updated_by
|
||||
)
|
||||
success_url = await self.repo.update_auto_comment_field(
|
||||
channel_id, 'button_url', button_url, updated_by
|
||||
)
|
||||
return success_text and success_url
|
||||
|
||||
async def update_auto_comment_photo(
|
||||
self,
|
||||
channel_id: int,
|
||||
photo_url: str,
|
||||
updated_by: Optional[int] = None
|
||||
) -> bool:
|
||||
"""Обновляет фото автокомментария"""
|
||||
return await self.repo.update_auto_comment_field(
|
||||
channel_id, 'photo_url', photo_url, updated_by
|
||||
)
|
||||
|
||||
|
||||
# Глобальный экземпляр менеджера
|
||||
_manager_instance: Optional[BanWordsManager] = None
|
||||
|
||||
Reference in New Issue
Block a user