node-telegram-bot-api icon indicating copy to clipboard operation
node-telegram-bot-api copied to clipboard

Node-red

Open davidebene opened this issue 11 years ago • 3 comments

Hi. Has anyone tested the use of the module within node-red? I declared globally the module within the settings.js of node-red, and I put the following sample code in a function node:

var TelegramBot = context.global.telegram; var token = 'my-bot-token'; var bot = new TelegramBot(token, {polling: true}); bot.on('message', function (msg) { var chatId = msg.chat.id; var testMsg = "test message"; bot.sendMessage(chatId, testMsg, {caption: "I'm a bot!"}); });

But the debugger gives me the following error:

Unhandled rejection Error: 409 {"ok":false,"error_code":409,"description":"Error: Conflict: terminated by other long poll or webhook"} at /usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/src/telegram.js:131:15 at tryCatcher (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/util.js:24:31) at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:489:31) at Promise._settlePromiseAt (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:565:18) at Promise._settlePromises (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/promise.js:681:14) at Async._drainQueue (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:123:16) at Async._drainQueues (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:133:10) at Async.drainQueues (/usr/local/lib/node_modules/node-red/node_modules/node-telegram-bot-api/node_modules/bluebird/js/main/async.js:15:14) at process._tickCallback (node.js:442:13)

Thanks!

davidebene avatar Jul 07 '15 15:07 davidebene

I am using a Python API to telegram and occasionally receive the same error, 409.

mahrens917 avatar Aug 14 '15 19:08 mahrens917

This happens when to program with same token polls the telegram bots api. you can run only one bot with same token at the same time.

Waterloo avatar Sep 03 '15 03:09 Waterloo

@davidebene This was done by this merge https://github.com/yagop/node-telegram-bot-api/pull/117

litinskii avatar Jun 08 '16 03:06 litinskii