diff --git a/bot_modules/messages.py b/bot_modules/messages.py index 97e4869..9f593f6 100644 --- a/bot_modules/messages.py +++ b/bot_modules/messages.py @@ -184,6 +184,7 @@ class ModuleMessages(mod_table_operate.TableOperateModule): for msg_name, message in msg_dict.items(): self.AddOrIgnoreMessage(message) + table_name = self.m_Table.GetName() msgs_bd = bd_item.GetAllItemsTemplate(self.m_Bot, table_name)() if msgs_bd: for m in msgs_bd: diff --git a/bot_modules/mod_table_operate.py b/bot_modules/mod_table_operate.py index 5095f44..742c93c 100644 --- a/bot_modules/mod_table_operate.py +++ b/bot_modules/mod_table_operate.py @@ -140,6 +140,8 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule): if len(a_Item) < self.m_Table.GetFieldsCount() - 1: # Для проектов это нужно. Там на 1 меньше поле. TODO разделить отправку сообщений item_access и Inline_keyboard_func return simple_message.WorkFuncResult(self.GetMessage(Messages.ERROR_FIND)) elif len(a_Item) == self.m_Table.GetFieldsCount(): + lang = str(a_CallbackQuery.from_user.language_code) + msg = msg.GetMessageForLang(lang).StaticCopy() msg.UpdateDesc(self.m_Table.ReplaceAllFieldTags(msg.GetDesc(), a_Item)) photo_field = self.m_Table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.PHOTO) if photo_field: diff --git a/bot_modules/profile.py b/bot_modules/profile.py index b7e887a..4062b38 100644 --- a/bot_modules/profile.py +++ b/bot_modules/profile.py @@ -68,7 +68,7 @@ class ModuleProfile(mod_simple_message.SimpleMessageModule): user_info = GetUserInfo(self.m_Bot, a_Message.from_user.id) lang = str(a_Message.from_user.language_code) if not user_info is None: - msg = self.GetButton(mod_simple_message.ButtonNames.START) + msg = self.GetMessage(mod_simple_message.Messages.START) msg = msg.GetMessageForLang(lang).StaticCopy() msg.UpdateDesc(table.ReplaceAllFieldTags(msg.GetDesc(), user_info)) return simple_message.WorkFuncResult(msg, item_access = str(user_info[table.GetFieldIDByDestiny(bd_table.TableFieldDestiny.ACCESS)])) diff --git a/bot_sys/aiogram_bot.py b/bot_sys/aiogram_bot.py index 8d05fce..07985c5 100644 --- a/bot_sys/aiogram_bot.py +++ b/bot_sys/aiogram_bot.py @@ -9,24 +9,6 @@ from aiogram.dispatcher import Dispatcher from aiogram.contrib.fsm_storage.memory import MemoryStorage from aiogram.utils import executor -def MakeAiogramInlineKeyboards(a_ButtonList : [InlineButton]): - buttons = [] - for row in a_ButtonList: - r = [] - for b in row: - r += [types.InlineKeyboardButton(text = str(b.label), callback_data = b.callback_data)] - buttons += [r] - - button_list_chunks = keyboard.Chunks(buttons, 20) - result = [] - for c in button_list_chunks: - result += [InlineKeyboardMarkup(inline_keyboard=c)] - - return result - -def MakeAiogramKeyboard(a_ButtonList : [[str]]): - return types.ReplyKeyboardMarkup(keyboard=a_ButtonList, resize_keyboard = True) - class AiogramBot(interfaces.IBot): def __init__(self, a_TelegramBotApiToken, a_BDFileName, a_RootIDs, a_Log): self.m_TelegramBotApiToken = a_TelegramBotApiToken diff --git a/bot_sys/bot_messages.py b/bot_sys/bot_messages.py index d616a00..dca7307 100644 --- a/bot_sys/bot_messages.py +++ b/bot_sys/bot_messages.py @@ -76,9 +76,8 @@ class BotMessages: a_MessageLang = self.a_DefaultLanguage cur_msg = BotMessage(self, a_MessageName, a_MessageDesc, a_MessageLang, a_MessagePhotoID, a_DateTime) msg = self.GetMessages() - if not msg.get(self.a_DefaultLanguage, None): - msg[self.a_DefaultLanguage] = {} - if not msg[self.a_DefaultLanguage].get(a_MessageName, None): - msg[self.a_DefaultLanguage][a_MessageName] = cur_msg + if not msg.get(a_MessageLang, None): + msg[a_MessageLang] = {} + msg[a_MessageLang][a_MessageName] = cur_msg return cur_msg diff --git a/bot_sys/keyboard.py b/bot_sys/keyboard.py index 263e82e..2ba2190 100644 --- a/bot_sys/keyboard.py +++ b/bot_sys/keyboard.py @@ -4,8 +4,9 @@ # Работа с кнопками и клавиатурой from bot_sys import user_access -from aiogram import types, Bot, Dispatcher + from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton +from aiogram import types class ButtonWithAccess: def __init__(self, a_Label, a_AccessMode : user_access.AccessMode, a_AccessString): @@ -47,9 +48,6 @@ def MakeButtons(a_ButtonList : [ButtonWithAccess], a_UserGroups): def MakeKeyboard(a_ButtonList : [ButtonWithAccess], a_UserGroups): return MakeAiogramKeyboard(MakeButtons(a_ButtonList, a_UserGroups)) -def MakeKeyboardRemove(): - return types.ReplyKeyboardRemove() - def MakeKeyboardForMods(a_ModList, a_UserGroups): buttons = GetButtons(a_ModList) return MakeKeyboard(buttons, a_UserGroups) @@ -79,3 +77,27 @@ def MakeInlineKeyboardButtons(a_ButtonList : [InlineButtonWithAccess], a_UserGro def MakeInlineKeyboard(a_ButtonList : [InlineButtonWithAccess], a_UserGroups): return MakeAiogramInlineKeyboard(MakeInlineKeyboardButtons(a_ButtonList, a_UserGroups)) + +# ------------------------------- + + +def MakeKeyboardRemove(): + return types.ReplyKeyboardRemove() + +def MakeAiogramInlineKeyboards(a_ButtonList : [InlineButton]): + buttons = [] + for row in a_ButtonList: + r = [] + for b in row: + r += [types.InlineKeyboardButton(text = str(b.label), callback_data = b.callback_data)] + buttons += [r] + + button_list_chunks = Chunks(buttons, 20) + result = [] + for c in button_list_chunks: + result += [InlineKeyboardMarkup(inline_keyboard=c)] + + return result + +def MakeAiogramKeyboard(a_ButtonList : [[str]]): + return types.ReplyKeyboardMarkup(keyboard=a_ButtonList, resize_keyboard = True)