ETELEGRAM:400 错误请求:轮询无法停止

ETELEGRAM: 400 Bad Request: poll can't be stopped

我正在尝试调用 telegramBot.stopPoll() 函数,但出现错误

ETELEGRAM: 400 Bad Request: poll can't be stopped

我想在期望的人 (userId) 回答投票时停止投票。

这是我创建投票和停止投票的函数。

function sendJacuzziMaintenancePoll(chatId, userName){

    return new Promise(function (resolve, reject) {

        var question = "Jacuzzi Maintenance QA checklist. @"+userName+" Please mark you think you have done.";
        var answers = ["Water quality check", "Post the picture of the PH test stripe to the Telegram group", "Check the current temperature and post the picture to the Telegram group"];

        var pollMessageId = null;

        var reply_markup  = JSON.stringify({
            'force_reply': true,
            'selective' : true
        });

        const opts = {
            'is_anonymous': false,
            'allows_multiple_answers': true,
            'reply_markup': reply_markup
        };

        // set poll_answer listener so that we can stop the poll when answered by the desired user
        // This will be called when a user answer a poll
        telegramBot.addListener("poll_answer", function (response) {
            console.log("poll_answer response", response);
            // Remove listner first
            telegramBot.removeListener("poll_answer");

            // Check the same user
             if (userName === response.user.username){
                 let message = "@" + userName + " " + STRINGS.BOT_MESSAGE_THANKYOU_FOR_POLL_VOTE;
                 sendMessage(chatId, message);

                 //Stop the POLL
                 telegramBot.stopPoll(chatId, pollMessageId);

             } else {
                 let message = "@" + userName + " --" + STRINGS.BOT_MESSAGE_THANKYOU_FOR_POLL_VOTE;
                 sendMessage(chatId, message);
             }
        })
    
        telegramBot.sendPoll(chatId, question, answers, opts).then(function(response){
            pollMessageId = response.message_id;
            resolve(response);
        }).catch(function(err){
            reject(err);
        })
    })
}

注意:我在发送轮询时保存响应中的 pollMessageId,然后传递该 pollMessageId 以停止轮询。

我是不是做错了什么?

这是完成的堆栈跟踪。

Unhandled rejection Error: ETELEGRAM: 400 Bad Request: poll can't be stopped
    at /Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/node-telegram-bot-api/src/telegram.js:284:15
    at tryCatcher (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/promise.js:547:31)
    at Promise._settlePromise (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/promise.js:604:18)
    at Promise._settlePromise0 (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/promise.js:649:10)
    at Promise._settlePromises (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/promise.js:729:18)
    at _drainQueueStep (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/async.js:93:12)
    at _drainQueue (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/async.js:86:9)
    at Async._drainQueues (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/qadirhussain/workspace/nodeJS/qRoomCleaningBot/node_modules/bluebird/js/release/async.js:15:14)
    at processImmediate (internal/timers.js:456:21)

我不确定,但我相信这是 Telegram Bot API 在处理 ForceReply 标记时的实现中的一个错误(因为其他 reply_markup 选项如内联按钮有效正好)。删除该标记,它应该可以正常工作。

...
const opts = {
    'is_anonymous': false,
    'allows_multiple_answers': true,
    // 'reply_markup': reply_markup // remove this
};