1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
from aiogram import Bot, Router
from aiogram.filters import Command
from aiogram.types import BotCommand, BotCommandScopeChat, Message
from models import User
router = Router(name="info")
COMMANDS = [
BotCommand(
command="start",
description="Показать стартовое сообщение",
),
BotCommand(
command="help",
description="Показать список доступных команд",
),
BotCommand(
command="vpn_link",
description="Показать ссылку доступа к VPN",
),
BotCommand(
command="announcements",
description="Показать анонсы",
),
BotCommand(
command="invoices",
description="Показать счета на оплату",
),
BotCommand(
command="payments",
description="Показать платежи",
),
BotCommand(
command="suggest_user",
description="Предложить нового пользователя",
),
]
ADMIN_COMMANDS = COMMANDS + [
BotCommand(
command="new_announcement",
description="Создать новый анонс",
),
BotCommand(
command="new_invoice",
description="Создать новый счёт на оплату",
),
BotCommand(
command="add_user",
description="Создать нового пользователя",
),
BotCommand(
command="suggest_list",
description="Показать предложения новых пользователей",
),
]
@router.message(Command("start"))
async def start_command(msg: Message, bot: Bot, user: User) -> None:
await msg.answer(
"Добро пожаловать в бота для пользователей VPN.\n"
"Посмотреть список доступных команд: /help"
)
await bot.set_my_commands(
ADMIN_COMMANDS if user.is_admin() else COMMANDS,
BotCommandScopeChat(chat_id=user.id),
)
@router.message(Command("help"))
async def help_command(msg: Message, user: User) -> None:
commands = ADMIN_COMMANDS if user.is_admin() else COMMANDS
commands_text = "\n".join(f"/{c.command} - {c.description}" for c in commands)
await msg.answer(f"Список доступных команд:\n{commands_text}")
|