

























@@ -109,11 +109,57 @@ function countTelegramExecApprovalEligibleAccounts(params: {
109109}).length;
110110}
111111112+function isExecApprovalRequest(
113+request: ExecApprovalRequest | PluginApprovalRequest,
114+): request is ExecApprovalRequest {
115+return "command" in request.request;
116+}
117+118+function isTargetForwardingMode(mode?: string): boolean {
119+return mode === "targets" || mode === "both";
120+}
121+122+function matchesExplicitTelegramForwardTargetAccount(params: {
123+cfg: OpenClawConfig;
124+accountId?: string | null;
125+request: ExecApprovalRequest | PluginApprovalRequest;
126+}): boolean | undefined {
127+const forwardingConfig = isExecApprovalRequest(params.request)
128+ ? params.cfg.approvals?.exec
129+ : params.cfg.approvals?.plugin;
130+if (!forwardingConfig?.enabled || !isTargetForwardingMode(forwardingConfig.mode)) {
131+return undefined;
132+}
133+const telegramTargets = (forwardingConfig.targets ?? []).filter(
134+(target) => normalizeLowercaseStringOrEmpty(target.channel) === "telegram",
135+);
136+if (telegramTargets.some((target) => !normalizeOptionalString(target.accountId))) {
137+return undefined;
138+}
139+const scopedTelegramAccountIds = telegramTargets
140+.map((target) => normalizeOptionalString(target.accountId))
141+.filter((accountId): accountId is string => Boolean(accountId));
142+if (scopedTelegramAccountIds.length === 0) {
143+return undefined;
144+}
145+const normalizedAccountId = params.accountId ? normalizeAccountId(params.accountId) : "";
146+return (
147+Boolean(normalizedAccountId) &&
148+scopedTelegramAccountIds.some(
149+(accountId) => normalizeAccountId(accountId) === normalizedAccountId,
150+)
151+);
152+}
153+112154function matchesTelegramRequestAccount(params: {
113155cfg: OpenClawConfig;
114156accountId?: string | null;
115157request: ExecApprovalRequest | PluginApprovalRequest;
116158}): boolean {
159+const explicitTargetMatch = matchesExplicitTelegramForwardTargetAccount(params);
160+if (explicitTargetMatch !== undefined) {
161+return explicitTargetMatch;
162+}
117163const turnSourceChannel = normalizeLowercaseStringOrEmpty(
118164params.request.request.turnSourceChannel,
119165);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。