From ba1b68df20e0ebb88253f8eeb96f5a8da441d8c7 Mon Sep 17 00:00:00 2001 From: Zhalslar Date: Sat, 14 Jun 2025 21:23:45 +0800 Subject: [PATCH 01/13] Update dingtalk_event.py --- .../sources/dingtalk/dingtalk_event.py | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py index 4834032f5..f9292ede9 100644 --- a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py +++ b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py @@ -31,21 +31,23 @@ class DingtalkMessageEvent(AstrMessageEvent): self.message_obj.raw_message, ) elif isinstance(segment, Comp.Image): + file = segment.file markdown_str = "" - if segment.file and segment.file.startswith("file:///"): - logger.warning( - "dingtalk only support url image, not: " + segment.file - ) - continue - elif segment.file and segment.file.startswith("http"): - markdown_str += f"![image]({segment.file})\n\n" - elif segment.file and segment.file.startswith("base64://"): - logger.warning("dingtalk only support url image, not base64") - continue - else: - logger.warning( - "dingtalk only support url image, not: " + segment.file - ) + + try: + if not file: + logger.warning("钉钉图片 segment 缺少 file 字段,跳过") + continue + + if file.startswith("http"): + markdown_str += f"![image]({file})\n\n" + else: + url = await segment.register_to_file_service() + markdown_str += f"![image]({url})\n\n" + + except Exception as e: + logger.error(f"钉钉图片处理失败: {e}") + logger.warning(f"跳过图片发送: {file}") continue ret = await asyncio.get_event_loop().run_in_executor( From 2059ddcadfa47eccda759822e8f8001ebed7a584 Mon Sep 17 00:00:00 2001 From: Zhalslar Date: Sat, 14 Jun 2025 21:39:33 +0800 Subject: [PATCH 02/13] Update dingtalk_event.py --- .../core/platform/sources/dingtalk/dingtalk_event.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py index f9292ede9..37b12ba4f 100644 --- a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py +++ b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py @@ -31,23 +31,23 @@ class DingtalkMessageEvent(AstrMessageEvent): self.message_obj.raw_message, ) elif isinstance(segment, Comp.Image): - file = segment.file + file_ = segment.file markdown_str = "" try: - if not file: + if not file_: logger.warning("钉钉图片 segment 缺少 file 字段,跳过") continue - if file.startswith("http"): - markdown_str += f"![image]({file})\n\n" + if file_.startswith("http://", "https://"): + markdown_str += f"![image]({file_})\n\n" else: url = await segment.register_to_file_service() markdown_str += f"![image]({url})\n\n" except Exception as e: logger.error(f"钉钉图片处理失败: {e}") - logger.warning(f"跳过图片发送: {file}") + logger.warning(f"跳过图片发送: {file_}") continue ret = await asyncio.get_event_loop().run_in_executor( From c7891385ca4f238df4bdc8833bb7055c31c5c577 Mon Sep 17 00:00:00 2001 From: Zhalslar Date: Sat, 14 Jun 2025 21:44:37 +0800 Subject: [PATCH 03/13] Update dingtalk_event.py --- .../sources/dingtalk/dingtalk_event.py | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py index 37b12ba4f..c2188dc36 100644 --- a/astrbot/core/platform/sources/dingtalk/dingtalk_event.py +++ b/astrbot/core/platform/sources/dingtalk/dingtalk_event.py @@ -31,34 +31,32 @@ class DingtalkMessageEvent(AstrMessageEvent): self.message_obj.raw_message, ) elif isinstance(segment, Comp.Image): - file_ = segment.file markdown_str = "" try: - if not file_: + if not segment.file: logger.warning("钉钉图片 segment 缺少 file 字段,跳过") continue - - if file_.startswith("http://", "https://"): - markdown_str += f"![image]({file_})\n\n" + if segment.file.startswith(("http://", "https://")): + image_url = segment.file else: - url = await segment.register_to_file_service() - markdown_str += f"![image]({url})\n\n" + image_url = await segment.register_to_file_service() + + markdown_str = f"![image]({image_url})\n\n" + + ret = await asyncio.get_event_loop().run_in_executor( + None, + client.reply_markdown, + "😄", + markdown_str, + self.message_obj.raw_message, + ) + logger.debug(f"send image: {ret}") except Exception as e: logger.error(f"钉钉图片处理失败: {e}") - logger.warning(f"跳过图片发送: {file_}") + logger.warning(f"跳过图片发送: {image_path}") continue - - ret = await asyncio.get_event_loop().run_in_executor( - None, - client.reply_markdown, - "😄", - markdown_str, - self.message_obj.raw_message, - ) - logger.debug(f"send image: {ret}") - async def send(self, message: MessageChain): await self.send_with_client(self.client, message) await super().send(message) From 1b1f5f5a5e62ba0561a95d68d31b6f07037c8c38 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:06:46 +0800 Subject: [PATCH 04/13] docs(README.md): update logo --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 07237bfa4..e678a54e5 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@

- -![da32a1f2-8da6-46a6-8516-5ed57d50e4b9](https://github.com/user-attachments/assets/39dc39ae-9003-434b-81a6-006b3de5e7c2) +![AstrBot-Logo-Simplified](https://github.com/user-attachments/assets/ffd99b6b-3272-4682-beaa-6fe74250f7d9)

From b93f30b809d0404ad40a67c8d611e7ea11a1fcce Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Sat, 14 Jun 2025 02:09:06 +0800 Subject: [PATCH 05/13] docs: update readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 08252881b..07237bfa4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@

+ +![da32a1f2-8da6-46a6-8516-5ed57d50e4b9](https://github.com/user-attachments/assets/39dc39ae-9003-434b-81a6-006b3de5e7c2) -![yjtp](https://github.com/user-attachments/assets/dcc74009-c57e-4b66-9ae3-0a81fc001255)

From f93f04a5362ab51367180c19c05016c2844122bb Mon Sep 17 00:00:00 2001 From: Zhalslar Date: Sat, 14 Jun 2025 15:01:18 +0800 Subject: [PATCH 06/13] =?UTF-8?q?feat:=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=BC=95=E7=94=A8bot=E6=B6=88=E6=81=AF=E6=9D=A5=E5=94=A4?= =?UTF-8?q?=E9=86=92bot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update dingtalk_event.py Update stage.py --- astrbot/core/pipeline/waking_check/stage.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/astrbot/core/pipeline/waking_check/stage.py b/astrbot/core/pipeline/waking_check/stage.py index 6fb3378ca..5c5163938 100644 --- a/astrbot/core/pipeline/waking_check/stage.py +++ b/astrbot/core/pipeline/waking_check/stage.py @@ -4,7 +4,7 @@ from astrbot import logger from typing import Union, AsyncGenerator from astrbot.core.platform.astr_message_event import AstrMessageEvent from astrbot.core.message.message_event_result import MessageEventResult, MessageChain -from astrbot.core.message.components import At, AtAll +from astrbot.core.message.components import At, AtAll, Reply from astrbot.core.star.star_handler import star_handlers_registry, EventType from astrbot.core.star.star import star_map from astrbot.core.star.filter.permission import PermissionTypeFilter @@ -80,11 +80,19 @@ class WakingCheckStage(Stage): event.message_str = event.message_str[len(wake_prefix) :].strip() break if not is_wake: - # 检查是否有 at 消息 + # 检查是否有at消息 / at全体成员消息 / 引用了bot的消息 for message in messages: - if (isinstance(message, At) and ( - str(message.qq) == str(event.get_self_id()) - )) or (isinstance(message, AtAll) and not self.ignore_at_all): + if ( + ( + isinstance(message, At) + and (str(message.qq) == str(event.get_self_id())) + ) + or (isinstance(message, AtAll) and not self.ignore_at_all) + or ( + isinstance(message, Reply) + and str(message.sender_id) == str(event.get_self_id()) + ) + ): is_wake = True event.is_wake = True wake_prefix = "" From 74ded9197632b32fa47c5d84405c151717d0f14b Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:07:05 +0800 Subject: [PATCH 07/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20WeChatPadPro?= =?UTF-8?q?=20=E8=BF=87=E6=9C=9F=E5=90=8E=E6=97=A0=E6=B3=95=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E7=9A=84=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wechatpadpro/wechatpadpro_adapter.py | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index 3cddeccce..cc8d8709c 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -158,7 +158,6 @@ class WeChatPadProAdapter(Platform): os.makedirs(data_dir, exist_ok=True) with open(self.credentials_file, "w") as f: json.dump(credentials, f) - logger.info("成功保存 WeChatPadPro 凭据。") except Exception as e: logger.error(f"保存 WeChatPadPro 凭据失败: {e}") @@ -190,6 +189,10 @@ class WeChatPadProAdapter(Platform): elif response.status == 200 and response_data.get("Code") == 300: logger.info("WeChatPadPro 设备已退出。") return False + elif response.status == 200 and response_data.get("Code") == -2: + # 该链接不存在 + self.auth_key = None + return False else: logger.error( f"检查在线状态失败: {response.status}, {response_data}" @@ -224,7 +227,7 @@ class WeChatPadProAdapter(Platform): and len(response_data["Data"]) > 0 ): self.auth_key = response_data["Data"][0] - logger.info("成功获取授权码") + logger.info(f"成功获取授权码 {self.auth_key[:8]}...") else: logger.error( f"生成授权码成功但未找到授权码: {response_data}" @@ -250,7 +253,6 @@ class WeChatPadProAdapter(Platform): try: async with session.post(url, params=params, json=payload) as response: response_data = await response.json() - # 修正成功判断条件和数据提取路径 if response.status == 200 and response_data.get("Code") == 200: # 二维码地址在 Data.QrCodeUrl 字段中 if response_data.get("Data") and response_data["Data"].get( @@ -262,6 +264,13 @@ class WeChatPadProAdapter(Platform): f"获取登录二维码成功但未找到二维码地址: {response_data}" ) return None + elif "该 key 无效" in response_data.get("Text"): + logger.error( + "授权码无效,已经清除。请重新启动 AstrBot 或者本消息适配器。原因也可能是 WeChatPadPro 的 MySQL 服务没有启动成功,请检查 WeChatPadPro 服务的日志。" + ) + self.auth_key = None + self.save_credentials() + return None else: logger.error( f"获取登录二维码失败: {response.status}, {response_data}" @@ -631,7 +640,11 @@ class WeChatPadProAdapter(Platform): # wechatpadpro 的格式: wxid # gewechat 的格式: msg_source = raw_message.get("msg_source", "") - if f"{abm.self_id}" in msg_source or f"{abm.self_id}," in msg_source or f",{abm.self_id}" in msg_source: + if ( + f"{abm.self_id}" in msg_source + or f"{abm.self_id}," in msg_source + or f",{abm.self_id}" in msg_source + ): at_me = True # 也检查 push_content 中是否有@提示 @@ -641,19 +654,28 @@ class WeChatPadProAdapter(Platform): if at_me: # 被@了,在消息开头插入At组件(参考gewechat的做法) - bot_nickname = await self._get_group_member_nickname(abm.group_id, abm.self_id) - abm.message.insert(0, At(qq=abm.self_id, name=bot_nickname or abm.self_id)) + bot_nickname = await self._get_group_member_nickname( + abm.group_id, abm.self_id + ) + abm.message.insert( + 0, At(qq=abm.self_id, name=bot_nickname or abm.self_id) + ) # 只有当消息内容不仅仅是@时才添加Plain组件 if "\u2005" in message_content: # 检查@之后是否还有其他内容 parts = message_content.split("\u2005") - if len(parts) > 1 and any(part.strip() for part in parts[1:]): + if len(parts) > 1 and any( + part.strip() for part in parts[1:] + ): abm.message.append(Plain(message_content)) else: # 检查是否只包含@机器人 is_pure_at = False - if bot_nickname and message_content.strip() == f"@{bot_nickname}": + if ( + bot_nickname + and message_content.strip() == f"@{bot_nickname}" + ): is_pure_at = True if not is_pure_at: abm.message.append(Plain(message_content)) From 8d21126bd63f90aeecaf36ab9fe91d1eb9ceb8c9 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:18:45 +0800 Subject: [PATCH 08/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20WeChatPadPro?= =?UTF-8?q?=20=E4=BC=9A=E8=AF=9D=E9=9A=94=E7=A6=BB=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E4=B8=8B=EF=BC=8C=E4=BC=9A=E8=AF=9D=20ID=20=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=B8=BA=E8=87=AA=E8=BA=ABID=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/platform/sources/wechatpadpro/wechatpadpro_adapter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index cc8d8709c..ce47a6743 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -501,7 +501,7 @@ class WeChatPadProAdapter(Platform): # 对于群聊,session_id 可以是群聊 ID 或发送者 ID + 群聊 ID (如果 unique_session 为 True) if self.unique_session: - abm.session_id = f"{from_user_name}_{to_user_name}" + abm.session_id = f"{from_user_name}_{abm.sender.user_id}" else: abm.session_id = from_user_name From 86ba3c230e55c645befe4c25d90f049e85a75aac Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:21:53 +0800 Subject: [PATCH 09/13] =?UTF-8?q?perf:=20=E5=BC=B1=E5=8C=96=20WeChatPadPro?= =?UTF-8?q?=20=E7=9A=84=20WS=20=E8=BF=9E=E6=8E=A5=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes: #1779 --- .../platform/sources/wechatpadpro/wechatpadpro_adapter.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index ce47a6743..5519c9d21 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -363,7 +363,7 @@ class WeChatPadProAdapter(Platform): while True: try: async with websockets.connect(ws_url) as websocket: - logger.info("WebSocket 连接成功。") + logger.debug("WebSocket 连接成功。") # 设置空闲超时重连 wait_time = ( self.active_message_poll_interval @@ -378,7 +378,7 @@ class WeChatPadProAdapter(Platform): # logger.debug(message) # 不显示原始消息内容 asyncio.create_task(self.handle_websocket_message(message)) except asyncio.TimeoutError: - logger.warning(f"WebSocket 连接空闲超过 {wait_time} s") + logger.debug(f"WebSocket 连接空闲超过 {wait_time} s") break except websockets.exceptions.ConnectionClosedOK: logger.info("WebSocket 连接正常关闭。") From 53a3736b043ebd2ff51f6dd82b70bbba9627eeb7 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:26:22 +0800 Subject: [PATCH 10/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=8F=AF?= =?UTF-8?q?=E8=83=BD=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes: #1778 --- .../platform/sources/wechatpadpro/wechatpadpro_adapter.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index 5519c9d21..eabca36d8 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -165,6 +165,8 @@ class WeChatPadProAdapter(Platform): """ 检查 WeChatPadPro 设备是否在线。 """ + if not self.auth_key: + return False url = f"{self.base_url}/login/GetLoginStatus" params = {"key": self.auth_key} @@ -183,7 +185,7 @@ class WeChatPadProAdapter(Platform): logger.info("WeChatPadPro 设备不在线。") return False else: - logger.error(f"未知的在线状态: {login_state:}") + logger.error(f"未知的在线状态: {response_data}") return False # Code == 300 为微信退出状态。 elif response.status == 200 and response_data.get("Code") == 300: From 85aa28d724ee9f30a682350c69d68fcef61e082c Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:27:29 +0800 Subject: [PATCH 11/13] perf: print traceback --- .../core/platform/sources/wechatpadpro/wechatpadpro_adapter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index eabca36d8..7746ba889 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -2,6 +2,7 @@ import asyncio import base64 import json import os +import traceback import time from typing import Optional @@ -206,6 +207,7 @@ class WeChatPadProAdapter(Platform): return False except Exception as e: logger.error(f"检查在线状态时发生错误: {e}") + logger.error(traceback.format_exc()) return False async def generate_auth_key(self): From 2c47abea95b2166754fdbab38209ebb70ec7404c Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 16 Jun 2025 23:36:11 +0800 Subject: [PATCH 12/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20WeChatPadPro?= =?UTF-8?q?=20=E4=B8=8B=EF=BC=8C=E5=BC=80=E5=90=AF=E4=BA=86=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E9=9A=94=E7=A6=BB=E5=90=8E=EF=BC=8C=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=BE=A4=E8=81=8A=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes: #1766 --- .../platform/sources/wechatpadpro/wechatpadpro_adapter.py | 7 +++++-- .../sources/wechatpadpro/wechatpadpro_message_event.py | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index 7746ba889..58e3c9b19 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -505,7 +505,7 @@ class WeChatPadProAdapter(Platform): # 对于群聊,session_id 可以是群聊 ID 或发送者 ID + 群聊 ID (如果 unique_session 为 True) if self.unique_session: - abm.session_id = f"{from_user_name}_{abm.sender.user_id}" + abm.session_id = f"{from_user_name}#{abm.sender.user_id}" else: abm.session_id = from_user_name @@ -832,7 +832,10 @@ class WeChatPadProAdapter(Platform): # 根据 session_id 判断消息类型 if "@chatroom" in session.session_id: dummy_message_obj.type = MessageType.GROUP_MESSAGE - dummy_message_obj.group_id = session.session_id + if "#" in session.session_id: + dummy_message_obj.group_id = session.session_id.split("#")[0] + else: + dummy_message_obj.group_id = session.session_id dummy_message_obj.sender = MessageMember(user_id="", nickname="") else: dummy_message_obj.type = MessageType.FRIEND_MESSAGE diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py index ab836ad28..3bb753dd4 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_message_event.py @@ -81,12 +81,16 @@ class WeChatPadProMessageEvent(AstrMessageEvent): # logger.info(f"已添加 @ 信息: {message_text}") else: message_text = text + if self.get_group_id() and "#" in self.session_id: + session_id = self.session_id.split("#")[0] + else: + session_id = self.session_id payload = { "MsgItem": [ { "MsgType": 1, "TextContent": message_text, - "ToUserName": self.session_id, + "ToUserName": session_id, } ] } From 345afe1338f10e2df79ca1adeaf73ce684e702ac Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Thu, 19 Jun 2025 00:38:23 +0800 Subject: [PATCH 13/13] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20PipInstaller?= =?UTF-8?q?=20=E4=B8=AD=20pip=20=E8=B0=83=E7=94=A8=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E4=BD=BF=E7=94=A8=E5=BD=93=E5=89=8D?= =?UTF-8?q?=20Python=20=E8=A7=A3=E9=87=8A=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- astrbot/core/utils/pip_installer.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/astrbot/core/utils/pip_installer.py b/astrbot/core/utils/pip_installer.py index a7c04d3d9..88cc21306 100644 --- a/astrbot/core/utils/pip_installer.py +++ b/astrbot/core/utils/pip_installer.py @@ -1,5 +1,6 @@ import logging import asyncio +import sys logger = logging.getLogger("astrbot") @@ -31,7 +32,10 @@ class PipInstaller: logger.info(f"Pip 包管理器: pip {' '.join(args)}") try: process = await asyncio.create_subprocess_exec( - "pip", *args, + sys.executable, + "-m", + "pip", + *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT, ) @@ -47,6 +51,7 @@ class PipInstaller: except FileNotFoundError: # 没有 pip from pip import main as pip_main + result_code = await asyncio.to_thread(pip_main, args) # 清除 pip.main 导致的多余的 logging handlers