Fix Telegram poll action wiring

This commit is contained in:
Krish
2026-02-16 19:54:49 +05:30
committed by Peter Steinberger
parent afd354c482
commit 556b531a14
5 changed files with 168 additions and 0 deletions

View File

@@ -58,6 +58,9 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
if (gate("deleteMessage")) {
actions.add("delete");
}
if (gate("polls")) {
actions.add("poll");
}
if (gate("editMessage")) {
actions.add("edit");
}
@@ -116,6 +119,40 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
);
}
if (action === "poll") {
const to = readStringParam(params, "to", { required: true });
const question = readStringParam(params, "pollQuestion", { required: true });
const options = readStringArrayParam(params, "pollOption", { required: true }) ?? [];
const allowMultiselect = typeof params.pollMulti === "boolean" ? params.pollMulti : undefined;
const durationSeconds = readNumberParam(params, "pollDurationSeconds", {
integer: true,
});
const durationHours = readNumberParam(params, "pollDurationHours", {
integer: true,
});
const replyToMessageId = readNumberParam(params, "replyTo", { integer: true });
const messageThreadId = readNumberParam(params, "threadId", { integer: true });
const silent = typeof params.silent === "boolean" ? params.silent : undefined;
const isAnonymous = typeof params.isAnonymous === "boolean" ? params.isAnonymous : undefined;
return await handleTelegramAction(
{
action: "poll",
to,
question,
options,
allowMultiselect,
durationSeconds: durationSeconds ?? undefined,
durationHours: durationHours ?? undefined,
replyToMessageId: replyToMessageId ?? undefined,
messageThreadId: messageThreadId ?? undefined,
silent,
isAnonymous,
accountId: accountId ?? undefined,
},
cfg,
);
}
if (action === "delete") {
const chatId =
readStringOrNumberParam(params, "chatId") ??