From 4883e7c4f7e70ea5b4e7749bde272aa21b421981 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E5=85=8B=E7=8B=AE?= <42016325+A1KESH1@users.noreply.github.com> Date: Mon, 8 Apr 2024 02:49:43 +0800 Subject: [PATCH 1/4] Update requirements.txt --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index b602722..83724fc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,7 @@ jieba~=0.42.1 peewee~=3.14.10 pillow~=9.5.0 playwright~=1.31.1 -pydantic~=1.9.1 +pydantic~=1.10.0 pymysql~=1.0.2 pyyaml~=6.0 requests~=2.27.1 @@ -17,4 +17,4 @@ setuptools~=60.2.0 starlette~=0.19.1 uvicorn~=0.18.2 websockets~=10.1 -zhon~=1.1.5 \ No newline at end of file +zhon~=1.1.5 From c65d639950e3c89a52ead43d63ef923f701ab566 Mon Sep 17 00:00:00 2001 From: Vivien <34387011+vivien8261@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:18:31 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20keyboard?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amiyabot/adapters/tencent/qqGroup/builder.py | 18 ++++++++ amiyabot/builtin/messageChain/keyboard.py | 43 ++++++++++++++++---- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/amiyabot/adapters/tencent/qqGroup/builder.py b/amiyabot/adapters/tencent/qqGroup/builder.py index f6b5aee..77f90a6 100644 --- a/amiyabot/adapters/tencent/qqGroup/builder.py +++ b/amiyabot/adapters/tencent/qqGroup/builder.py @@ -213,6 +213,24 @@ async def insert_media(url: str, file_type: int = 1): if isinstance(item, Html): await insert_media(await item.create_html_image()) + # Ark + if isinstance(item, Ark): + payload.msg_type = 3 + payload.ark = item.get()['ark'] + + refresh_payload() + + # Markdown + if isinstance(item, Markdown): + md = item.get() + + payload.msg_type = 2 + payload.markdown = md['markdown'] + if 'keyboard' in md: + payload.keyboard = md['keyboard'] + + refresh_payload() + if payload.content: payload_list.append(payload) diff --git a/amiyabot/builtin/messageChain/keyboard.py b/amiyabot/builtin/messageChain/keyboard.py index d754f67..6683de0 100644 --- a/amiyabot/builtin/messageChain/keyboard.py +++ b/amiyabot/builtin/messageChain/keyboard.py @@ -4,7 +4,7 @@ @dataclass class Permission: - type: int = 1 + type: int = 2 specify_role_ids: List[str] = field(default_factory=lambda: ['1', '2', '3']) specify_user_ids: List[str] = field(default_factory=lambda: []) @@ -13,17 +13,20 @@ class Permission: class RenderData: label: str = '' visited_label: str = '' + style: int = 0 @dataclass class Action: - type: int = 1 + type: int = 2 data: str = '' + anchor: int = 0 unsupport_tips: str = '' + click_limit: int = 10 + reply: bool = False enter: bool = False - anchor: bool = False at_bot_show_channel_list: bool = False permission: Permission = field(default_factory=Permission) @@ -43,10 +46,20 @@ class Row: def add_button( self, button: Union[str, Button], - label: str, - visited_label: Optional[str] = None, - action_type: int = 1, + rander_label: str, + rander_visited_label: str = '', + rander_style: int = 0, + action_type: int = 2, action_data: str = '', + action_anchor: int = 0, + action_unsupport_tips: str = '', + action_click_limit: int = 10, + action_reply: bool = False, + action_enter: bool = False, + action_at_bot_show_channel_list: bool = False, + permission_type: int = 2, + permission_specify_role_ids: Optional[List[str]] = None, + permission_specify_user_ids: Optional[List[str]] = None, ): if len(self.buttons) >= 5: raise OverflowError('Create up to 5 buttons per row') @@ -54,10 +67,22 @@ def add_button( if isinstance(button, str): button = Button(button) - button.render_data.label = label - button.render_data.visited_label = visited_label or label + button.render_data.label = rander_label + button.render_data.visited_label = rander_visited_label or rander_label + button.render_data.style = rander_style + button.action.type = action_type - button.action.data = action_data or button.id + button.action.data = action_data or rander_label + button.action.anchor = action_anchor + button.action.unsupport_tips = action_unsupport_tips + button.action.click_limit = action_click_limit + button.action.reply = action_reply + button.action.enter = action_enter + button.action.at_bot_show_channel_list = action_at_bot_show_channel_list + + button.action.permission.type = permission_type + button.action.permission.specify_role_ids = permission_specify_role_ids + button.action.permission.specify_user_ids = permission_specify_user_ids self.buttons.append(button) From 0e0f22e9bc198224409b9931fa9b5e10cbb42321 Mon Sep 17 00:00:00 2001 From: Vivien <34387011+vivien8261@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:21:51 +0800 Subject: [PATCH 3/4] remove: pylint python3.9 --- .github/workflows/pylint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index b43f351..51165d6 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [ '3.8', '3.9' ] + python-version: [ '3.8' ] steps: - uses: actions/checkout@v3 - name: Set up Python ${{ matrix.python-version }} From 652181ecce11c35dcf17fe13016055eaed55544c Mon Sep 17 00:00:00 2001 From: Vivien <34387011+vivien8261@users.noreply.github.com> Date: Fri, 19 Apr 2024 12:31:41 +0800 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20=E7=A5=9E=E9=87=91=20pylint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- amiyabot/builtin/lib/imageCreator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/amiyabot/builtin/lib/imageCreator.py b/amiyabot/builtin/lib/imageCreator.py index 8a1782f..014bc7f 100644 --- a/amiyabot/builtin/lib/imageCreator.py +++ b/amiyabot/builtin/lib/imageCreator.py @@ -81,8 +81,7 @@ def __parse(self): length += self.__font_seat(char)[0] sub_text += char - if length > self.width_seat: - self.width_seat = length + self.width_seat = max(self.width_seat, length) is_end = idx == len(text) - 1 if length >= self.max_seat or char == '\n' or is_end: