-
Notifications
You must be signed in to change notification settings - Fork 1
/
commands.py
47 lines (33 loc) · 1.53 KB
/
commands.py
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
import typing
from dataclasses import dataclass
from aiogram.types import InlineKeyboardButton
from babel.support import LazyProxy
from aiogram.utils.i18n import lazy_gettext as __
@dataclass
class CallbackMenuItem:
name: LazyProxy | str
callback_data: str
command: typing.Optional[str] = None
def to_button(self, payload: str = ''):
return InlineKeyboardButton(text=str(self.name), callback_data=payload or self.callback_data)
def to_filter(self):
return lambda c: c.data and c.data == self.callback_data
@dataclass
class CallbackMenuLink:
name: LazyProxy | str
url: str
command: typing.Optional[str] = None
def to_button(self, payload: str = '', format_: str = ''):
return InlineKeyboardButton(text=str(self.name), url=(payload or self.url).format(format_))
def to_filter(self):
return None
class Commands:
GO_TO_MAIN_MENU = CallbackMenuItem(__('🔥 Let\'s go'), 'go_to_menu')
MAIN_MENU = CallbackMenuItem(__('Manage your necklace'), 'menu', command='menu')
START = CallbackMenuItem('Manage your necklace', 'start', command='start')
CONNECTION_INSTRUCTIONS = CallbackMenuItem(__('📜 Connection guide'), '', command='')
SETTINGS = CallbackMenuItem('⚙️ Settings', 'settings', command='settings')
SKIP_BOT = CallbackMenuItem(__('⏩ Skip'), 'skip_bot')
HELP = CallbackMenuItem(('ℹ️ Help'), 'help', command='help')
MANAGE_WALLET = CallbackMenuItem(__('⚙️ Wallet'), 'wallet', command='wallet')
EXIT = CallbackMenuItem(__('«'), 'exit')