|
|
|
@ -35,6 +35,7 @@ def SubscribeMessage(a_EnumItem):
|
|
|
|
|
return 'subscribe ' + str(a_EnumItem) |
|
|
|
|
|
|
|
|
|
class ButtonNames(Enum): |
|
|
|
|
SHOW = auto() |
|
|
|
|
LIST = auto() |
|
|
|
|
ADD = auto() |
|
|
|
|
EDIT = auto() |
|
|
|
@ -153,6 +154,11 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
cur_buttons += [keyboard.ButtonWithAccess(self.GetButton(EditButton(f.m_Destiny)), access, self.GetAccess()),] |
|
|
|
|
return mod_buttons + keyboard.MakeButtons(self.m_Bot, cur_buttons, a_UserGroups) |
|
|
|
|
|
|
|
|
|
def GetShowItemInlineKeyboardTemplate(self, a_ItemID): |
|
|
|
|
def GetShowItemInlineKeyboard(a_Message, a_UserGroups): |
|
|
|
|
return self.GetShowItemInlineKeyboard(a_Message, a_UserGroups, a_ItemID) |
|
|
|
|
return GetShowItemInlineKeyboard |
|
|
|
|
|
|
|
|
|
def GetViewItemInlineKeyboardTemplate(self, a_ItemID): |
|
|
|
|
def GetViewItemInlineKeyboard(a_Message, a_UserGroups): |
|
|
|
|
return self.GetViewItemInlineKeyboard(a_Message, a_UserGroups, a_ItemID) |
|
|
|
@ -170,6 +176,12 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
def GetShowPrefix(self): |
|
|
|
|
return self.m_ShowPrefix |
|
|
|
|
|
|
|
|
|
def GetShowItemInlineKeyboard(self, a_Message, a_UserGroups, a_ItemID): |
|
|
|
|
cur_buttons = [ |
|
|
|
|
keyboard.InlineButtonWithAccess(self.GetButton(ButtonNames.SHOW), self.GetShowPrefix(), a_ItemID, self.GetAccess(), user_access.AccessMode.VIEW), |
|
|
|
|
] |
|
|
|
|
return keyboard.MakeInlineKeyboardButtons(self.m_Bot, cur_buttons, a_UserGroups) |
|
|
|
|
|
|
|
|
|
def GetViewItemInlineKeyboard(self, a_Message, a_UserGroups, a_ItemID): |
|
|
|
|
if not self.m_ChildModName: |
|
|
|
|
return None |
|
|
|
@ -385,18 +397,21 @@ class TableOperateModule(mod_simple_message.SimpleMessageModule):
|
|
|
|
|
cur_item = GetCurItem(self.m_Bot, table_name, key_name, a_TableItem) |
|
|
|
|
for s_user_id in self.m_BotSubscribes.GetUserIDs(self.GetName(), a_Type, a_ItemID = a_ItemID): |
|
|
|
|
a_BotMessage = self.GetMessage(SubscribeMessage(a_Type)) |
|
|
|
|
#print('s_user_id', s_user_id, a_BotMessage, a_OwnerUserID, a_TableItem, cur_item) |
|
|
|
|
if not a_BotMessage: |
|
|
|
|
continue |
|
|
|
|
if s_user_id == a_OwnerUserID: |
|
|
|
|
continue |
|
|
|
|
a_UserID = s_user_id |
|
|
|
|
a_BotMessage = a_BotMessage.StaticCopy() |
|
|
|
|
a_BotMessage.UpdateDesc(a_BotMessage.GetDesc().replace("#item_id", str(a_ItemID))) |
|
|
|
|
a_BotMessage.UpdateDesc(a_BotMessage.GetDesc().replace("#item_id", str(a_TableItem))) |
|
|
|
|
|
|
|
|
|
inline_keyboard_func = None |
|
|
|
|
if cur_item: |
|
|
|
|
a_BotMessage.UpdateDesc(self.m_Table.ReplaceAllFieldTags(a_BotMessage.GetDesc(), cur_item)) |
|
|
|
|
inline_keyboard_func = self.GetShowItemInlineKeyboardTemplate(a_TableItem) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await self.SendMessageToUser(a_BotMessage, a_UserID) |
|
|
|
|
await self.SendMessageToUser(a_BotMessage, a_UserID, a_GetInlineButtonsFunc = inline_keyboard_func) |
|
|
|
|
|
|
|
|
|
def SelectSourceTemplate(self, a_PrevPrefix, a_ButtonName): |
|
|
|
|
parent_id_field = self.m_Table.GetFieldNameByDestiny(bd_table.TableFieldDestiny.PARENT_ID) |
|
|
|
|