From 95708489c979d3d891e01ca684939a4d8e623ee3 Mon Sep 17 00:00:00 2001 From: zhayujie Date: Wed, 31 Jan 2024 16:24:29 +0800 Subject: [PATCH] fix: wxcomapp user name --- bot/linkai/link_ai_bot.py | 6 +++++- channel/wechat/wechat_channel.py | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bot/linkai/link_ai_bot.py b/bot/linkai/link_ai_bot.py index efd571a..a0b92c1 100644 --- a/bot/linkai/link_ai_bot.py +++ b/bot/linkai/link_ai_bot.py @@ -107,7 +107,11 @@ class LinkAIBot(Bot): body["group_name"] = context.kwargs.get("msg").from_user_nickname body["sender_name"] = context.kwargs.get("msg").actual_user_nickname else: - body["sender_name"] = context.kwargs.get("msg").from_user_nickname + if body.get("channel_type") in ["wechatcom_app"]: + body["sender_name"] = context.kwargs.get("msg").from_user_id + else: + body["sender_name"] = context.kwargs.get("msg").from_user_nickname + except Exception as e: pass file_id = context.kwargs.get("file_id") diff --git a/channel/wechat/wechat_channel.py b/channel/wechat/wechat_channel.py index bb59c8f..fe14daa 100644 --- a/channel/wechat/wechat_channel.py +++ b/channel/wechat/wechat_channel.py @@ -251,20 +251,25 @@ class WechatChannel(ChatChannel): def _send_login_success(): try: from common.linkai_client import chat_client - chat_client.send_login_success() + if chat_client.client_id: + chat_client.send_login_success() except Exception as e: pass def _send_logout(): try: from common.linkai_client import chat_client - chat_client.send_logout() + time.sleep(2) + if chat_client.client_id: + chat_client.send_logout() except Exception as e: pass def _send_qr_code(qrcode_list: list): try: from common.linkai_client import chat_client - chat_client.send_qrcode(qrcode_list) + time.sleep(2) + if chat_client.client_id: + chat_client.send_qrcode(qrcode_list) except Exception as e: pass