Browse Source

Интерфейсы самого бота и начало для переделки симпл мессадж

pull/2/head
Alexei 2 years ago
parent
commit
0aa24beefc
  1. 6
      bot_modules/access.py
  2. 2
      bot_modules/backup.py
  3. 10
      bot_modules/comments.py
  4. 4
      bot_modules/groups.py
  5. 16
      bot_modules/languages.py
  6. 16
      bot_modules/messages.py
  7. 16
      bot_modules/needs.py
  8. 2
      bot_modules/profile.py
  9. 16
      bot_modules/projects.py
  10. 4
      bot_modules/start.py
  11. 14
      bot_modules/tasks.py
  12. 46
      bot_sys/aiogram_bot.py
  13. 5
      bot_sys/bot_bd.py
  14. 21
      bot_sys/interfaces.py
  15. 35
      bot_sys/keyboard.py
  16. 4
      template/bd_item_add.py
  17. 2
      template/bd_item_delete.py
  18. 4
      template/bd_item_select.py
  19. 6
      template/simple_message.py

6
bot_modules/access.py

@ -136,7 +136,7 @@ def ShowMessageTemplate(a_StringMessage):
return simple_message.WorkFuncResult(msg, item_access = a_Item[1]) return simple_message.WorkFuncResult(msg, item_access = a_Item[1])
return ShowMessage return ShowMessage
def SimpleMessageTemplate(a_StringMessage): def SimpleMessageTemplateLegacy(a_StringMessage):
async def ShowMessage(a_CallbackQuery : types.CallbackQuery): async def ShowMessage(a_CallbackQuery : types.CallbackQuery):
return simple_message.WorkFuncResult(a_StringMessage) return simple_message.WorkFuncResult(a_StringMessage)
return ShowMessage return ShowMessage
@ -178,8 +178,8 @@ def GetModuleButtons():
# Обработка кнопок # Обработка кнопок
def RegisterHandlers(dp : Dispatcher): def RegisterHandlers(dp : Dispatcher):
defaul_keyboard_func = GetEditAccessKeyboardButtons defaul_keyboard_func = GetEditAccessKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(access_start_message, defaul_keyboard_func, GetAccess), text = access_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(access_start_message, defaul_keyboard_func, GetAccess), text = access_button_name)
dp.register_message_handler(simple_message.InfoMessageTemplate(help_message, defaul_keyboard_func, GetAccess), text = help_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(help_message, defaul_keyboard_func, GetAccess), text = help_button_name)
sql_request.RequestToBDRegisterHandlers(dp, sql_request_button_name, request_start_message, FSMRequestToBDAccess, defaul_keyboard_func, user_access.AccessMode.ACCEES_EDIT, GetAccess) sql_request.RequestToBDRegisterHandlers(dp, sql_request_button_name, request_start_message, FSMRequestToBDAccess, defaul_keyboard_func, user_access.AccessMode.ACCEES_EDIT, GetAccess)

2
bot_modules/backup.py

@ -81,7 +81,7 @@ def GetModuleButtons():
# Обработка кнопок # Обработка кнопок
def RegisterHandlers(dp : Dispatcher): def RegisterHandlers(dp : Dispatcher):
dp.register_message_handler(simple_message.InfoMessageTemplate(backup_message, GetBackupKeyboardButtons, GetAccess), text = backup_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(backup_message, GetBackupKeyboardButtons, GetAccess), text = backup_button_name)
dp.register_message_handler(file_message.BackupFileTemplate(bot_bd.GetBDFileName(), backup_bd_message, GetAccess, GetBackupKeyboardButtons, error_backup_message), text = backup_bd_button_name) dp.register_message_handler(file_message.BackupFileTemplate(bot_bd.GetBDFileName(), backup_bd_message, GetAccess, GetBackupKeyboardButtons, error_backup_message), text = backup_bd_button_name)
dp.register_message_handler(file_message.BackupFileTemplate(log.g_log_file_name, backup_log_message, GetAccess, GetBackupKeyboardButtons, error_backup_message), text = backup_log_button_name) dp.register_message_handler(file_message.BackupFileTemplate(log.g_log_file_name, backup_log_message, GetAccess, GetBackupKeyboardButtons, error_backup_message), text = backup_log_button_name)

10
bot_modules/comments.py

@ -166,7 +166,7 @@ def ShowMessageTemplate(a_StringMessage):
return simple_message.WorkFuncResult(msg, item_access = a_Item[2]) return simple_message.WorkFuncResult(msg, item_access = a_Item[2])
return ShowMessage return ShowMessage
def SimpleMessageTemplate(a_StringMessage): def SimpleMessageTemplateLegacy(a_StringMessage):
async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item): async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item):
return simple_message.WorkFuncResult(a_StringMessage) return simple_message.WorkFuncResult(a_StringMessage)
return ShowMessage return ShowMessage
@ -252,7 +252,7 @@ def RegisterHandlers(dp : Dispatcher):
# Стартовое сообщение # Стартовое сообщение
dp.register_message_handler(simple_message.SimpleMessageTemplate(CommentsOpen, defaul_keyboard_func, GetAccess), text = comments_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(CommentsOpen, defaul_keyboard_func, GetAccess), text = comments_button_name)
# Список комментариев # Список комментариев
a_Prefix = RegisterSelectParent(list_comment_button_name, user_access.AccessMode.VIEW) a_Prefix = RegisterSelectParent(list_comment_button_name, user_access.AccessMode.VIEW)
@ -291,8 +291,8 @@ def RegisterHandlers(dp : Dispatcher):
bd_item.GetCheckForPrefixFunc(a_Prefix), \ bd_item.GetCheckForPrefixFunc(a_Prefix), \
FSMCreateComment, \ FSMCreateComment, \
AddBDItemFunc, \ AddBDItemFunc, \
SimpleMessageTemplate(comment_create_desc_message), \ SimpleMessageTemplateLegacy(comment_create_desc_message), \
SimpleMessageTemplate(comment_success_create_message), \ SimpleMessageTemplateLegacy(comment_success_create_message), \
a_Prefix,\ a_Prefix,\
needs.table_name, \ needs.table_name, \
needs.key_name, \ needs.key_name, \
@ -325,7 +325,7 @@ def RegisterHandlers(dp : Dispatcher):
# Редактирование комментариев # Редактирование комментариев
edit_keyboard_func = GetEditCommentKeyboardButtons edit_keyboard_func = GetEditCommentKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(comment_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_comment_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(comment_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_comment_button_name)
RegisterEdit(edit_comment_desc_button_name, FSMEditCommentDescItem, comment_edit_desc_message, desc_field, bd_item.FieldType.text) RegisterEdit(edit_comment_desc_button_name, FSMEditCommentDescItem, comment_edit_desc_message, desc_field, bd_item.FieldType.text)
RegisterEdit(edit_comment_access_button_name, FSMEditCommentAccessItem, comment_edit_access_message, access_field, bd_item.FieldType.text) RegisterEdit(edit_comment_access_button_name, FSMEditCommentAccessItem, comment_edit_access_message, access_field, bd_item.FieldType.text)

4
bot_modules/groups.py

@ -124,7 +124,7 @@ def GetModuleButtons():
# Обработка кнопок # Обработка кнопок
def RegisterHandlers(dp : Dispatcher): def RegisterHandlers(dp : Dispatcher):
dp.register_message_handler(simple_message.InfoMessageTemplate(group_start_message, GetEditGroupKeyboardButtons, GetAccess), text = user_group_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(group_start_message, GetEditGroupKeyboardButtons, GetAccess), text = user_group_button_name)
dp.register_message_handler(simple_message.InfoMessageTemplate(help_message, GetEditGroupKeyboardButtons, GetAccess), text = help_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(help_message, GetEditGroupKeyboardButtons, GetAccess), text = help_button_name)
sql_request.RequestToBDRegisterHandlers(dp, sql_request_button_name, request_start_message, FSMRequestToBD, GetEditGroupKeyboardButtons, user_access.AccessMode.EDIT, GetAccess) sql_request.RequestToBDRegisterHandlers(dp, sql_request_button_name, request_start_message, FSMRequestToBD, GetEditGroupKeyboardButtons, user_access.AccessMode.EDIT, GetAccess)

16
bot_modules/languages.py

@ -185,7 +185,7 @@ def GetStartLanguageKeyboardButtons(a_Language, a_UserGroups):
def GetViewItemInlineKeyboardTemplate(a_ItemID): def GetViewItemInlineKeyboardTemplate(a_ItemID):
def GetViewItemInlineKeyboard(a_Message, a_UserGroups): def GetViewItemInlineKeyboard(a_Message, a_UserGroups):
cur_buttons = [ cur_buttons = [
keyboard.InlineButton(messages.list_message_button_name, messages.select_messages_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW), keyboard.InlineButtonWithAccess(messages.list_message_button_name, messages.select_messages_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW),
] ]
return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups) return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups)
return GetViewItemInlineKeyboard return GetViewItemInlineKeyboard
@ -216,7 +216,7 @@ def ShowMessageTemplate(a_StringLanguage, keyboard_template_func = None):
return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func) return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func)
return ShowLanguage return ShowLanguage
def SimpleMessageTemplate(a_StringLanguage): def SimpleMessageTemplateLegacy(a_StringLanguage):
async def ShowLanguage(a_CallbackQuery : types.CallbackQuery, a_Item): async def ShowLanguage(a_CallbackQuery : types.CallbackQuery, a_Item):
return simple_message.WorkFuncResult(a_StringLanguage) return simple_message.WorkFuncResult(a_StringLanguage)
return ShowLanguage return ShowLanguage
@ -298,7 +298,7 @@ def RegisterHandlers(dp : Dispatcher):
defaul_keyboard_func = GetStartLanguageKeyboardButtons defaul_keyboard_func = GetStartLanguageKeyboardButtons
# Список языков # Список языков
dp.register_message_handler(simple_message.SimpleMessageTemplate(LanguagesOpen, defaul_keyboard_func, GetAccess), text = languages_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(LanguagesOpen, defaul_keyboard_func, GetAccess), text = languages_button_name)
bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, \ bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, \
list_language_button_name, \ list_language_button_name, \
table_name, \ table_name, \
@ -333,10 +333,10 @@ def RegisterHandlers(dp : Dispatcher):
FSMCreateLanguage.desc, \ FSMCreateLanguage.desc, \
FSMCreateLanguage.photo,\ FSMCreateLanguage.photo,\
AddBDItemFunc, \ AddBDItemFunc, \
SimpleMessageTemplate(language_create_name_message), \ SimpleMessageTemplateLegacy(language_create_name_message), \
SimpleMessageTemplate(language_create_desc_message), \ SimpleMessageTemplateLegacy(language_create_desc_message), \
SimpleMessageTemplate(language_create_photo_message), \ SimpleMessageTemplateLegacy(language_create_photo_message), \
SimpleMessageTemplate(language_success_create_message), \ SimpleMessageTemplateLegacy(language_success_create_message), \
None,\ None,\
None, \ None, \
None, \ None, \
@ -370,7 +370,7 @@ def RegisterHandlers(dp : Dispatcher):
field_type = a_FieldType\ field_type = a_FieldType\
) )
dp.register_message_handler(simple_message.InfoMessageTemplate(language_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_language_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(language_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_language_button_name)
RegisterEdit(edit_language_photo_button_name, FSMEditLanguagePhotoItem, language_edit_photo_message, photo_field, bd_item.FieldType.photo) RegisterEdit(edit_language_photo_button_name, FSMEditLanguagePhotoItem, language_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_language_name_button_name, FSMEditLanguageNameItem, language_edit_name_message, name_field, bd_item.FieldType.text) RegisterEdit(edit_language_name_button_name, FSMEditLanguageNameItem, language_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_language_desc_button_name, FSMEditLanguageDeskItem, language_edit_desc_message, desc_field, bd_item.FieldType.text) RegisterEdit(edit_language_desc_button_name, FSMEditLanguageDeskItem, language_edit_desc_message, desc_field, bd_item.FieldType.text)

16
bot_modules/messages.py

@ -193,7 +193,7 @@ def GetStartMessageKeyboardButtons(a_Message, a_UserGroups):
def GetViewItemInlineKeyboardTemplate(a_ItemID): def GetViewItemInlineKeyboardTemplate(a_ItemID):
def GetViewItemInlineKeyboard(a_Message, a_UserGroups): def GetViewItemInlineKeyboard(a_Message, a_UserGroups):
cur_buttons = [ cur_buttons = [
#keyboard.InlineButton(needs.list_need_button_name, needs.select_needs_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW), #keyboard.InlineButtonWithAccess(needs.list_need_button_name, needs.select_needs_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW),
] ]
return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups) return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups)
return GetViewItemInlineKeyboard return GetViewItemInlineKeyboard
@ -228,7 +228,7 @@ def ShowMessageTemplate(a_StringMessage, keyboard_template_func = None):
return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func) return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func)
return ShowMessage return ShowMessage
def SimpleMessageTemplate(a_StringMessage): def SimpleMessageTemplateLegacy(a_StringMessage):
async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item): async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item):
return simple_message.WorkFuncResult(a_StringMessage) return simple_message.WorkFuncResult(a_StringMessage)
return ShowMessage return ShowMessage
@ -314,7 +314,7 @@ def RegisterHandlers(dp : Dispatcher):
) )
# Стартовое сообщение # Стартовое сообщение
dp.register_message_handler(simple_message.SimpleMessageTemplate(MessagesOpen, defaul_keyboard_func, GetAccess), text = messages_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(MessagesOpen, defaul_keyboard_func, GetAccess), text = messages_button_name)
# Список сообщений # Список сообщений
a_Prefix = RegisterSelectParent(list_message_button_name, user_access.AccessMode.VIEW) a_Prefix = RegisterSelectParent(list_message_button_name, user_access.AccessMode.VIEW)
@ -356,10 +356,10 @@ def RegisterHandlers(dp : Dispatcher):
FSMCreateMessage.desc, \ FSMCreateMessage.desc, \
FSMCreateMessage.photo,\ FSMCreateMessage.photo,\
AddBDItemFunc, \ AddBDItemFunc, \
SimpleMessageTemplate(message_create_name_message), \ SimpleMessageTemplateLegacy(message_create_name_message), \
SimpleMessageTemplate(message_create_desc_message), \ SimpleMessageTemplateLegacy(message_create_desc_message), \
SimpleMessageTemplate(message_create_photo_message), \ SimpleMessageTemplateLegacy(message_create_photo_message), \
SimpleMessageTemplate(message_success_create_message), \ SimpleMessageTemplateLegacy(message_success_create_message), \
a_Prefix,\ a_Prefix,\
languages.table_name, \ languages.table_name, \
languages.key_name, \ languages.key_name, \
@ -393,7 +393,7 @@ def RegisterHandlers(dp : Dispatcher):
# Редактирование сообщения # Редактирование сообщения
edit_keyboard_func = GetEditMessageKeyboardButtons edit_keyboard_func = GetEditMessageKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(message_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_message_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(message_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_message_button_name)
RegisterEdit(edit_message_photo_button_name, FSMEditMessagePhotoItem, message_edit_photo_message, photo_field, bd_item.FieldType.photo) RegisterEdit(edit_message_photo_button_name, FSMEditMessagePhotoItem, message_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_message_name_button_name, FSMEditMessageNameItem, message_edit_name_message, name_field, bd_item.FieldType.text) RegisterEdit(edit_message_name_button_name, FSMEditMessageNameItem, message_edit_name_message, name_field, bd_item.FieldType.text)

16
bot_modules/needs.py

@ -192,7 +192,7 @@ def GetStartNeedKeyboardButtons(a_Message, a_UserGroups):
def GetViewItemInlineKeyboardTemplate(a_ItemID): def GetViewItemInlineKeyboardTemplate(a_ItemID):
def GetViewItemInlineKeyboard(a_Message, a_UserGroups): def GetViewItemInlineKeyboard(a_Message, a_UserGroups):
cur_buttons = [ cur_buttons = [
keyboard.InlineButton(comments.list_comment_button_name, comments.select_comments_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW), keyboard.InlineButtonWithAccess(comments.list_comment_button_name, comments.select_comments_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW),
] ]
return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups) return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups)
return GetViewItemInlineKeyboard return GetViewItemInlineKeyboard
@ -223,7 +223,7 @@ def ShowMessageTemplate(a_StringMessage, keyboard_template_func = None):
return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func) return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func)
return ShowMessage return ShowMessage
def SimpleMessageTemplate(a_StringMessage): def SimpleMessageTemplateLegacy(a_StringMessage):
async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item): async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item):
return simple_message.WorkFuncResult(a_StringMessage) return simple_message.WorkFuncResult(a_StringMessage)
return ShowMessage return ShowMessage
@ -299,7 +299,7 @@ def RegisterHandlers(dp : Dispatcher):
# Стартовое сообщение # Стартовое сообщение
dp.register_message_handler(simple_message.SimpleMessageTemplate(NeedsOpen, defaul_keyboard_func, GetAccess), text = needs_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(NeedsOpen, defaul_keyboard_func, GetAccess), text = needs_button_name)
# Список потребностей # Список потребностей
a_Prefix = RegisterSelectParent(list_need_button_name, user_access.AccessMode.VIEW) a_Prefix = RegisterSelectParent(list_need_button_name, user_access.AccessMode.VIEW)
@ -341,10 +341,10 @@ def RegisterHandlers(dp : Dispatcher):
FSMCreateNeed.desc, \ FSMCreateNeed.desc, \
FSMCreateNeed.photo,\ FSMCreateNeed.photo,\
AddBDItemFunc, \ AddBDItemFunc, \
SimpleMessageTemplate(need_create_name_message), \ SimpleMessageTemplateLegacy(need_create_name_message), \
SimpleMessageTemplate(need_create_desc_message), \ SimpleMessageTemplateLegacy(need_create_desc_message), \
SimpleMessageTemplate(need_create_photo_message), \ SimpleMessageTemplateLegacy(need_create_photo_message), \
SimpleMessageTemplate(need_success_create_message), \ SimpleMessageTemplateLegacy(need_success_create_message), \
a_Prefix,\ a_Prefix,\
tasks.table_name, \ tasks.table_name, \
tasks.key_name, \ tasks.key_name, \
@ -378,7 +378,7 @@ def RegisterHandlers(dp : Dispatcher):
# Редактирование потребностей # Редактирование потребностей
edit_keyboard_func = GetEditNeedKeyboardButtons edit_keyboard_func = GetEditNeedKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(need_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_need_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(need_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_need_button_name)
RegisterEdit(edit_need_photo_button_name, FSMEditNeedPhotoItem, need_edit_photo_message, photo_field, bd_item.FieldType.photo) RegisterEdit(edit_need_photo_button_name, FSMEditNeedPhotoItem, need_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_need_name_button_name, FSMEditNeedNameItem, need_edit_name_message, name_field, bd_item.FieldType.text) RegisterEdit(edit_need_name_button_name, FSMEditNeedNameItem, need_edit_name_message, name_field, bd_item.FieldType.text)

2
bot_modules/profile.py

@ -125,4 +125,4 @@ def GetModuleButtons():
# Обработка кнопок # Обработка кнопок
def RegisterHandlers(dp : Dispatcher): def RegisterHandlers(dp : Dispatcher):
dp.register_message_handler(simple_message.SimpleMessageTemplate(ProfileOpen, GetStartKeyboardButtons, GetAccess), text = user_profile_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(ProfileOpen, GetStartKeyboardButtons, GetAccess), text = user_profile_button_name)

16
bot_modules/projects.py

@ -190,7 +190,7 @@ def GetStartProjectKeyboardButtons(a_Message, a_UserGroups):
def GetViewItemInlineKeyboardTemplate(a_ItemID): def GetViewItemInlineKeyboardTemplate(a_ItemID):
def GetViewItemInlineKeyboard(a_Message, a_UserGroups): def GetViewItemInlineKeyboard(a_Message, a_UserGroups):
cur_buttons = [ cur_buttons = [
keyboard.InlineButton(tasks.list_task_button_name, tasks.select_tasks_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW), keyboard.InlineButtonWithAccess(tasks.list_task_button_name, tasks.select_tasks_prefix, a_ItemID, GetAccess(), user_access.AccessMode.VIEW),
] ]
return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups) return keyboard.MakeInlineKeyboard(cur_buttons, a_UserGroups)
return GetViewItemInlineKeyboard return GetViewItemInlineKeyboard
@ -222,7 +222,7 @@ def ShowMessageTemplate(a_StringMessage, keyboard_template_func = None):
return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func) return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func)
return ShowMessage return ShowMessage
def SimpleMessageTemplate(a_StringMessage): def SimpleMessageTemplateLegacy(a_StringMessage):
async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item): async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item):
return simple_message.WorkFuncResult(a_StringMessage) return simple_message.WorkFuncResult(a_StringMessage)
return ShowMessage return ShowMessage
@ -276,7 +276,7 @@ def RegisterHandlers(dp : Dispatcher):
defaul_keyboard_func = GetStartProjectKeyboardButtons defaul_keyboard_func = GetStartProjectKeyboardButtons
# Список проектов # Список проектов
dp.register_message_handler(simple_message.SimpleMessageTemplate(ProjectsOpen, defaul_keyboard_func, GetAccess), text = projects_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(ProjectsOpen, defaul_keyboard_func, GetAccess), text = projects_button_name)
bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, \ bd_item_view.FirstSelectAndShowBDItemRegisterHandlers(dp, \
list_project_button_name, \ list_project_button_name, \
table_name, \ table_name, \
@ -311,10 +311,10 @@ def RegisterHandlers(dp : Dispatcher):
FSMCreateProject.desc, \ FSMCreateProject.desc, \
FSMCreateProject.photo,\ FSMCreateProject.photo,\
AddBDItemFunc, \ AddBDItemFunc, \
SimpleMessageTemplate(project_create_name_message), \ SimpleMessageTemplateLegacy(project_create_name_message), \
SimpleMessageTemplate(project_create_desc_message), \ SimpleMessageTemplateLegacy(project_create_desc_message), \
SimpleMessageTemplate(project_create_photo_message), \ SimpleMessageTemplateLegacy(project_create_photo_message), \
SimpleMessageTemplate(project_success_create_message), \ SimpleMessageTemplateLegacy(project_success_create_message), \
None,\ None,\
None, \ None, \
None, \ None, \
@ -348,7 +348,7 @@ def RegisterHandlers(dp : Dispatcher):
field_type = a_FieldType\ field_type = a_FieldType\
) )
dp.register_message_handler(simple_message.InfoMessageTemplate(project_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_project_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(project_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_project_button_name)
RegisterEdit(edit_project_photo_button_name, FSMEditProjectPhotoItem, project_edit_photo_message, photo_field, bd_item.FieldType.photo) RegisterEdit(edit_project_photo_button_name, FSMEditProjectPhotoItem, project_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_project_name_button_name, FSMEditProjectNameItem, project_edit_name_message, name_field, bd_item.FieldType.text) RegisterEdit(edit_project_name_button_name, FSMEditProjectNameItem, project_edit_name_message, name_field, bd_item.FieldType.text)
RegisterEdit(edit_project_desc_button_name, FSMEditProjectDeskItem, project_edit_desc_message, desc_field, bd_item.FieldType.text) RegisterEdit(edit_project_desc_button_name, FSMEditProjectDeskItem, project_edit_desc_message, desc_field, bd_item.FieldType.text)

4
bot_modules/start.py

@ -72,7 +72,7 @@ def GetModuleButtons():
# Обработка кнопок # Обработка кнопок
def RegisterHandlers(dp : Dispatcher): def RegisterHandlers(dp : Dispatcher):
dp.register_message_handler(simple_message.SimpleMessageTemplate(StartMenu, GetStartKeyboardButtons, GetAccess), commands = ['start']) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(StartMenu, GetStartKeyboardButtons, GetAccess), commands = ['start'])
dp.register_message_handler(simple_message.SimpleMessageTemplate(StartMenu, GetStartKeyboardButtons, GetAccess), text = start_menu_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(StartMenu, GetStartKeyboardButtons, GetAccess), text = start_menu_button_name)

14
bot_modules/tasks.py

@ -224,7 +224,7 @@ def ShowMessageTemplate(a_StringMessage, keyboard_template_func = None):
return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func) return simple_message.WorkFuncResult(msg, photo_id = a_Item[3], item_access = a_Item[4], keyboard_func = keyboard_func)
return ShowMessage return ShowMessage
def SimpleMessageTemplate(a_StringMessage): def SimpleMessageTemplateLegacy(a_StringMessage):
async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item): async def ShowMessage(a_CallbackQuery : types.CallbackQuery, a_Item):
return simple_message.WorkFuncResult(a_StringMessage) return simple_message.WorkFuncResult(a_StringMessage)
return ShowMessage return ShowMessage
@ -286,7 +286,7 @@ def RegisterHandlers(dp : Dispatcher):
) )
# Стартовое сообщение # Стартовое сообщение
dp.register_message_handler(simple_message.SimpleMessageTemplate(TasksOpen, defaul_keyboard_func, GetAccess), text = tasks_button_name) dp.register_message_handler(simple_message.SimpleMessageTemplateLegacy(TasksOpen, defaul_keyboard_func, GetAccess), text = tasks_button_name)
# Список задач # Список задач
a_Prefix = RegisterSelectParent(list_task_button_name, user_access.AccessMode.VIEW) a_Prefix = RegisterSelectParent(list_task_button_name, user_access.AccessMode.VIEW)
@ -328,10 +328,10 @@ def RegisterHandlers(dp : Dispatcher):
FSMCreateTask.desc, \ FSMCreateTask.desc, \
FSMCreateTask.photo,\ FSMCreateTask.photo,\
AddBDItemFunc, \ AddBDItemFunc, \
SimpleMessageTemplate(task_create_name_message), \ SimpleMessageTemplateLegacy(task_create_name_message), \
SimpleMessageTemplate(task_create_desc_message), \ SimpleMessageTemplateLegacy(task_create_desc_message), \
SimpleMessageTemplate(task_create_photo_message), \ SimpleMessageTemplateLegacy(task_create_photo_message), \
SimpleMessageTemplate(task_success_create_message), \ SimpleMessageTemplateLegacy(task_success_create_message), \
a_Prefix,\ a_Prefix,\
projects.table_name, \ projects.table_name, \
projects.key_name, \ projects.key_name, \
@ -365,7 +365,7 @@ def RegisterHandlers(dp : Dispatcher):
# Редактирование задачи # Редактирование задачи
edit_keyboard_func = GetEditTaskKeyboardButtons edit_keyboard_func = GetEditTaskKeyboardButtons
dp.register_message_handler(simple_message.InfoMessageTemplate(task_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_task_button_name) dp.register_message_handler(simple_message.InfoMessageTemplateLegacy(task_start_edit_message, edit_keyboard_func, GetAccess, access_mode = user_access.AccessMode.EDIT), text = edit_task_button_name)
RegisterEdit(edit_task_photo_button_name, FSMEditTaskPhotoItem, task_edit_photo_message, photo_field, bd_item.FieldType.photo) RegisterEdit(edit_task_photo_button_name, FSMEditTaskPhotoItem, task_edit_photo_message, photo_field, bd_item.FieldType.photo)
RegisterEdit(edit_task_name_button_name, FSMEditTaskNameItem, task_edit_name_message, name_field, bd_item.FieldType.text) RegisterEdit(edit_task_name_button_name, FSMEditTaskNameItem, task_edit_name_message, name_field, bd_item.FieldType.text)

46
bot_sys/aiogram_bot.py

@ -0,0 +1,46 @@
#-*-coding utf-8-*-
# Общественное достояние, 2023, Алексей Безбородов (Alexei Bezborodov) <AlexeiBv+mirocod_platform_bot@narod.ru>
from bot_sys import interfaces, bot_bd, keyboard
from aiogram import types
from aiogram import Bot
from aiogram.dispatcher import Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage
class AiogramBot(IBot):
def __init__(self, a_TelegramBotApiToken, a_BDFileName):
self.m_TelegramBotApiToken = a_TelegramBotApiToken
self.m_BDFileName = a_BDFileName
self.m_TBot = Bot(token=self.m_TelegramBotApiToken, parse_mode = types.ParseMode.HTML)
self.m_Storage = MemoryStorage()
self.m_Dispatcher = Dispatcher(self.m_TBot, storage = storage)
def SQLRequest(self, a_Request : str, commit = False, return_error = False, param = None):
return bot_bd.SQLRequest(self.m_BDFileName, a_Request, commit = commit, return_error = return_error, param = param)
async def SendMessage(self, a_UserID, a_Message, a_PhotoIDs, a_InlineKeyboardButtons, a_KeyboardButtons):
inline_keyboard = keyboard.MakeAiogramInlineKeyboard(a_InlineKeyboardButtons)
keyboard = keyboard.MakeAiogramKeyboard(a_KeyboardButtons)
if not keyboard:
keyboard = inline_keyboard
if a_PhotoIDs:
self.m_TBot.send_photo(
a_UserID,
a_PhotoIDs,
a_Message,
reply_markup = keyboard
)
else:
self.m_TBot.send_message(
a_UserID,
a_Message,
reply_markup = keyboard
)
def RegisterMessageHandler(self, a_MessageHandler, a_CheckFunc):
self.m_Dispatcher.register_message_handler(a_MessageHandler, a_CheckFunc)
def RegisterCallbackHandler(self, a_CallbackHandler, a_CheckFunc):
self.m_Dispatcher.register_callback_query_handler(a_CallbackHandler, a_CheckFunc)

5
bot_sys/bot_bd.py

@ -29,7 +29,10 @@ def SelectBDTemplate(a_TableName):
return SelectBD return SelectBD
def SQLRequestToBD(a_Request : str, commit = False, return_error = False, param = None): def SQLRequestToBD(a_Request : str, commit = False, return_error = False, param = None):
db = sqlite3.connect(GetBDFileName()) return SQLRequest(GetBDFileName(), a_Request, commit = commit, return_error = return_error, param = param)
def SQLRequest(a_BDFileName, a_Request : str, commit = False, return_error = False, param = None):
db = sqlite3.connect(a_BDFileName)
cursor = db.cursor() cursor = db.cursor()
result = [] result = []
error = None error = None

21
bot_sys/interfaces.py

@ -0,0 +1,21 @@
#-*-coding utf-8-*-
# Общественное достояние, 2023, Алексей Безбородов (Alexei Bezborodov) <AlexeiBv+mirocod_platform_bot@narod.ru>
from abc import ABC, abstractmethod
class IBot(ABC):
@abstractmethod
def SQLRequest(self, a_Request : str, commit = False, return_error = False, param = None):
pass
@abstractmethod
async def SendMessage(self, a_UserID, a_Message, a_PhotoIDs, a_InlineKeyboardButtons, a_KeyboardButtons):
pass
@abstractmethod
def RegisterMessageHandler(self, a_MessageHandler, a_CheckFunc):
pass
@abstractmethod
def RegisterCallbackHandler(self, a_CallbackHandler, a_CheckFunc):
pass

35
bot_sys/keyboard.py

@ -30,14 +30,19 @@ def Chunks(a_List, a_ChunkSize):
def GetButtonInRowCount(a_AllKeyCount): def GetButtonInRowCount(a_AllKeyCount):
return min(max(int(math.sqrt(a_AllKeyCount) // 1), 1), 4) return min(max(int(math.sqrt(a_AllKeyCount) // 1), 1), 4)
def MakeKeyboard(a_ButtonList : [ButtonWithAccess], a_UserGroups): def MakeAiogramKeyboard(a_ButtonList : [[str]]):
return types.ReplyKeyboardMarkup(keyboard=a_ButtonList, resize_keyboard = True)
def MakeButtons(a_ButtonList : [ButtonWithAccess], a_UserGroups):
buttons = [] buttons = []
for b in a_ButtonList: for b in a_ButtonList:
if user_access.CheckAccessString(b.access_string, a_UserGroups, b.access_mode): if user_access.CheckAccessString(b.access_string, a_UserGroups, b.access_mode):
buttons += [types.KeyboardButton(b.label)] buttons += [types.KeyboardButton(b.label)]
step = GetButtonInRowCount(len(buttons)) step = GetButtonInRowCount(len(buttons))
key = types.ReplyKeyboardMarkup(keyboard=Chunks(buttons, step), resize_keyboard = True) return Chunks(buttons, step)
return key
def MakeKeyboard(a_ButtonList : [ButtonWithAccess], a_UserGroups):
return MakeAiogramKeyboard(MakeButtons(a_ButtonList, a_UserGroups))
def MakeKeyboardRemove(): def MakeKeyboardRemove():
return types.ReplyKeyboardRemove() return types.ReplyKeyboardRemove()
@ -47,6 +52,11 @@ def MakeKeyboardForMods(a_ModList, a_UserGroups):
return MakeKeyboard(buttons, a_UserGroups) return MakeKeyboard(buttons, a_UserGroups)
class InlineButton: class InlineButton:
def __init__(self, a_Label, a_CallBackData):
self.label = a_Label
self.callback_data = str(a_CallBackData)
class InlineButtonWithAccess:
def __init__(self, a_Label, a_CallBackPrefix, a_CallBackData, a_AccessString, a_AccessMode): def __init__(self, a_Label, a_CallBackPrefix, a_CallBackData, a_AccessString, a_AccessMode):
self.label = a_Label self.label = a_Label
self.callback_prefix = a_CallBackPrefix self.callback_prefix = a_CallBackPrefix
@ -54,12 +64,23 @@ class InlineButton:
self.access_string = a_AccessString self.access_string = a_AccessString
self.access_mode = a_AccessMode self.access_mode = a_AccessMode
def MakeInlineKeyboard(a_ButtonList : [InlineButton], a_UserGroups): def MakeAiogramInlineKeyboard(a_ButtonList : [InlineButton]):
buttons = []
for row in a_ButtonList:
r = []
for b in row:
r += [types.InlineKeyboardButton(text = b.label, callback_data = b.callback_data)]
buttons += r
inline_keyboard = InlineKeyboardMarkup(inline_keyboard=buttons)
return inline_keyboard
def MakeInlineKeyboardButtons(a_ButtonList : [InlineButtonWithAccess], a_UserGroups):
buttons = [] buttons = []
for b in a_ButtonList: for b in a_ButtonList:
if user_access.CheckAccessString(b.access_string, a_UserGroups, b.access_mode): if user_access.CheckAccessString(b.access_string, a_UserGroups, b.access_mode):
buttons += [types.InlineKeyboardButton(text = b.label, callback_data = f'{b.callback_prefix}{b.callback_data}')] buttons += [InlineButton(b.label, f'{b.callback_prefix}{b.callback_data}')]
step = GetButtonInRowCount(len(buttons)) step = GetButtonInRowCount(len(buttons))
inline_keyboard = InlineKeyboardMarkup(inline_keyboard=Chunks(buttons, step)) return Chunks(buttons, step)
return inline_keyboard
def MakeInlineKeyboard(a_ButtonList : [InlineButtonWithAccess], a_UserGroups):
return MakeAiogramInlineKeyboard(MakeInlineKeyboardButtons(a_ButtonList, a_UserGroups))

4
template/bd_item_add.py

@ -39,7 +39,7 @@ def StartAddBDItemTemplate(a_FSM, a_FSMStart, a_MessageFunc, a_ParentTableName,
check.keyboard_func = a_FinishButtonFunc check.keyboard_func = a_FinishButtonFunc
return check return check
return res_of_work_func return res_of_work_func
return simple_message.SimpleMessageTemplate(StartAddBDItem, a_ButtonFunc, a_AccessFunc, access_mode) return simple_message.SimpleMessageTemplateLegacy(StartAddBDItem, a_ButtonFunc, a_AccessFunc, access_mode)
def FinishAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, a_FieldName, a_MessageFunc, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.ADD, field_type = bd_item.FieldType.text): def FinishAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, a_FieldName, a_MessageFunc, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.ADD, field_type = bd_item.FieldType.text):
return FinishOrNextAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, a_FieldName, a_MessageFunc, a_AccessFunc, a_ButtonFunc, a_ButtonFunc, True, access_mode = access_mode, field_type = field_type) return FinishOrNextAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_ParentKeyFieldName, a_FieldName, a_MessageFunc, a_AccessFunc, a_ButtonFunc, a_ButtonFunc, True, access_mode = access_mode, field_type = field_type)
@ -95,7 +95,7 @@ def FinishOrNextAddBDItemTemplate(a_FSM, a_AddBDItemFunc, a_ParentTableName, a_P
return simple_message.WorkFuncResult(error) return simple_message.WorkFuncResult(error)
return res_of_work_func return res_of_work_func
return simple_message.SimpleMessageTemplate(FinishAddBDItem, a_ButtonFunc, a_AccessFunc, access_mode) return simple_message.SimpleMessageTemplateLegacy(FinishAddBDItem, a_ButtonFunc, a_AccessFunc, access_mode)
def AddBDItem3RegisterHandlers(dp, a_StartCheckFunc, a_FSM, a_FSMName, a_FSMDesc, a_FSMPhoto, a_AddBDItemFunc, a_AddNameMessageFunc, a_AddDescMessageFunc, a_AddPhotoMessageFunc, a_FinishMessageFunc, a_ParentPrefix, a_ParentTableName : str, a_ParentKeyFieldName, a_NameField, a_DescField, a_PhotoField, a_GetButtonNameAndKeyValueAndAccessFunc, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.ADD): def AddBDItem3RegisterHandlers(dp, a_StartCheckFunc, a_FSM, a_FSMName, a_FSMDesc, a_FSMPhoto, a_AddBDItemFunc, a_AddNameMessageFunc, a_AddDescMessageFunc, a_AddPhotoMessageFunc, a_FinishMessageFunc, a_ParentPrefix, a_ParentTableName : str, a_ParentKeyFieldName, a_NameField, a_DescField, a_PhotoField, a_GetButtonNameAndKeyValueAndAccessFunc, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.ADD):
keyboard_cancel = bd_item.GetCancelKeyboardButtonsTemplate(a_AccessFunc, access_mode) keyboard_cancel = bd_item.GetCancelKeyboardButtonsTemplate(a_AccessFunc, access_mode)

2
template/bd_item_delete.py

@ -29,7 +29,7 @@ def DeleteBDItemTemplate(a_TableName, a_KeyName, a_PreDeleteWorkFunc, a_PostDele
return await a_PostDeleteWorkFunc(a_CallbackQuery, item_id) return await a_PostDeleteWorkFunc(a_CallbackQuery, item_id)
return simple_message.SimpleMessageTemplate(DeleteBDItem, a_ButtonFunc, a_AccessFunc, access_mode) return simple_message.SimpleMessageTemplateLegacy(DeleteBDItem, a_ButtonFunc, a_AccessFunc, access_mode)
def DeleteBDItemRegisterHandlers(dp, a_PrevPrefix, a_StartCheckFunc, a_TableName : str, a_KeyName, a_ParentIDFieldName,a_PreDeleteWorkFunc, a_PostDeleteWorkFunc, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.DELETE): def DeleteBDItemRegisterHandlers(dp, a_PrevPrefix, a_StartCheckFunc, a_TableName : str, a_KeyName, a_ParentIDFieldName,a_PreDeleteWorkFunc, a_PostDeleteWorkFunc, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_ButtonFunc, access_mode = user_access.AccessMode.DELETE):
reg_func = dp.register_message_handler reg_func = dp.register_message_handler

4
template/bd_item_select.py

@ -24,14 +24,14 @@ def GetBDItemsListKeyboardButtonsTemplate(a_TableName : str, a_ParentIDFieldName
if access is None: if access is None:
access = '' access = ''
if bname: if bname:
b = keyboard.InlineButton(bname, a_NextPrefix, key_value, access, access_mode) b = keyboard.InlineButtonWithAccess(bname, a_NextPrefix, key_value, access, access_mode)
items_button_list += [b] items_button_list += [b]
return keyboard.MakeInlineKeyboard(items_button_list, a_UserGroups) return keyboard.MakeInlineKeyboard(items_button_list, a_UserGroups)
return GetBDItemsListKeyboardButtons return GetBDItemsListKeyboardButtons
def SelectDBItemTemplate(a_TableName : str, a_ParentIDFieldName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_PrevPrefix, a_NextPrefix, access_mode = user_access.AccessMode.VIEW): def SelectDBItemTemplate(a_TableName : str, a_ParentIDFieldName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, a_PrevPrefix, a_NextPrefix, access_mode = user_access.AccessMode.VIEW):
keyboard_func = GetBDItemsListKeyboardButtonsTemplate(a_TableName, a_ParentIDFieldName, a_PrevPrefix, a_NextPrefix, a_GetButtonNameAndKeyValueAndAccessFunc) keyboard_func = GetBDItemsListKeyboardButtonsTemplate(a_TableName, a_ParentIDFieldName, a_PrevPrefix, a_NextPrefix, a_GetButtonNameAndKeyValueAndAccessFunc)
return simple_message.InfoMessageTemplate(a_StartMessage, keyboard_func, a_AccessFunc, access_mode) return simple_message.InfoMessageTemplateLegacy(a_StartMessage, keyboard_func, a_AccessFunc, access_mode)
def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): def FirstSelectBDItemRegisterHandlers(dp, a_PrefixBase, a_ButtonName, a_TableName : str, a_KeyName, a_GetButtonNameAndKeyValueAndAccessFunc, a_StartMessage, a_AccessFunc, access_mode = user_access.AccessMode.VIEW):

6
template/simple_message.py

@ -18,13 +18,13 @@ class WorkFuncResult():
self.keyboard_func = keyboard_func self.keyboard_func = keyboard_func
def InfoMessageTemplate(a_HelpMessage, a_GetButtonsFunc, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): def InfoMessageTemplateLegacy(a_HelpMessage, a_GetButtonsFunc, a_AccessFunc, access_mode = user_access.AccessMode.VIEW):
async def GetMessage(a_Message : types.message, state = None): async def GetMessage(a_Message : types.message, state = None):
return WorkFuncResult(a_HelpMessage) return WorkFuncResult(a_HelpMessage)
return SimpleMessageTemplate(GetMessage, a_GetButtonsFunc, a_AccessFunc, access_mode) return SimpleMessageTemplateLegacy(GetMessage, a_GetButtonsFunc, a_AccessFunc, access_mode)
def SimpleMessageTemplate(a_WorkFunc, a_GetButtonsFunc, a_AccessFunc, access_mode = user_access.AccessMode.VIEW): def SimpleMessageTemplateLegacy(a_WorkFunc, a_GetButtonsFunc, a_AccessFunc, access_mode = user_access.AccessMode.VIEW):
async def SimpleMessage(a_Message : types.message, state = None): async def SimpleMessage(a_Message : types.message, state = None):
user_id = str(a_Message.from_user.id) user_id = str(a_Message.from_user.id)
user_groups = groups.GetUserGroupData(user_id) user_groups = groups.GetUserGroupData(user_id)

Loading…
Cancel
Save