mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 13:26:04 -06:00
f9d9d1225a
* refactor(sdk): add channel lifecycle patch factories * refactor(channels): adopt lifecycle patches in a-m * refactor(channels): adopt lifecycle patches in n-z * refactor(runtime): lifecycle-own ambient registries * test(slack): assert lifecycle factory fields * fix(sdk): preserve lifecycle patch extras types * test(zalouser): widen lifecycle status sink * test(irc): avoid shadowed status patch * fix(zalo): reuse account-agnostic media route * fix(gateway): accept explicit channel ready recovery * test(qa): assert terminal Slack block fact * test(qa): restore Slack blocked lifecycle scenario * test(gateway): lock explicit lifecycle recovery contract
56 lines
1.5 KiB
TypeScript
56 lines
1.5 KiB
TypeScript
// Telegram plugin module implements webhook status behavior.
|
|
import type { ChannelAccountSnapshot } from "openclaw/plugin-sdk/channel-contract";
|
|
import { channelReadyPatch } from "openclaw/plugin-sdk/gateway-runtime";
|
|
|
|
type TelegramWebhookStatusSink = (patch: Omit<ChannelAccountSnapshot, "accountId">) => void;
|
|
|
|
export function createTelegramWebhookStatusPublisher(setStatus?: TelegramWebhookStatusSink) {
|
|
return {
|
|
noteWebhookStart() {
|
|
setStatus?.({
|
|
mode: "webhook",
|
|
connected: false,
|
|
lastConnectedAt: null,
|
|
lastEventAt: null,
|
|
lastTransportActivityAt: null,
|
|
});
|
|
},
|
|
noteWebhookAdvertised(at = Date.now()) {
|
|
setStatus?.(
|
|
channelReadyPatch({
|
|
lastConnectedAt: at,
|
|
lastEventAt: at,
|
|
mode: "webhook",
|
|
}),
|
|
);
|
|
},
|
|
noteWebhookUpdateReceived(at = Date.now()) {
|
|
setStatus?.(
|
|
channelReadyPatch({
|
|
lastConnectedAt: at,
|
|
lastEventAt: at,
|
|
mode: "webhook",
|
|
}),
|
|
);
|
|
},
|
|
noteWebhookRecovery() {
|
|
setStatus?.({ lifecycle: "recovering" });
|
|
},
|
|
noteWebhookRegistrationFailure(error: string, lifecycle?: "recovering" | "blocked") {
|
|
setStatus?.({
|
|
mode: "webhook",
|
|
connected: false,
|
|
...(lifecycle ? { lifecycle } : {}),
|
|
...(lifecycle === "blocked" ? { terminalDisconnect: true } : {}),
|
|
lastError: error,
|
|
});
|
|
},
|
|
noteWebhookStop() {
|
|
setStatus?.({
|
|
mode: "webhook",
|
|
connected: false,
|
|
});
|
|
},
|
|
};
|
|
}
|