最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Retrieving telegram poll results when the poll is closed - Stack Overflow

programmeradmin3浏览0评论

I'm currently using grammY to create a telegram bot.

I'm able to create a poll using the below code. The poll closes when at pollCloseDate.

I want to send a message when the poll closes. The message should have context of the result of the closed poll. eg. "Option 1 has the most vote!".

How can I do so?

botmand("q", async (ctx) => {
    const poll = await ctx.api.sendPoll(
        ctx.chat.id,
        "Poll question",
        [{text: "option 1"}, {text: "option 2"}, {text: "option 3"}],
        { is_anonymous: true, allows_multiple_answers: true, close_date: pollCloseDate}
    );
});

Thanks for the help!

I have tried using bot.on("poll" ...), bot.on("poll_answer" ...) but both were not called when the poll is closed using the close_date.

I'm currently using grammY to create a telegram bot.

I'm able to create a poll using the below code. The poll closes when at pollCloseDate.

I want to send a message when the poll closes. The message should have context of the result of the closed poll. eg. "Option 1 has the most vote!".

How can I do so?

botmand("q", async (ctx) => {
    const poll = await ctx.api.sendPoll(
        ctx.chat.id,
        "Poll question",
        [{text: "option 1"}, {text: "option 2"}, {text: "option 3"}],
        { is_anonymous: true, allows_multiple_answers: true, close_date: pollCloseDate}
    );
});

Thanks for the help!

I have tried using bot.on("poll" ...), bot.on("poll_answer" ...) but both were not called when the poll is closed using the close_date.

Share Improve this question edited Mar 18 at 15:44 Daniel Chua asked Mar 17 at 16:35 Daniel ChuaDaniel Chua 12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

you can use schedule message and set date and time same as poll closes

to get poll results after poll coloses you can save message_id of the poll and access the results by message_id

I'm not familiar with this library, but you can search for it or get help from ChatGPT to write the code.

发布评论

评论列表(0)

  1. 暂无评论