lukefx / hubot-telegram

Hubot adapter for Telegram
MIT License
160 stars 42 forks source link

ERROR TypeError: Cannot read property 'message_id' of undefined #46

Closed ishankhare07 closed 8 years ago

ishankhare07 commented 8 years ago

This happens when i try to call my bot using @ syntax in a group while it works fine for direct chat with bot

eg. mybot help -> works great in direct chat with the bot @mybot_username help -> sucks in group chat

ERROR TypeError: Cannot read property 'message_id' of undefined
2016-04-05T21:35:09.531315+00:00 app[web.1]:   at Telegram.handleUpdate (/app/node_modules/hubot-telegram/src/telegram.coffee:176:28, <js>:217:64)
2016-04-05T21:35:09.531316+00:00 app[web.1]:   at Function.<anonymous> (/app/node_modules/hubot-telegram/src/telegram.coffee:251:29, <js>:288:36)
2016-04-05T21:35:09.531317+00:00 app[web.1]:   at Request._callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/lib/telegrambot.js:51:12)
2016-04-05T21:35:09.531318+00:00 app[web.1]:   at Request.self.callback (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:200:22)
2016-04-05T21:35:09.531319+00:00 app[web.1]:   at Request.emit (events.js:98:17)
2016-04-05T21:35:09.531320+00:00 app[web.1]:   at Request.<anonymous> (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:1041:10)
2016-04-05T21:35:09.531320+00:00 app[web.1]:   at Request.emit (events.js:117:20)
2016-04-05T21:35:09.531321+00:00 app[web.1]:   at IncomingMessage.<anonymous> (/app/node_modules/hubot-telegram/node_modules/telegrambot/node_modules/request/request.js:968:12)
2016-04-05T21:35:09.531322+00:00 app[web.1]:   at IncomingMessage.emit (events.js:117:20)
2016-04-05T21:35:09.531323+00:00 app[web.1]:   at _stream_readable.js:944:16
2016-04-05T21:35:09.531324+00:00 app[web.1]:   at process._tickCallback (node.js:458:13)
arcturial commented 8 years ago

Does your bot use webhooks to receive updates or do you poll?

ishankhare07 commented 8 years ago

I've only setup the TELEGRAM_TOKEN and not any other things

arcturial commented 8 years ago

What version of the bot are you running currently?

arcturial commented 8 years ago

Hey, the latest master version has some more debug in to debug incoming messages. Can you please give it a try and let me know what output you get? Also, are you using an inline bot?

ishankhare07 commented 8 years ago

@arcturial will do that and let you know very soon

arcturial commented 8 years ago

Have you managed to replicate the issue with the latest debug additions active?

rvrangel commented 8 years ago

I was having the same problem with 0.1.0, but upgrading to master seems to have fixed it for me. Perhaps release a new version?

iroes commented 8 years ago

Maybe it has to do with a message update by the telegram user after being sent. The telegram API responds with a JSON object that the adapter doesn't know how to handle (the object update.message is undefined in this case, then message_id doesn't exist either. The object should be edited_message in this case).

{"update_id":887944688,"edited_message":{"message_id":9,"from":{"id":1111111,"first_name":"xxx","username":"xxx"},"chat":{"id":-22222,"title":"xxx","type":"group"},"date":1464543624,"edit_date":1464543643,"text":"xxxbot ping"}}
ghost commented 8 years ago

FYI, i had a similar problem. ERROR TypeError: Cannot read property 'hasOwnProperty' of undefined It turned out that msg.reply caused this and msg.send works fine.$

lukefx commented 8 years ago

50 This branch should fix your issue, can I ask you to test it out?

thx @ishankhare07

lukefx commented 8 years ago

As said, #50 should fix this issue. I will close this thread...hoping not have to re-open it 😃