diff --git a/src/plugin_system/apis/send_api.py b/src/plugin_system/apis/send_api.py index eae512dfb..feb18848b 100644 --- a/src/plugin_system/apis/send_api.py +++ b/src/plugin_system/apis/send_api.py @@ -56,12 +56,6 @@ async def file_to_stream( if not file_name: file_name = Path(file_path).name - # 临时的WSL路径转换方案 - if file_path.startswith("E:"): - original_path = file_path - file_path = "/mnt/e/" + file_path[3:].replace("\\", "/") - logger.info(f"WSL路径转换: {original_path} -> {file_path}") - params = { "file": file_path, "name": file_name, diff --git a/src/plugins/built_in/napcat_adapter_plugin/src/recv_handler/notice_handler.py b/src/plugins/built_in/napcat_adapter_plugin/src/recv_handler/notice_handler.py index 0f08b32f9..6bc473621 100644 --- a/src/plugins/built_in/napcat_adapter_plugin/src/recv_handler/notice_handler.py +++ b/src/plugins/built_in/napcat_adapter_plugin/src/recv_handler/notice_handler.py @@ -100,6 +100,7 @@ class NoticeHandler: # message_time: int = raw_message.get("time") message_time: float = time.time() # 应可乐要求,现在是float了 + self_id = raw_message.get("self_id") group_id = raw_message.get("group_id") user_id = raw_message.get("user_id") target_id = raw_message.get("target_id") @@ -161,9 +162,12 @@ class NoticeHandler: logger.warning(f"不支持的group_ban类型: {notice_type}.{sub_type}") case NoticeType.group_upload: logger.info("群文件上传") + if user_id == self_id: + logger.info("检测到机器人自己上传文件,忽略此通知") + return None if not await message_handler.check_allow_to_chat(user_id, group_id, False, False): return None - handled_message, user_info = await self.handle_group_upload_notify(raw_message, group_id, user_id) + handled_message, user_info = await self.handle_group_upload_notify(raw_message, group_id, user_id, self_id) case _: logger.warning(f"不支持的notice类型: {notice_type}") return None @@ -382,7 +386,7 @@ class NoticeHandler: seg_data = Seg(type="text",data=f"{user_name}使用Emoji表情{QQ_FACE.get(like_emoji_id,"")}回复了你的消息[{target_message_text}]") return seg_data, user_info - async def handle_group_upload_notify(self, raw_message: dict, group_id: int, user_id: int): + async def handle_group_upload_notify(self, raw_message: dict, group_id: int, user_id: int, self_id: int): if not group_id: logger.error("群ID不能为空,无法处理群文件上传通知") return None, None diff --git a/src/plugins/built_in/napcat_adapter_plugin/src/send_handler.py b/src/plugins/built_in/napcat_adapter_plugin/src/send_handler.py index 8426147d8..f586ae0da 100644 --- a/src/plugins/built_in/napcat_adapter_plugin/src/send_handler.py +++ b/src/plugins/built_in/napcat_adapter_plugin/src/send_handler.py @@ -274,6 +274,9 @@ class SendHandler: new_payload = self.build_payload(payload, self.handle_videourl_message(video_url), False) elif seg.type == "file": file_path = seg.data + file_path = seg.data + if isinstance(file_path, dict): + file_path = file_path.get("file", "") new_payload = self.build_payload(payload, self.handle_file_message(file_path), False) return new_payload @@ -411,11 +414,9 @@ class SendHandler: def handle_file_message(self, file_path: str) -> dict: """处理文件消息""" - # 临时的WSL路径转换方案 - if file_path.startswith("E:"): - original_path = file_path - file_path = "/mnt/e/" + file_path[3:].replace("\\", "/") - logger.info(f"WSL路径转换: {original_path} -> {file_path}") + if not file_path: + logger.error("文件路径为空") + return {} return { "type": "file",