mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-08 12:13:36 +00:00
fix(feishu): use RawRequest for bot info API
This commit is contained in:
parent
79234d237e
commit
b719da7400
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user