diff --git a/app/modules/wechatclawbot/wechatclawbot.py b/app/modules/wechatclawbot/wechatclawbot.py index 5022487d..50b6fc59 100644 --- a/app/modules/wechatclawbot/wechatclawbot.py +++ b/app/modules/wechatclawbot/wechatclawbot.py @@ -1426,7 +1426,10 @@ class ILinkClient: payload = self._json(resp) if self._ok(payload): return True, "连接正常" - return False, payload.get("errmsg") or payload.get("message") or "连接失败" + err_message = payload.get("errmsg") or payload.get("message") or "连接失败" + if "ilink_user_id required" in str(err_message).strip().lower(): + return True, "连接正常" + return False, err_message class WechatClawBot: diff --git a/tests/test_wechatclawbot.py b/tests/test_wechatclawbot.py index 416c75f5..49f7e6d8 100644 --- a/tests/test_wechatclawbot.py +++ b/tests/test_wechatclawbot.py @@ -205,6 +205,23 @@ class WechatClawBotTest(unittest.TestCase): self.assertNotIn("sync_buf", request_body) self.assertNotIn("syncBuf", request_body) + def test_ilink_test_connection_accepts_getconfig_ilink_user_id_limitation(self): + client = ILinkClient( + base_url="https://ilinkai.weixin.qq.com", + bot_token="token", + ) + response = MagicMock() + response.json.return_value = { + "ret": -1, + "errmsg": "ilink_user_id required", + } + + with patch("app.modules.wechatclawbot.wechatclawbot.RequestUtils.post", return_value=response): + ok, message = client.test_connection() + + self.assertTrue(ok) + self.assertIn("iLink 自检接口要求额外的 ilink_user_id", message) + def test_wechatclawbot_send_msg_uses_plain_text_payload(self): state = { "bot_token": None,