lbb00 / hubot-telegram-better

A better hubot telegram adapter.
MIT License
10 stars 3 forks source link

hubot-help breaks when trying to use #10

Closed pedroxs closed 5 years ago

pedroxs commented 5 years ago

If you have hubot-help enabled and send help command/message the bot throws an exception and does not reply with the help messages as expected.

Stacktrace:

[Thu May 23 2019 10:58:09 GMT-0300 (Brasilia Standard Time)] INFO Receiving message_id: 70
[Thu May 23 2019 10:58:09 GMT-0300 (Brasilia Standard Time)] INFO Received message: <user> said '@test_bot help'
[Thu May 23 2019 10:58:09 GMT-0300 (Brasilia Standard Time)] DEBUG Message '@test_bot help' matched regex //^\s*[@]?test_bot[:,]?\s*(?:help(?:\s+(.*))?$)/i/; listener.options = { id: null }
[Thu May 23 2019 10:58:09 GMT-0300 (Brasilia Standard Time)] DEBUG Executing listener callback for Message '@test_bot help'
[Thu May 23 2019 10:58:09 GMT-0300 (Brasilia Standard Time)] DEBUG Message length: 1290
[Thu May 23 2019 10:58:09 GMT-0300 (Brasilia Standard Time)] DEBUG Message parts: 1
[Thu May 23 2019 10:58:10 GMT-0300 (Brasilia Standard Time)] ERROR { Error: Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 1105
    at Function.TelegramBot.error (/home/pedroxs/work/personal/qbot/node_modules/telegrambot/lib/telegrambot.js:26:15)
    at Request._callback (/home/pedroxs/work/personal/qbot/node_modules/telegrambot/lib/telegrambot.js:47:66)
    at Request.self.callback (/home/pedroxs/work/personal/qbot/node_modules/request/request.js:185:22)
    at Request.emit (events.js:193:13)
    at Request.<anonymous> (/home/pedroxs/work/personal/qbot/node_modules/request/request.js:1161:10)
    at Request.emit (events.js:193:13)
    at IncomingMessage.<anonymous> (/home/pedroxs/work/personal/qbot/node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:281:20)
    at IncomingMessage.emit (events.js:198:15)
    at endReadableNT (_stream_readable.js:1139:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:17)
 code: 400, httpStatus: 400 }
lbb00 commented 5 years ago

I will look at it later. Welcome PR, if you find some way to fix this. And I have not maintained it for a long time, I suggest you publish your own package after the fix.

pedroxs commented 5 years ago

Thanks for the reply, I found the issue, it is related to the contents of the text and not with any external modules. Basically the name of my bot had _ and since Markdown is enable by default it was trying to parse the message, but since the number of underlines was odd it broke the parser with missing close underline. What I did that fixed the issue was just adding an alias for the bot name. I guess you could just update your docs explaining this and recommending the use of an alias if your bot name has _.

For future reference you can set the bot alias with a start parameter --alias MyBot or with an environment variable HUBOT_ALIAS=MyBot