mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-19 11:38:38 +00:00
Default Telegram polls to public
This commit is contained in:
@@ -1293,6 +1293,36 @@ describe("sendPollTelegram", () => {
|
|||||||
expect(api.sendPoll.mock.calls[0]?.[3]).toMatchObject({ open_period: 60 });
|
expect(api.sendPoll.mock.calls[0]?.[3]).toMatchObject({ open_period: 60 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("defaults polls to public (is_anonymous=false)", async () => {
|
||||||
|
const api = {
|
||||||
|
sendPoll: vi.fn(async () => ({ message_id: 123, chat: { id: 555 }, poll: { id: "p1" } })),
|
||||||
|
};
|
||||||
|
|
||||||
|
await sendPollTelegram(
|
||||||
|
"123",
|
||||||
|
{ question: "Q", options: ["A", "B"] },
|
||||||
|
{ token: "t", api: api as unknown as Bot["api"] },
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(api.sendPoll).toHaveBeenCalledTimes(1);
|
||||||
|
expect(api.sendPoll.mock.calls[0]?.[3]).toMatchObject({ is_anonymous: false });
|
||||||
|
});
|
||||||
|
|
||||||
|
it("supports explicit anonymous polls", async () => {
|
||||||
|
const api = {
|
||||||
|
sendPoll: vi.fn(async () => ({ message_id: 123, chat: { id: 555 }, poll: { id: "p1" } })),
|
||||||
|
};
|
||||||
|
|
||||||
|
await sendPollTelegram(
|
||||||
|
"123",
|
||||||
|
{ question: "Q", options: ["A", "B"] },
|
||||||
|
{ token: "t", api: api as unknown as Bot["api"], isAnonymous: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(api.sendPoll).toHaveBeenCalledTimes(1);
|
||||||
|
expect(api.sendPoll.mock.calls[0]?.[3]).toMatchObject({ is_anonymous: true });
|
||||||
|
});
|
||||||
|
|
||||||
it("retries without message_thread_id on thread-not-found", async () => {
|
it("retries without message_thread_id on thread-not-found", async () => {
|
||||||
const api = {
|
const api = {
|
||||||
sendPoll: vi.fn(
|
sendPoll: vi.fn(
|
||||||
|
|||||||
@@ -974,7 +974,7 @@ type TelegramPollOpts = {
|
|||||||
messageThreadId?: number;
|
messageThreadId?: number;
|
||||||
/** Send message silently (no notification). Defaults to false. */
|
/** Send message silently (no notification). Defaults to false. */
|
||||||
silent?: boolean;
|
silent?: boolean;
|
||||||
/** Whether votes are anonymous. Defaults to true (Telegram default). */
|
/** Whether votes are anonymous. Defaults to false (public poll). */
|
||||||
isAnonymous?: boolean;
|
isAnonymous?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1032,7 +1032,7 @@ export async function sendPollTelegram(
|
|||||||
// sendPoll(chat_id, question, options, other?, signal?)
|
// sendPoll(chat_id, question, options, other?, signal?)
|
||||||
const pollParams = {
|
const pollParams = {
|
||||||
allows_multiple_answers: normalizedPoll.maxSelections > 1,
|
allows_multiple_answers: normalizedPoll.maxSelections > 1,
|
||||||
is_anonymous: opts.isAnonymous ?? true,
|
is_anonymous: opts.isAnonymous ?? false,
|
||||||
...(durationSeconds !== undefined ? { open_period: durationSeconds } : {}),
|
...(durationSeconds !== undefined ? { open_period: durationSeconds } : {}),
|
||||||
...(Object.keys(threadParams).length > 0 ? threadParams : {}),
|
...(Object.keys(threadParams).length > 0 ? threadParams : {}),
|
||||||
...(opts.silent === true ? { disable_notification: true } : {}),
|
...(opts.silent === true ? { disable_notification: true } : {}),
|
||||||
|
|||||||
Reference in New Issue
Block a user