From 1435571d7a8a3ff3bcb70371f7c973a66d2334b6 Mon Sep 17 00:00:00 2001 From: David Dzhalaev <72649244+DavidRomanovizc@users.noreply.github.com> Date: Tue, 22 Aug 2023 16:09:29 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Improve=20format=20of=20the=20co?= =?UTF-8?q?de?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- keyboards/inline/main_menu_inline.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/keyboards/inline/main_menu_inline.py b/keyboards/inline/main_menu_inline.py index 5fd057b9..f5382319 100644 --- a/keyboards/inline/main_menu_inline.py +++ b/keyboards/inline/main_menu_inline.py @@ -7,10 +7,14 @@ from utils.db_api import db_commands -async def start_keyboard(obj: Union[CallbackQuery, Message]) -> InlineKeyboardMarkup: +async def start_keyboard(obj: Union[CallbackQuery, Message, int]) -> InlineKeyboardMarkup: markup = InlineKeyboardMarkup(row_width=2) - user_db = await db_commands.select_user(telegram_id=obj.from_user.id) + try: + user_db = await db_commands.select_user(telegram_id=obj.from_user.id) + except AttributeError: + user_db = await db_commands.select_user(telegram_id=obj) status = user_db["status"] + support_ids = load_config().tg_bot.support_ids[0] registration = InlineKeyboardButton(text=_("➕ Регистрация"), callback_data="registration") language = InlineKeyboardButton(text=_("🌐 Язык"), callback_data="language_reg") my_profile = InlineKeyboardButton(text=_("👤 Моя анекта"), callback_data="my_profile") @@ -27,6 +31,10 @@ async def start_keyboard(obj: Union[CallbackQuery, Message]) -> InlineKeyboardMa markup.row(my_profile) markup.row(view_ques, meetings) markup.row(information, filters) - if load_config().tg_bot.support_ids[0] != obj.from_user.id: - markup.row(support) + try: + if support_ids != obj.from_user.id: + markup.row(support) + except AttributeError: + if support_ids != obj: + markup.row(support) return markup