diff --git a/amiyabot/adapters/tencent/qqGuild/builder.py b/amiyabot/adapters/tencent/qqGuild/builder.py index f5c0967..ef17e89 100644 --- a/amiyabot/adapters/tencent/qqGuild/builder.py +++ b/amiyabot/adapters/tencent/qqGuild/builder.py @@ -146,10 +146,6 @@ async def build_message_send(chain: Chain, custom_chain: Optional[CHAIN_LIST] = if isinstance(item, Markdown): messages.add_data(item.get()) - # Keyboard - if isinstance(item, Keyboard): - messages.add_data(item.get()) - messages.done() return messages diff --git a/amiyabot/builtin/messageChain/__init__.py b/amiyabot/builtin/messageChain/__init__.py index 815abe1..a8ae578 100644 --- a/amiyabot/builtin/messageChain/__init__.py +++ b/amiyabot/builtin/messageChain/__init__.py @@ -193,12 +193,14 @@ def markdown( render_time=render_time, ) - def markdown_template(self, template_id: str, params: List[dict]): - self.chain.append(Markdown(template_id, params)) - return self - - def keyboard(self, keyboard: Optional[InlineKeyboard] = None, template_id: Optional[str] = ''): - self.chain.append(Keyboard(template_id, keyboard)) + def markdown_template( + self, + template_id: str, + params: List[dict], + keyboard: Optional[InlineKeyboard] = None, + keyboard_template_id: Optional[str] = '', + ): + self.chain.append(Markdown(template_id, params, keyboard, keyboard_template_id)) return self def embed(self, title: str, prompt: str, thumbnail: str, fields: List[str]): diff --git a/amiyabot/builtin/messageChain/element.py b/amiyabot/builtin/messageChain/element.py index 0dc03bb..eae503e 100644 --- a/amiyabot/builtin/messageChain/element.py +++ b/amiyabot/builtin/messageChain/element.py @@ -190,34 +190,24 @@ def get(self): class Markdown: template_id: str params: List[dict] + keyboard: Optional[InlineKeyboard] = None + keyboard_template_id: Optional[str] = '' def get(self): - return { + data = { 'markdown': { 'custom_template_id': self.template_id, 'params': self.params, } } + if self.keyboard: + data.update({'keyboard': {'content': self.keyboard.dict()}}) -@dataclass -class Keyboard: - template_id: Optional[str] = '' - keyboard: Optional[InlineKeyboard] = None + if self.keyboard_template_id: + data.update({'keyboard': {'id': self.keyboard_template_id}}) - def get(self): - if self.keyboard: - return { - 'keyboard': { - 'content': self.keyboard.dict(), - } - } - else: - return { - 'keyboard': { - 'id': self.template_id, - } - } + return data @dataclass @@ -243,7 +233,6 @@ def get(self): Embed, Ark, Markdown, - Keyboard, Extend, ] CHAIN_LIST = List[CHAIN_ITEM]