Skip to content

Commit

Permalink
ref: complete
Browse files Browse the repository at this point in the history
  • Loading branch information
NikitosKey committed Dec 21, 2024
1 parent f332881 commit e7175c3
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 66 deletions.
2 changes: 1 addition & 1 deletion bot/handlers/callback_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from bot.settings import load_texts


async def callback_handler(update: Update, context: CallbackContext) -> None:
async def callback_handler(update: Update, _context: CallbackContext) -> None:
"""
This handler processes the inline buttons on the menu.
"""
Expand Down
2 changes: 1 addition & 1 deletion bot/handlers/help_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from bot.settings import load_texts


async def help_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
async def help_handler(update: Update, _context: ContextTypes.DEFAULT_TYPE) -> None:
"""Send a message when the command /help is issued."""
logging.getLogger(__name__).info(
"%s use %s", update.message.from_user.id, update.message.text
Expand Down
2 changes: 1 addition & 1 deletion bot/handlers/start_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from bot.settings import load_texts


async def start_handler(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
async def start_handler(update: Update, _context: ContextTypes.DEFAULT_TYPE) -> None:
"""Send a message when the command /start is issued."""
logging.getLogger(__name__).info(
"%s use %s", update.message.from_user.id, update.message.text
Expand Down
2 changes: 0 additions & 2 deletions bot/roles/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ class Admin(Barman):
"""
Represents an admin role in the bot.
"""

pass
23 changes: 3 additions & 20 deletions bot/roles/barman.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,7 @@ def __build_queue_menu(self) -> InlineKeyboardMarkup:
buttons.append([button])
else:
logging.getLogger(__name__).info("No orders in database")
buttons.append(
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
]
)
buttons.append(self.back_to_menu_button)
return InlineKeyboardMarkup(buttons)

def __build_pre_complete_order_menu(self, data) -> InlineKeyboardMarkup:
Expand All @@ -66,12 +59,7 @@ def __build_pre_complete_order_menu(self, data) -> InlineKeyboardMarkup:
self.texts["back_button"], callback_data=self.texts["queue_button"]
)
],
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
],
self.back_to_menu_button,
]
return InlineKeyboardMarkup(buttons)

Expand All @@ -82,12 +70,7 @@ def __build_complete_order_menu(self) -> InlineKeyboardMarkup:
self.texts["back_button"], callback_data=self.texts["queue_button"]
)
],
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
],
self.back_to_menu_button,
]
return InlineKeyboardMarkup(buttons)

Expand Down
52 changes: 12 additions & 40 deletions bot/roles/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ def __init__(self, db, tg_user_id, texts):
self.db = db
self.tg_user_id = tg_user_id
self.texts = texts
self.back_to_menu_button = [
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
]

def create_customer_menu_buttons(self):
"""Create buttons for the customer menu."""
Expand Down Expand Up @@ -65,14 +71,7 @@ def __build_show_products_menu(self) -> InlineKeyboardMarkup:
buttons.append([button])
else:
logging.getLogger(__name__).info("No products in database")
buttons.append(
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
]
)
buttons.append(self.back_to_menu_button)
return InlineKeyboardMarkup(buttons)

def __build_show_product_info_menu(self, data) -> InlineKeyboardMarkup:
Expand All @@ -87,12 +86,7 @@ def __build_show_product_info_menu(self, data) -> InlineKeyboardMarkup:
callback_data=self.texts["show_products_button"],
)
],
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
],
self.back_to_menu_button,
]
return InlineKeyboardMarkup(buttons)

Expand All @@ -118,12 +112,7 @@ def __build_pre_approve_order_menu(self, data) -> InlineKeyboardMarkup:
callback_data=self.texts["make_order_button"],
)
],
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
],
self.back_to_menu_button,
]
return InlineKeyboardMarkup(buttons)

Expand All @@ -133,12 +122,7 @@ def __build_approve_order_menu(self, pre_data) -> InlineKeyboardMarkup:
"""
buttons = [
[InlineKeyboardButton(self.texts["back_button"], callback_data=pre_data)],
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
],
self.back_to_menu_button,
]
return InlineKeyboardMarkup(buttons)

Expand All @@ -158,14 +142,7 @@ def __build_show_orders_menu(self) -> InlineKeyboardMarkup:
logging.getLogger(__name__).info(
"No orders found for user %s", self.tg_user_id
)
buttons.append(
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
]
)
buttons.append(self.back_to_menu_button)
return InlineKeyboardMarkup(buttons)

def __build_show_order_info_menu(self) -> InlineKeyboardMarkup:
Expand All @@ -179,12 +156,7 @@ def __build_show_order_info_menu(self) -> InlineKeyboardMarkup:
callback_data=self.texts["show_orders_button"],
)
],
[
InlineKeyboardButton(
self.texts["back_to_menu_button"],
callback_data=self.texts["back_to_menu_button"],
)
],
self.back_to_menu_button,
]
return InlineKeyboardMarkup(buttons)

Expand Down
5 changes: 4 additions & 1 deletion res/locales/ru.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[texts]
start = 'Привет! Я бот. Нажимай на кнопку "/help" для получения подсказок по командам.'
start_description = 'Запуск и перезапуск бота.'
help = 'Помощь'
help = """Список команд:
/start - запуск бота,
/help - показать список команд,
/menu - показать менюшечку."""
help_description = 'Показывает список доступных команд.'
menu = 'Менюшечка'
menu_description = 'Показывает менюшечку.'
Expand Down

0 comments on commit e7175c3

Please sign in to comment.