diff --git a/pkg/platform/manager.py b/pkg/platform/manager.py index aa0303b9..acdf0990 100644 --- a/pkg/platform/manager.py +++ b/pkg/platform/manager.py @@ -170,7 +170,8 @@ class PlatformManager: self.ap.logger.debug(f"Traceback: {traceback.format_exc()}") tasks.append(exception_wrapper(adapter)) - + + for task in tasks: self.ap.task_mgr.create_task( task, diff --git a/pkg/platform/sources/gewechat.py b/pkg/platform/sources/gewechat.py index 05785093..5227a52d 100644 --- a/pkg/platform/sources/gewechat.py +++ b/pkg/platform/sources/gewechat.py @@ -82,7 +82,7 @@ class GewechatMessageConverter(adapter.MessageConverter): content_list.append(platform_message.At(target=bot_account_id)) content_list.append(platform_message.Plain(message["Data"]["Content"]["string"].replace(at_string, '', 1))) # 更优雅的替换改名后@机器人,仅仅限于单独AT的情况 - elif '在群聊中@了你' in message["Data"]["PushContent"]: + elif "PushContent" in message['Data'] and '在群聊中@了你' in message["Data"]["PushContent"]: content_list.append(platform_message.At(target=bot_account_id)) content_list.append(platform_message.Plain(re.sub(pattern, '', message["Data"]["Content"]["string"]))) else: @@ -161,6 +161,10 @@ class GewechatEventConverter(adapter.EventConverter): event: dict, bot_account_id: str ) -> platform_events.MessageEvent: + + if event['Wxid'] == event['Data']['FromUserName']['string']: + return None + message_chain = await self.message_converter.target2yiri(copy.deepcopy(event), bot_account_id) if not message_chain: diff --git a/pkg/utils/image.py b/pkg/utils/image.py index 16077ace..760c2128 100644 --- a/pkg/utils/image.py +++ b/pkg/utils/image.py @@ -15,6 +15,9 @@ import asyncio from urllib.parse import urlparse + + + async def get_gewechat_image_base64( gewechat_url: str, gewechat_file_url: str, @@ -67,6 +70,7 @@ async def get_gewechat_image_base64( } ) as response: if response.status != 200: + # print(response) raise Exception(f"获取gewechat图片下载失败: {await response.text()}") resp_data = await response.json() @@ -108,6 +112,9 @@ async def get_gewechat_image_base64( raise Exception(f"获取图片失败: {str(e)}") from e + + + async def get_wecom_image_base64(pic_url: str) -> tuple[str, str]: """ 下载企业微信图片并转换为 base64