Skip to content

Commit e7175c3

Browse files
committed
ref: complete
1 parent f332881 commit e7175c3

7 files changed

Lines changed: 22 additions & 66 deletions

File tree

‎bot/handlers/callback_handler.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from bot.settings import load_texts
1313

1414

15-
async def callback_handler(update: Update, context: CallbackContext) -> None:
15+
async def callback_handler(update: Update, _context: CallbackContext) -> None:
1616
"""
1717
This handler processes the inline buttons on the menu.
1818
"""

‎bot/handlers/help_handler.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from bot.settings import load_texts
1010

1111

12-
async def help_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
12+
async def help_handler(update: Update, _context: ContextTypes.DEFAULT_TYPE) -> None:
1313
"""Send a message when the command /help is issued."""
1414
logging.getLogger(__name__).info(
1515
"%s use %s", update.message.from_user.id, update.message.text

‎bot/handlers/start_handler.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from bot.settings import load_texts
1111

1212

13-
async def start_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
13+
async def start_handler(update: Update, _context: ContextTypes.DEFAULT_TYPE) -> None:
1414
"""Send a message when the command /start is issued."""
1515
logging.getLogger(__name__).info(
1616
"%s use %s", update.message.from_user.id, update.message.text

‎bot/roles/admin.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,3 @@ class Admin(Barman):
99
"""
1010
Represents an admin role in the bot.
1111
"""
12-
13-
pass

‎bot/roles/barman.py‎

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,7 @@ def __build_queue_menu(self) -> InlineKeyboardMarkup:
4444
buttons.append([button])
4545
else:
4646
logging.getLogger(__name__).info("No orders in database")
47-
buttons.append(
48-
[
49-
InlineKeyboardButton(
50-
self.texts["back_to_menu_button"],
51-
callback_data=self.texts["back_to_menu_button"],
52-
)
53-
]
54-
)
47+
buttons.append(self.back_to_menu_button)
5548
return InlineKeyboardMarkup(buttons)
5649

5750
def __build_pre_complete_order_menu(self, data) -> InlineKeyboardMarkup:
@@ -66,12 +59,7 @@ def __build_pre_complete_order_menu(self, data) -> InlineKeyboardMarkup:
6659
self.texts["back_button"], callback_data=self.texts["queue_button"]
6760
)
6861
],
69-
[
70-
InlineKeyboardButton(
71-
self.texts["back_to_menu_button"],
72-
callback_data=self.texts["back_to_menu_button"],
73-
)
74-
],
62+
self.back_to_menu_button,
7563
]
7664
return InlineKeyboardMarkup(buttons)
7765

@@ -82,12 +70,7 @@ def __build_complete_order_menu(self) -> InlineKeyboardMarkup:
8270
self.texts["back_button"], callback_data=self.texts["queue_button"]
8371
)
8472
],
85-
[
86-
InlineKeyboardButton(
87-
self.texts["back_to_menu_button"],
88-
callback_data=self.texts["back_to_menu_button"],
89-
)
90-
],
73+
self.back_to_menu_button,
9174
]
9275
return InlineKeyboardMarkup(buttons)
9376

‎bot/roles/customer.py‎

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ def __init__(self, db, tg_user_id, texts):
2020
self.db = db
2121
self.tg_user_id = tg_user_id
2222
self.texts = texts
23+
self.back_to_menu_button = [
24+
InlineKeyboardButton(
25+
self.texts["back_to_menu_button"],
26+
callback_data=self.texts["back_to_menu_button"],
27+
)
28+
]
2329

2430
def create_customer_menu_buttons(self):
2531
"""Create buttons for the customer menu."""
@@ -65,14 +71,7 @@ def __build_show_products_menu(self) -> InlineKeyboardMarkup:
6571
buttons.append([button])
6672
else:
6773
logging.getLogger(__name__).info("No products in database")
68-
buttons.append(
69-
[
70-
InlineKeyboardButton(
71-
self.texts["back_to_menu_button"],
72-
callback_data=self.texts["back_to_menu_button"],
73-
)
74-
]
75-
)
74+
buttons.append(self.back_to_menu_button)
7675
return InlineKeyboardMarkup(buttons)
7776

7877
def __build_show_product_info_menu(self, data) -> InlineKeyboardMarkup:
@@ -87,12 +86,7 @@ def __build_show_product_info_menu(self, data) -> InlineKeyboardMarkup:
8786
callback_data=self.texts["show_products_button"],
8887
)
8988
],
90-
[
91-
InlineKeyboardButton(
92-
self.texts["back_to_menu_button"],
93-
callback_data=self.texts["back_to_menu_button"],
94-
)
95-
],
89+
self.back_to_menu_button,
9690
]
9791
return InlineKeyboardMarkup(buttons)
9892

@@ -118,12 +112,7 @@ def __build_pre_approve_order_menu(self, data) -> InlineKeyboardMarkup:
118112
callback_data=self.texts["make_order_button"],
119113
)
120114
],
121-
[
122-
InlineKeyboardButton(
123-
self.texts["back_to_menu_button"],
124-
callback_data=self.texts["back_to_menu_button"],
125-
)
126-
],
115+
self.back_to_menu_button,
127116
]
128117
return InlineKeyboardMarkup(buttons)
129118

@@ -133,12 +122,7 @@ def __build_approve_order_menu(self, pre_data) -> InlineKeyboardMarkup:
133122
"""
134123
buttons = [
135124
[InlineKeyboardButton(self.texts["back_button"], callback_data=pre_data)],
136-
[
137-
InlineKeyboardButton(
138-
self.texts["back_to_menu_button"],
139-
callback_data=self.texts["back_to_menu_button"],
140-
)
141-
],
125+
self.back_to_menu_button,
142126
]
143127
return InlineKeyboardMarkup(buttons)
144128

@@ -158,14 +142,7 @@ def __build_show_orders_menu(self) -> InlineKeyboardMarkup:
158142
logging.getLogger(__name__).info(
159143
"No orders found for user %s", self.tg_user_id
160144
)
161-
buttons.append(
162-
[
163-
InlineKeyboardButton(
164-
self.texts["back_to_menu_button"],
165-
callback_data=self.texts["back_to_menu_button"],
166-
)
167-
]
168-
)
145+
buttons.append(self.back_to_menu_button)
169146
return InlineKeyboardMarkup(buttons)
170147

171148
def __build_show_order_info_menu(self) -> InlineKeyboardMarkup:
@@ -179,12 +156,7 @@ def __build_show_order_info_menu(self) -> InlineKeyboardMarkup:
179156
callback_data=self.texts["show_orders_button"],
180157
)
181158
],
182-
[
183-
InlineKeyboardButton(
184-
self.texts["back_to_menu_button"],
185-
callback_data=self.texts["back_to_menu_button"],
186-
)
187-
],
159+
self.back_to_menu_button,
188160
]
189161
return InlineKeyboardMarkup(buttons)
190162

‎res/locales/ru.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[texts]
22
start = 'Привет! Я бот. Нажимай на кнопку "/help" для получения подсказок по командам.'
33
start_description = 'Запуск и перезапуск бота.'
4-
help = 'Помощь'
4+
help = """Список команд:
5+
/start - запуск бота,
6+
/help - показать список команд,
7+
/menu - показать менюшечку."""
58
help_description = 'Показывает список доступных команд.'
69
menu = 'Менюшечка'
710
menu_description = 'Показывает менюшечку.'

0 commit comments

Comments
 (0)