mute and ban commands with photos

This commit is contained in:
2025-07-25 20:19:07 +03:00
parent a714e0d05c
commit 3f23b4c708
6 changed files with 502 additions and 409 deletions

View File

@@ -1,6 +1,7 @@
from telebot.async_telebot import AsyncTeleBot
from telebot.types import Message
import logging
import os
from database import db
# Инициализация
@@ -47,7 +48,7 @@ class ActionReporter:
return text
# Отправляет лог действия в админ-чат
async def log_action(self, action: str, user_id: int, admin_id: int, reason: str, duration: str):
async def log_action(self, action: str, user_id: int, admin_id: int, reason: str, duration: str, photo_path: str):
try:
# Получаем информацию о пользователе и администраторе
@@ -64,9 +65,15 @@ class ActionReporter:
msg += f"📝 <b>Причина:</b> <i>{reason}</i>\n"
msg += f"\n{user_info}\n\n{admin_info}"
# Отправляем сообщение
await self.bot.send_message(self.log_chat_id, msg, message_thread_id=self.log_thread_id)
# Отправляем лог с изображением
if photo_path and os.path.exists(photo_path):
with open(photo_path, 'rb') as photo_file:
await self.bot.send_photo(self.log_chat_id, photo_file, caption=msg, message_thread_id=self.log_thread_id)
# Отправляем лог без изображения
else:
await self.bot.send_message(self.log_chat_id, msg, message_thread_id=self.log_thread_id)
except Exception as e:
logging.error(f"Ошибка отправки лога: {str(e)}")