mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
- Sync latest changes from clawdbot-feishu including multi-account support - Add eslint-disable comments for SDK-related any types - Remove unused imports - Fix no-floating-promises in monitor.ts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
1.2 KiB
TypeScript
45 lines
1.2 KiB
TypeScript
import type { FeishuProbeResult } from "./types.js";
|
|
import { createFeishuClient, type FeishuClientCredentials } from "./client.js";
|
|
|
|
export async function probeFeishu(creds?: FeishuClientCredentials): Promise<FeishuProbeResult> {
|
|
if (!creds?.appId || !creds?.appSecret) {
|
|
return {
|
|
ok: false,
|
|
error: "missing credentials (appId, appSecret)",
|
|
};
|
|
}
|
|
|
|
try {
|
|
const client = createFeishuClient(creds);
|
|
// Use bot/v3/info API to get bot information
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- SDK generic request method
|
|
const response = await (client as any).request({
|
|
method: "GET",
|
|
url: "/open-apis/bot/v3/info",
|
|
data: {},
|
|
});
|
|
|
|
if (response.code !== 0) {
|
|
return {
|
|
ok: false,
|
|
appId: creds.appId,
|
|
error: `API error: ${response.msg || `code ${response.code}`}`,
|
|
};
|
|
}
|
|
|
|
const bot = response.bot || response.data?.bot;
|
|
return {
|
|
ok: true,
|
|
appId: creds.appId,
|
|
botName: bot?.bot_name,
|
|
botOpenId: bot?.open_id,
|
|
};
|
|
} catch (err) {
|
|
return {
|
|
ok: false,
|
|
appId: creds.appId,
|
|
error: err instanceof Error ? err.message : String(err),
|
|
};
|
|
}
|
|
}
|