Template
mirror of
https://github.com/djimboy/djimbo_template_aio3.git
synced 2026-08-26 15:07:43 +00:00
Update aiogram 3 template
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user