Update aiogram 3 template

This commit is contained in:
dj
2026-05-29 09:44:39 +03:00
parent e144cb1424
commit 2eced5dc4f
43 changed files with 1877 additions and 1252 deletions
+15 -12
View File
@@ -2,29 +2,32 @@
from aiogram import Bot
from aiogram.types import BotCommand, BotCommandScopeChat, BotCommandScopeDefault
from tgbot.data.config import get_admins
from tgbot.data.config import BOT_DATABASE_EXPORT, get_admins
from tgbot.utils.misc.bot_logging import bot_logger
# Commands for users
# Команды для обычных пользователей
user_commands = [
BotCommand(command="start", description="♻️ Restart bot"),
BotCommand(command="menu", description="🌀 Get keyboards"),
BotCommand(command="start", description="♻️ Перезапуск бота"),
BotCommand(command="menu", description="🌀 Получение клавиатуры"),
]
# Commands for admins
# Команды для админов
admin_commands = [
BotCommand(command="start", description="♻️ Restart bot"),
BotCommand(command="menu", description="🌀 Get keyboards"),
BotCommand(command="log", description="🖨 Get Logs"),
BotCommand(command="db", description="📦 Get Database"),
BotCommand(command="start", description="♻️ Перезапуск бота"),
BotCommand(command="menu", description="🌀 Получение клавиатуры"),
BotCommand(command="log", description="🖨 Получить логи"),
]
if BOT_DATABASE_EXPORT:
admin_commands.append(BotCommand(command="db", description="📦 Получить БД"))
# Set commands
# Обновление списка команд в Telegram
async def set_commands(bot: Bot):
await bot.set_my_commands(user_commands, scope=BotCommandScopeDefault())
for admin in get_admins():
try:
await bot.set_my_commands(admin_commands, scope=BotCommandScopeChat(chat_id=admin))
except:
...
except Exception:
bot_logger.warning("Не удалось обновить команды для админа %s", admin, exc_info=True)