


























@@ -2,7 +2,7 @@ import type { AgentToolResult } from "openclaw/plugin-sdk/agent-core";
22import { readBooleanParam } from "openclaw/plugin-sdk/boolean-param";
33import {
44jsonResult,
5-readNumberParam,
5+readPositiveIntegerParam,
66readReactionParams,
77readStringArrayParam,
88readStringOrNumberParam,
@@ -97,7 +97,9 @@ type TelegramForumTopicIconColor = (typeof TELEGRAM_FORUM_TOPIC_ICON_COLORS)[num
9797function readTelegramForumTopicIconColor(
9898params: Record<string, unknown>,
9999): TelegramForumTopicIconColor | undefined {
100-const iconColor = readNumberParam(params, "iconColor", { integer: true });
100+const iconColor = readPositiveIntegerParam(params, "iconColor", {
101+message: "iconColor must be one of Telegram's supported forum topic colors.",
102+});
101103if (iconColor == null) {
102104return undefined;
103105}
@@ -124,8 +126,12 @@ function readTelegramChatId(params: Record<string, unknown>) {
124126125127function readTelegramThreadId(params: Record<string, unknown>) {
126128return (
127-readNumberParam(params, "messageThreadId", { integer: true }) ??
128-readNumberParam(params, "threadId", { integer: true })
129+readPositiveIntegerParam(params, "messageThreadId", {
130+message: "messageThreadId must be a positive integer.",
131+}) ??
132+readPositiveIntegerParam(params, "threadId", {
133+message: "threadId must be a positive integer.",
134+})
129135);
130136}
131137@@ -147,8 +153,12 @@ function formatTelegramDeliveryTarget(to: string, messageThreadId?: number | nul
147153148154function readTelegramReplyToMessageId(params: Record<string, unknown>) {
149155return (
150-readNumberParam(params, "replyToMessageId", { integer: true }) ??
151-readNumberParam(params, "replyTo", { integer: true })
156+readPositiveIntegerParam(params, "replyToMessageId", {
157+message: "replyToMessageId must be a positive integer.",
158+}) ??
159+readPositiveIntegerParam(params, "replyTo", {
160+message: "replyTo must be a positive integer.",
161+})
152162);
153163}
154164@@ -353,9 +363,19 @@ export async function handleTelegramAction(
353363});
354364}
355365const chatId = readTelegramChatId(params);
356-const messageId =
357-readNumberParam(params, "messageId", { integer: true }) ??
358-resolveReactionMessageId({ args: params });
366+let explicitMessageId: number | undefined;
367+try {
368+explicitMessageId = readPositiveIntegerParam(params, "messageId", {
369+message: "messageId must be a positive integer.",
370+});
371+} catch {
372+return jsonResult({
373+ok: false,
374+reason: "missing_message_id",
375+hint: "Telegram reaction requires a valid messageId (or inbound context fallback). Do not retry.",
376+});
377+}
378+const messageId = explicitMessageId ?? resolveReactionMessageId({ args: params });
359379if (typeof messageId !== "number" || !Number.isFinite(messageId) || messageId <= 0) {
360380return jsonResult({
361381ok: false,
@@ -547,16 +567,18 @@ export async function handleTelegramAction(
547567const allowMultiselect =
548568readBooleanParam(params, "allowMultiselect") ?? readBooleanParam(params, "pollMulti");
549569const durationSeconds =
550-readNumberParam(params, "durationSeconds", { integer: true }) ??
551-readNumberParam(params, "pollDurationSeconds", {
552-integer: true,
553-strict: true,
570+readPositiveIntegerParam(params, "durationSeconds", {
571+message: "durationSeconds must be a positive integer.",
572+}) ??
573+readPositiveIntegerParam(params, "pollDurationSeconds", {
574+message: "pollDurationSeconds must be a positive integer.",
554575});
555576const durationHours =
556-readNumberParam(params, "durationHours", { integer: true }) ??
557-readNumberParam(params, "pollDurationHours", {
558-integer: true,
559-strict: true,
577+readPositiveIntegerParam(params, "durationHours", {
578+message: "durationHours must be a positive integer.",
579+}) ??
580+readPositiveIntegerParam(params, "pollDurationHours", {
581+message: "pollDurationHours must be a positive integer.",
560582});
561583const replyToMessageId = readTelegramReplyToMessageId(params);
562584const messageThreadId = readTelegramThreadId(params);
@@ -607,10 +629,12 @@ export async function handleTelegramAction(
607629throw new Error("Telegram deleteMessage is disabled.");
608630}
609631const chatId = readTelegramChatId(params);
610-const messageId = readNumberParam(params, "messageId", {
611-required: true,
612-integer: true,
632+const messageId = readPositiveIntegerParam(params, "messageId", {
633+message: "messageId must be a positive integer.",
613634});
635+if (messageId === undefined) {
636+throw new Error("messageId required");
637+}
614638const token = resolveTelegramToken(cfg, { accountId }).token;
615639if (!token) {
616640throw new Error(
@@ -634,10 +658,12 @@ export async function handleTelegramAction(
634658throw new Error("Telegram editMessage is disabled.");
635659}
636660const chatId = readTelegramChatId(params);
637-const messageId = readNumberParam(params, "messageId", {
638-required: true,
639-integer: true,
661+const messageId = readPositiveIntegerParam(params, "messageId", {
662+message: "messageId must be a positive integer.",
640663});
664+if (messageId === undefined) {
665+throw new Error("messageId required");
666+}
641667const content =
642668readStringParam(params, "content", { allowEmpty: false }) ??
643669readStringParam(params, "message", { required: true, allowEmpty: false });
@@ -722,7 +748,10 @@ export async function handleTelegramAction(
722748);
723749}
724750const query = readStringParam(params, "query", { required: true });
725-const limit = readNumberParam(params, "limit", { integer: true }) ?? 5;
751+const limit =
752+readPositiveIntegerParam(params, "limit", {
753+message: "limit must be a positive integer.",
754+}) ?? 5;
726755const results = telegramActionRuntime.searchStickers(query, limit);
727756return jsonResult({
728757ok: true,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。