Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error on help command (and workaround) #57

Open
gtrafimenkov opened this issue Nov 26, 2016 · 11 comments
Open

error on help command (and workaround) #57

gtrafimenkov opened this issue Nov 26, 2016 · 11 comments

Comments

@gtrafimenkov
Copy link

Hello,

I've encountered the same problem as #41. I almost gave up on the idea to make hubot work with telegram but accidentally found a workaround.

If the bot name has an underscore in it, then the help command doesn't work (but all other commands work fine). See the debug log below.

All Telegram bots have _bot in the end of their names. Also if you want to address the bot in the group chat, its (hubot) name must be the same as Telegram bot name. And here is the problem, underscore characters in the name makes the help command fail.

The workaround I found is to have the (hubot) name without underscore and provide a convenient alias for addressing the bot from the chat. For example, use / character as alias, start the hubot like this

bin/hubot -a telegram -l /

and in the group chat type /command instead of @botname command

I hope this helps.

My setup:

  • clean Ubuntu 16.04 virtual machine
vagrant@u1604:~/gttest003_bot$ uname -a
Linux u1604 4.4.0-21-generic #37-Ubuntu SMP Mon Apr 18 18:33:37 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
vagrant@u1604:~/gttest003_bot$ node --version
v6.9.1
vagrant@u1604:~/gttest003_bot$ npm --version
3.10.8
  • brand new bot, name of the bot is "gttest003_bot"

Debug log showing unsuccessful help and successful ping commands:

vagrant@u1604:~/gttest003_bot$ HUBOT_LOG_LEVEL="debug" TELEGRAM_TOKEN=XXX bin/hubot -a telegram
[Sat Nov 26 2016 17:36:46 GMT+0000 (UTC)] DEBUG Loading adapter telegram
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO Telegram Adapter Bot XXX Loaded...
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO Telegram Adapter Started...
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading scripts from /home/vagrant/gttest003_bot/scripts
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/scripts/example.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading scripts from /home/vagrant/gttest003_bot/src/scripts
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading hubot-scripts from /home/vagrant/gttest003_bot/node_modules/hubot-scripts/src/scripts
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] WARNING Loading scripts from hubot-scripts.json is deprecated and will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) in favor of packages for each script.

Your hubot-scripts.json is empty, so you just need to remove it.
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Loading external-scripts from npm packages
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-diagnostics/src/diagnostics.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-help/src/help.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] ERROR hubot-heroku-alive included, but missing HUBOT_HEROKU_KEEPALIVE_URL. `heroku config:set HUBOT_HEROKU_KEEPALIVE_URL=$(heroku apps:info -s  | grep web-url | cut -d= -f2)`
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-heroku-keepalive/src/heroku-keepalive.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-google-images/src/google-images.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-google-translate/src/google-translate.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-pugme/src/pugme.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-maps/src/maps.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO hubot-redis-brain: Using default redis on localhost:6379
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-redis-brain/src/redis-brain.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-rules/src/rules.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG Parsing help for /home/vagrant/gttest003_bot/node_modules/hubot-shipit/src/shipit.coffee
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] DEBUG hubot-redis-brain: Successfully connected to Redis
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO hubot-redis-brain: Data for hubot brain retrieved from Redis
[Sat Nov 26 2016 17:36:47 GMT+0000 (UTC)] INFO Telegram Bot Identified: gttest003_bot
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG { update_id: 364844667,
  message:
   { message_id: 31,
     from:
      { id: 157896654,
        first_name: 'Gennady',
        last_name: 'Trafimenkov',
        username: 'gtrafimenkov' },
     chat:
      { id: 157896654,
        first_name: 'Gennady',
        last_name: 'Trafimenkov',
        username: 'gtrafimenkov',
        type: 'private' },
     date: 1480181826,
     text: 'help' } }
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] INFO Receiving message_id: 31
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Received message: gtrafimenkov said 'gttest003_bot help'
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Message 'gttest003_bot help' matched regex //^\s*[@]?gttest003_bot[:,]?\s*(?:help(?:\s+(.*))?$)/i/; listener.options = { id: null }
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'gttest003_bot help'
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Message length: 1212
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] DEBUG Message parts: 1
[Sat Nov 26 2016 17:37:07 GMT+0000 (UTC)] ERROR Error: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 1027
  at Function.TelegramBot.error (/home/vagrant/gttest003_bot/node_modules/telegrambot/lib/telegrambot.js:26:15)
  at Request._callback (/home/vagrant/gttest003_bot/node_modules/telegrambot/lib/telegrambot.js:47:66)
  at Request.self.callback (/home/vagrant/gttest003_bot/node_modules/request/request.js:186:22)
  at emitTwo (events.js:106:13)
  at Request.emit (events.js:191:7)
  at Request.<anonymous> (/home/vagrant/gttest003_bot/node_modules/request/request.js:1081:10)
  at emitOne (events.js:96:13)
  at Request.emit (events.js:188:7)
  at IncomingMessage.<anonymous> (/home/vagrant/gttest003_bot/node_modules/request/request.js:1001:12)
  at IncomingMessage.g (events.js:291:16)
  at emitNone (events.js:91:20)
  at IncomingMessage.emit (events.js:185:7)
  at endReadableNT (_stream_readable.js:974:12)
  at _combinedTickCallback (internal/process/next_tick.js:74:11)
  at process._tickCallback (internal/process/next_tick.js:98:9)

[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG { update_id: 364844668,
  message:
   { message_id: 32,
     from:
      { id: 157896654,
        first_name: 'Gennady',
        last_name: 'Trafimenkov',
        username: 'gtrafimenkov' },
     chat:
      { id: 157896654,
        first_name: 'Gennady',
        last_name: 'Trafimenkov',
        username: 'gtrafimenkov',
        type: 'private' },
     date: 1480181831,
     text: 'ping' } }
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] INFO Receiving message_id: 32
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Received message: gtrafimenkov said 'gttest003_bot ping'
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Message 'gttest003_bot ping' matched regex //^\s*[@]?gttest003_bot[:,]?\s*(?:PING$)/i/; listener.options = { id: null }
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Executing listener callback for Message 'gttest003_bot ping'
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Message length: 4
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] DEBUG Message parts: 1
[Sat Nov 26 2016 17:37:13 GMT+0000 (UTC)] INFO Sending message to room: 157896654
@hanselke
Copy link

got the same error, calling the bot by botname or @botName too

[Mon Jan 23 2017 06:26:39 GMT+0000 (GMT)] ERROR Error: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 483
at Function.TelegramBot.error (/root/blueskygroupbot/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/root/blueskygroupbot/node_modules/telegrambot/lib/telegrambot.js:47:66)
at Request.self.callback (/root/blueskygroupbot/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/root/blueskygroupbot/node_modules/request/request.js:1081:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/root/blueskygroupbot/node_modules/request/request.js:1001:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

[Mon Jan 23 2017 06:26:39 GMT+0000 (GMT)] ERROR hubot-bangbang: DOES NOT COMPUTE
[Mon Jan 23 2017 06:27:45 GMT+0000 (GMT)] INFO Receiving message_id: 5
[Mon Jan 23 2017 06:27:45 GMT+0000 (GMT)] ERROR Error: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 483
at Function.TelegramBot.error (/root/blueskygroupbot/node_modules/telegrambot/lib/telegrambot.js:26:15)
at Request._callback (/root/blueskygroupbot/node_modules/telegrambot/lib/telegrambot.js:47:66)
at Request.self.callback (/root/blueskygroupbot/node_modules/request/request.js:186:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:191:7)
at Request. (/root/blueskygroupbot/node_modules/request/request.js:1081:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:188:7)
at IncomingMessage. (/root/blueskygroupbot/node_modules/request/request.js:1001:12)
at IncomingMessage.g (events.js:291:16)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)

[Mon Jan 23 2017 06:27:45 GMT+0000 (GMT)] ERROR hubot-bangbang: DOES NOT COMPUTE

@lukefx
Copy link
Owner

lukefx commented Jan 23, 2017

Ok strange, I will try to look at this asap, thx guys for reporting it 👍

@hashashin
Copy link

Hi, same problem here, or similar at least, on my tests it's seems has something to do with the markdown support in the messages and underscores (_) ie:

Jan 23 02:06:23 ambrosio-tele app/web.1:  [Mon Jan 23 2017 11:06:23 GMT+0100 (CET)] INFO hubot-rss-reader: Pokémon ¿qué? http://elpais.com/cultura/2017/01/22/television/1485084013_172502.html#?ref=rss&format=simple&link=link => 133188453 
Jan 23 02:06:25 ambrosio-tele app/web.1:  [M
:
Jan 23 02:06:23 ambrosio-tele app/web.1:  [Mon Jan 23 2017 11:06:23 GMT+0100 (CET)] INFO hubot-rss-reader: Pokémon ¿qué? http://elpais.com/cultura/2017/01/22/television/1485084013_172502.html#?ref=rss&format=simple&link=link => 133188453 
Jan 23 02:06:25 ambrosio-tele app/web.1:  [Mon Jan 23 2017 11:06:25 GMT+0100 (CET)] ERROR Error: Bad Request: Can't parse message text: Can't find end of the entity starting at byte offset 135 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at Function.TelegramBot.error (/app/node_modules/telegrambot/lib/telegrambot.js:26:15) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at Request._callback (/app/node_modules/telegrambot/lib/telegrambot.js:47:66) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at Request.self.callback (/app/node_modules/request/request.js:186:22) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at emitTwo (events.js:106:13) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at Request.emit (events.js:191:7) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at Request.<anonymous> (/app/node_modules/request/request.js:1081:10) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at emitOne (events.js:96:13) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at Request.emit (events.js:188:7) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1001:12) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at IncomingMessage.g (events.js:291:16) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at emitNone (events.js:91:20) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at IncomingMessage.emit (events.js:185:7) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at endReadableNT (_stream_readable.js:974:12) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at _combinedTickCallback (internal/process/next_tick.js:74:11) 
Jan 23 02:06:25 ambrosio-tele app/web.1:      at process._tickCallback (internal/process/next_tick.js:98:9) 

Notice the underscore in the msg.

Thanks, salud!

@hashashin
Copy link

Forgot to say, I've markdown formated responses that work just fine, the problem appears with "unclosed" markdown ie: "_something_" => something works, "some_thing" fails.

@MTRNord
Copy link

MTRNord commented Jun 29, 2017

any progress? still failing on my side even with the workaround

@MTRNord
Copy link

MTRNord commented Jun 29, 2017

Hm works with help but not better-help

@bafplus
Copy link

bafplus commented Jun 30, 2017

I have the same issue with hubot-better-help
doesent work with "hubot help"
But does work when calling help on a command "hubot help adapter"

@gburgett
Copy link

gburgett commented Jul 1, 2017

The issue is definitely the unclosed underscore.

curl -XPOST -H 'content-type: application/json' https://api.telegram.org/$TELEGRAM_TOKEN/sendMessage -d @/tmp/test.json

contents of /tmp/test.json should be

{ 
  "chat_id": 344335405,
  "text": "This unmatched_underscore breaks telegram markdown parsing",
  "reply_to_message_id": 8,
  "parse_mode": "Markdown"
}

response:

{"ok":false,"error_code":400,"description":"Bad Request: can't parse entities in message text: Can't find end of the entity starting at byte offset 14"}

I'm asking telegram bot help about this, I'll let you know what they say. Other markdown parsers that I've used will just leave a literal underscore when there's no second, closing underscore. And in fact that's how it works if you write an underscore in the web client, so I don't see why it should work differently for the bot API.

@surfer190
Copy link

@gburgett Any update on this, I see the problem is persisting.

@gburgett
Copy link

gburgett commented May 22, 2019

@surfer190 this was the latest info that I have from two years ago: CruAlbania/hubot-better-help#3

You could repeat the curl command above and test whether their markdown parsing is still broken.

@surfer190
Copy link

@gburgett Yes, same response.

http POST https://api.telegram.org/botXXX:YYY/sendMessage < test.json

returns:

{
    "description": "Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 14",
    "error_code": 400,
    "ok": false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants