From 1674653a42f9c56ef58d404bcd3aa5b19feee6d4 Mon Sep 17 00:00:00 2001 From: Zhenyi Wang Date: Sun, 6 Jul 2025 16:18:31 +0800 Subject: [PATCH] =?UTF-8?q?fix(wechatpadpro):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=8E=88=E6=9D=83=E7=A0=81=E6=8F=90=E5=8F=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BB=A5=E5=85=BC=E5=AE=B9=E6=96=B0=E6=97=A7=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新接口返回多了一层authKeys字段,同时兼容二者 --- .../wechatpadpro/wechatpadpro_adapter.py | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py index 58e3c9b19..786c769bf 100644 --- a/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py +++ b/astrbot/core/platform/sources/wechatpadpro/wechatpadpro_adapter.py @@ -225,21 +225,23 @@ class WeChatPadProAdapter(Platform): # 修正成功判断条件和授权码提取路径 if response.status == 200 and response_data.get("Code") == 200: # 授权码在 Data 字段的列表中 - if ( - response_data.get("Data") - and isinstance(response_data["Data"], list) - and len(response_data["Data"]) > 0 - ): - self.auth_key = response_data["Data"][0] - logger.info(f"成功获取授权码 {self.auth_key[:8]}...") + data = response_data.get("Data") + if data: + # 新返回格式 + if isinstance(data.get("authKeys"), list) and data["authKeys"]: + self.auth_key = data["authKeys"][0] + # 兼容旧版接口 + elif isinstance(data, list) and data: + self.auth_key = data[0] + + if self.auth_key: + logger.info(f"成功获取授权码 {self.auth_key[:8]}...") + else: + logger.error(f"生成授权码成功但未找到授权码: {response_data}") else: - logger.error( - f"生成授权码成功但未找到授权码: {response_data}" - ) + logger.error(f"生成授权码成功但未找到授权码: {response_data}") else: - logger.error( - f"生成授权码失败: {response.status}, {response_data}" - ) + logger.error(f"生成授权码失败: {response.status}, {response_data}") except aiohttp.ClientConnectorError as e: logger.error(f"连接到 WeChatPadPro 服务失败: {e}") except Exception as e: