mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-19 00:52:10 -06:00
26cb29a171
* refactor(line): use shared DM policy factory * refactor(line): use shared channel probe runner * refactor(zalouser): use shared channel probe runner * refactor(tlon): use shared channel probe runner Honor the status adapter timeoutMs instead of discarding it. * refactor(line): use canonical inbound context builder * refactor(line): drop stale setup policy export * fix(tlon): honor adapter probe timeoutMs
36 lines
1.0 KiB
TypeScript
36 lines
1.0 KiB
TypeScript
// Line plugin module implements probe behavior.
|
|
import { messagingApi } from "@line/bot-sdk";
|
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
import { runChannelProbe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
import type { LineProbeResult } from "./types.js";
|
|
|
|
export async function probeLineBot(
|
|
channelAccessToken: string,
|
|
timeoutMs = 5000,
|
|
): Promise<LineProbeResult> {
|
|
if (!channelAccessToken?.trim()) {
|
|
return { ok: false, error: "Channel access token not configured" };
|
|
}
|
|
|
|
const client = new messagingApi.MessagingApiClient({
|
|
channelAccessToken: channelAccessToken.trim(),
|
|
});
|
|
|
|
return await runChannelProbe(
|
|
timeoutMs,
|
|
async () => {
|
|
const profile = await client.getBotInfo();
|
|
return {
|
|
ok: true,
|
|
bot: {
|
|
displayName: profile.displayName,
|
|
userId: profile.userId,
|
|
basicId: profile.basicId,
|
|
pictureUrl: profile.pictureUrl,
|
|
},
|
|
};
|
|
},
|
|
(error) => ({ ok: false, error: formatErrorMessage(error) }),
|
|
);
|
|
}
|