feat(telegram): add sendPoll support (#16193) (#16209)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: b58492cfed
Co-authored-by: robbyczgw-cla <239660374+robbyczgw-cla@users.noreply.github.com>
Co-authored-by: steipete <58493+steipete@users.noreply.github.com>
Reviewed-by: @steipete
This commit is contained in:
Robby
2026-02-14 18:34:30 +01:00
committed by GitHub
parent fc5d147d1b
commit 8e5689a84d
21 changed files with 364 additions and 11 deletions

View File

@@ -35,7 +35,15 @@ export const PollParamsSchema = Type.Object(
question: NonEmptyString,
options: Type.Array(NonEmptyString, { minItems: 2, maxItems: 12 }),
maxSelections: Type.Optional(Type.Integer({ minimum: 1, maximum: 12 })),
/** Poll duration in seconds (channel-specific limits may apply). */
durationSeconds: Type.Optional(Type.Integer({ minimum: 1, maximum: 600 })),
durationHours: Type.Optional(Type.Integer({ minimum: 1 })),
/** Send silently (no notification) where supported. */
silent: Type.Optional(Type.Boolean()),
/** Poll anonymity where supported (e.g. Telegram polls default to anonymous). */
isAnonymous: Type.Optional(Type.Boolean()),
/** Thread id (channel-specific meaning, e.g. Telegram forum topic id). */
threadId: Type.Optional(Type.String()),
channel: Type.Optional(Type.String()),
accountId: Type.Optional(Type.String()),
idempotencyKey: NonEmptyString,

View File

@@ -274,7 +274,11 @@ export const sendHandlers: GatewayRequestHandlers = {
question: string;
options: string[];
maxSelections?: number;
durationSeconds?: number;
durationHours?: number;
silent?: boolean;
isAnonymous?: boolean;
threadId?: string;
channel?: string;
accountId?: string;
idempotencyKey: string;
@@ -303,8 +307,13 @@ export const sendHandlers: GatewayRequestHandlers = {
question: request.question,
options: request.options,
maxSelections: request.maxSelections,
durationSeconds: request.durationSeconds,
durationHours: request.durationHours,
};
const threadId =
typeof request.threadId === "string" && request.threadId.trim().length
? request.threadId.trim()
: undefined;
const accountId =
typeof request.accountId === "string" && request.accountId.trim().length
? request.accountId.trim()
@@ -340,6 +349,9 @@ export const sendHandlers: GatewayRequestHandlers = {
to: resolved.to,
poll: normalized,
accountId,
threadId,
silent: request.silent,
isAnonymous: request.isAnonymous,
});
const payload: Record<string, unknown> = {
runId: idem,