mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-13 22:49:47 +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:
|
def _fetch_bot_open_id(self) -> str | None:
|
||||||
"""Fetch the bot's own open_id via GET /open-apis/bot/v3/info."""
|
"""Fetch the bot's own open_id via GET /open-apis/bot/v3/info."""
|
||||||
from lark_oapi.api.bot.v3 import GetBotInfoRequest
|
|
||||||
try:
|
try:
|
||||||
request = GetBotInfoRequest.builder().build()
|
import lark_oapi as lark
|
||||||
response = self._client.bot.v3.bot_info.get(request)
|
request = lark.RawRequest.builder() \
|
||||||
if response.success() and response.data and response.data.bot:
|
.http_method(lark.HttpMethod.GET) \
|
||||||
return getattr(response.data.bot, "open_id", None)
|
.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)
|
logger.warning("Failed to get bot info: code={}, msg={}", response.code, response.msg)
|
||||||
return None
|
return None
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user