Files
openclaw/extensions/line/src/probe.ts
Peter Steinberger 26cb29a171 refactor(channels): finish factory migrations for line/tlon/zalouser (#113646)
* 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
2026-07-25 05:46:32 -07:00

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) }),
);
}