fix(feishu): use RawRequest for bot info API

This commit is contained in:
Xubin Ren 2026-04-06 11:39:23 +00:00
parent 79234d237e
commit b719da7400

View File

@ -408,12 +408,18 @@ class FeishuChannel(BaseChannel):
def _fetch_bot_open_id(self) -> str | None:
"""Fetch the bot's own open_id via GET /open-apis/bot/v3/info."""
from lark_oapi.api.bot.v3 import GetBotInfoRequest
try:
request = GetBotInfoRequest.builder().build()
response = self._client.bot.v3.bot_info.get(request)
if response.success() and response.data and response.data.bot:
return getattr(response.data.bot, "open_id", None)
import lark_oapi as lark
request = lark.RawRequest.builder() \
.http_method(lark.HttpMethod.GET) \
.uri("/open-apis/bot/v3/info") \
.build()
response = self._client.request(request)
if response.success():
import json
data = json.loads(response.raw.content)
bot = (data.get("data") or data).get("bot") or data.get("bot") or {}
return bot.get("open_id")
logger.warning("Failed to get bot info: code={}, msg={}", response.code, response.msg)
return None
except Exception as e: