mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:04:33 +00:00
Revert "Fix Telegram poll action wiring"
This reverts commit 556b531a14.
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
editMessageTelegram,
|
||||
reactMessageTelegram,
|
||||
sendMessageTelegram,
|
||||
sendPollTelegram,
|
||||
sendStickerTelegram,
|
||||
} from "../../telegram/send.js";
|
||||
import { getCacheStats, searchStickers } from "../../telegram/sticker-cache.js";
|
||||
@@ -212,66 +211,6 @@ export async function handleTelegramAction(
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "poll") {
|
||||
if (!isActionEnabled("polls")) {
|
||||
throw new Error("Telegram polls are disabled.");
|
||||
}
|
||||
const to = readStringParam(params, "to", { required: true });
|
||||
const question = readStringParam(params, "question", { required: true });
|
||||
const options = params.options ?? params.answers;
|
||||
if (!Array.isArray(options)) {
|
||||
throw new Error("options must be an array of strings");
|
||||
}
|
||||
const pollOptions = options.filter((option): option is string => typeof option === "string");
|
||||
if (pollOptions.length !== options.length) {
|
||||
throw new Error("options must be an array of strings");
|
||||
}
|
||||
const durationSeconds = readNumberParam(params, "durationSeconds", {
|
||||
integer: true,
|
||||
});
|
||||
const durationHours = readNumberParam(params, "durationHours", {
|
||||
integer: true,
|
||||
});
|
||||
const replyToMessageId = readNumberParam(params, "replyToMessageId", {
|
||||
integer: true,
|
||||
});
|
||||
const messageThreadId = readNumberParam(params, "messageThreadId", {
|
||||
integer: true,
|
||||
});
|
||||
const maxSelections =
|
||||
typeof params.allowMultiselect === "boolean" && params.allowMultiselect ? 2 : 1;
|
||||
const token = resolveTelegramToken(cfg, { accountId }).token;
|
||||
if (!token) {
|
||||
throw new Error(
|
||||
"Telegram bot token missing. Set TELEGRAM_BOT_TOKEN or channels.telegram.botToken.",
|
||||
);
|
||||
}
|
||||
const result = await sendPollTelegram(
|
||||
to,
|
||||
{
|
||||
question,
|
||||
options: pollOptions,
|
||||
maxSelections,
|
||||
durationSeconds: durationSeconds ?? undefined,
|
||||
durationHours: durationHours ?? undefined,
|
||||
},
|
||||
{
|
||||
token,
|
||||
accountId: accountId ?? undefined,
|
||||
replyToMessageId: replyToMessageId ?? undefined,
|
||||
messageThreadId: messageThreadId ?? undefined,
|
||||
silent: typeof params.silent === "boolean" ? params.silent : undefined,
|
||||
isAnonymous: typeof params.isAnonymous === "boolean" ? params.isAnonymous : undefined,
|
||||
},
|
||||
);
|
||||
return jsonResult({
|
||||
ok: true,
|
||||
messageId: result.messageId,
|
||||
chatId: result.chatId,
|
||||
pollId: result.pollId,
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "deleteMessage") {
|
||||
if (!isActionEnabled("deleteMessage")) {
|
||||
throw new Error("Telegram deleteMessage is disabled.");
|
||||
|
||||
Reference in New Issue
Block a user