mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
fix(telegram): split monitor runtime types
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { RunOptions } from "@grammyjs/runner";
|
||||
import { CHANNEL_APPROVAL_NATIVE_RUNTIME_CONTEXT_CAPABILITY } from "openclaw/plugin-sdk/approval-handler-adapter-runtime";
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core";
|
||||
import { registerChannelRuntimeContext } from "openclaw/plugin-sdk/channel-runtime-context";
|
||||
import { resolveAgentMaxConcurrent } from "openclaw/plugin-sdk/config-runtime";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
@@ -13,28 +12,14 @@ import { resolveTelegramAccount } from "./accounts.js";
|
||||
import { resolveTelegramAllowedUpdates } from "./allowed-updates.js";
|
||||
import { isTelegramExecApprovalHandlerConfigured } from "./exec-approvals.js";
|
||||
import { resolveTelegramTransport } from "./fetch.js";
|
||||
import type { MonitorTelegramOpts } from "./monitor.types.js";
|
||||
import {
|
||||
isRecoverableTelegramNetworkError,
|
||||
isTelegramPollingNetworkError,
|
||||
} from "./network-errors.js";
|
||||
import { makeProxyFetch } from "./proxy.js";
|
||||
|
||||
export type MonitorTelegramOpts = {
|
||||
token?: string;
|
||||
accountId?: string;
|
||||
config?: OpenClawConfig;
|
||||
runtime?: RuntimeEnv;
|
||||
channelRuntime?: PluginRuntime["channel"];
|
||||
abortSignal?: AbortSignal;
|
||||
useWebhook?: boolean;
|
||||
webhookPath?: string;
|
||||
webhookPort?: number;
|
||||
webhookSecret?: string;
|
||||
webhookHost?: string;
|
||||
proxyFetch?: typeof fetch;
|
||||
webhookUrl?: string;
|
||||
webhookCertPath?: string;
|
||||
};
|
||||
export type { MonitorTelegramOpts } from "./monitor.types.js";
|
||||
|
||||
export function createTelegramRunnerOptions(cfg: OpenClawConfig): RunOptions<unknown> {
|
||||
return {
|
||||
|
||||
22
extensions/telegram/src/monitor.types.ts
Normal file
22
extensions/telegram/src/monitor.types.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core";
|
||||
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime";
|
||||
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
|
||||
|
||||
export type MonitorTelegramOpts = {
|
||||
token?: string;
|
||||
accountId?: string;
|
||||
config?: OpenClawConfig;
|
||||
runtime?: RuntimeEnv;
|
||||
channelRuntime?: PluginRuntime["channel"];
|
||||
abortSignal?: AbortSignal;
|
||||
useWebhook?: boolean;
|
||||
webhookPath?: string;
|
||||
webhookPort?: number;
|
||||
webhookSecret?: string;
|
||||
webhookHost?: string;
|
||||
proxyFetch?: typeof fetch;
|
||||
webhookUrl?: string;
|
||||
webhookCertPath?: string;
|
||||
};
|
||||
|
||||
export type TelegramMonitorFn = (opts?: MonitorTelegramOpts) => Promise<void>;
|
||||
@@ -1,12 +1,13 @@
|
||||
import type { ChannelMessageActionAdapter } from "openclaw/plugin-sdk/channel-contract";
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk/runtime-store";
|
||||
import type { PluginRuntime } from "openclaw/plugin-sdk/channel-core";
|
||||
import type { TelegramMonitorFn } from "./monitor.types.js";
|
||||
|
||||
export type TelegramProbeFn = typeof import("./probe.js").probeTelegram;
|
||||
export type TelegramAuditCollectFn = typeof import("./audit.js").collectTelegramUnmentionedGroupIds;
|
||||
export type TelegramAuditMembershipFn = typeof import("./audit.js").auditTelegramGroupMembership;
|
||||
export type TelegramMonitorFn = typeof import("./monitor.js").monitorTelegramProvider;
|
||||
export type TelegramSendFn = typeof import("./send.js").sendMessageTelegram;
|
||||
export type TelegramResolveTokenFn = typeof import("./token.js").resolveTelegramToken;
|
||||
type BasePluginRuntimeChannel = PluginRuntime extends { channel: infer T } ? T : never;
|
||||
|
||||
export type TelegramChannelRuntime = {
|
||||
probeTelegram?: TelegramProbeFn;
|
||||
@@ -18,8 +19,10 @@ export type TelegramChannelRuntime = {
|
||||
messageActions?: ChannelMessageActionAdapter;
|
||||
};
|
||||
|
||||
export type TelegramRuntime = PluginRuntime & {
|
||||
channel: PluginRuntime["channel"] & {
|
||||
telegram?: TelegramChannelRuntime;
|
||||
};
|
||||
};
|
||||
export interface TelegramRuntimeChannel extends BasePluginRuntimeChannel {
|
||||
telegram?: TelegramChannelRuntime;
|
||||
}
|
||||
|
||||
export interface TelegramRuntime extends PluginRuntime {
|
||||
channel: TelegramRuntimeChannel;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user