From c38c1c3c35ad30938c228e3bdfa158a2fbb81cc9 Mon Sep 17 00:00:00 2001 From: Raven95676 Date: Sun, 23 Feb 2025 18:05:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9Bfix:=20=E4=BF=AE=E5=A4=8Daiocqh?= =?UTF-8?q?ttp=5Fplatform=5Fadapter=E6=96=87=E4=BB=B6=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiocqhttp/aiocqhttp_platform_adapter.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py index 248b799e0..afaa87fa2 100644 --- a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +++ b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py @@ -148,8 +148,11 @@ class AiocqhttpAdapter(Platform): a = None if t == 'text': message_str += m['data']['text'].strip() + a = ComponentTypes[t](**m['data']) # noqa: F405 + abm.message.append(a) + elif t == 'file': - if m['data']['url'] and m['data']['url'].startswith("http"): + if m['data'].get('url') and m['data'].get('url').startswith("http"): # Lagrange logger.info("guessing lagrange") @@ -161,6 +164,8 @@ class AiocqhttpAdapter(Platform): "file": path, "name": file_name } + a = ComponentTypes[t](**m['data']) # noqa: F405 + abm.message.append(a) else: try: @@ -175,13 +180,17 @@ class AiocqhttpAdapter(Platform): "file": ret['file'], "name": ret['file_name'] } + a = ComponentTypes[t](**m['data']) # noqa: F405 + abm.message.append(a) except ActionFailed as e: logger.error(f"获取文件失败: {e},此消息段将被忽略。") except BaseException as e: logger.error(f"获取文件失败: {e},此消息段将被忽略。") - - a = ComponentTypes[t](**m['data']) # noqa: F405 - abm.message.append(a) + + else: + a = ComponentTypes[t](**m['data']) # noqa: F405 + abm.message.append(a) + abm.timestamp = int(time.time()) abm.message_str = message_str abm.raw_message = event From 786b0e4a540f712d5fc8579c6008b873c8881489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=A1=E9=B8=A695676?= Date: Sun, 23 Feb 2025 18:16:39 +0800 Subject: [PATCH 2/2] Update aiocqhttp_platform_adapter.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit else尾随空格 --- .../platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py index afaa87fa2..6ef1c3e56 100644 --- a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py +++ b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_platform_adapter.py @@ -187,7 +187,7 @@ class AiocqhttpAdapter(Platform): except BaseException as e: logger.error(f"获取文件失败: {e},此消息段将被忽略。") - else: + else: a = ComponentTypes[t](**m['data']) # noqa: F405 abm.message.append(a) @@ -263,4 +263,4 @@ class AiocqhttpAdapter(Platform): bot=self.bot ) - self.commit_event(message_event) \ No newline at end of file + self.commit_event(message_event)