Node-telegram-bot-api: parse_mode: "Markdown" throws error. parse_mode: "markdown" does not.

Created on 6 Feb 2017  路  8Comments  路  Source: yagop/node-telegram-bot-api

Bug Report

I have read:

I am using the latest version of the library.

Expected Behavior

Using Markdown to parse my chat message.

Actual Behavior

Getting error "Can't parse message text: Can't find end of the entity starting at byte offset 3"

Steps to reproduce the Behavior

bot.sendMessage(chatID, "I will throw the error!", {
    parse_mode: "Markdown"
})

bot.sendMessage(chatID, "I wont throw the error!", {
    parse_mode: "markdown"
})

Simply changing "Markdown" -> "markdown" reproduces this issue.

sorry! my bad!

Most helpful comment

Solution
bot.sendMessage(chatId,message, {parse_mode: 'HTML'});

All 8 comments

I can not seem to reproduce this bug.

I'm sorry, it seems that I must have changed something else beyond uppercasing the M.

You can close this and if I find time to look for what reproduced it, I will get back to you.

Okay. We will be waiting.

I'm having the same kind of error Can't parse message text: Can't find end of the entity starting at byte offset xxx, and I'm using markdown parsing
It's completely random (I have ~500 events/h on the bot (private company bot))
ex in production:
no errors in the last 7 days
many errors the week before
21 days uptime

cannot reproduce bug in local

I'm essentially here to get updates on the issue...

There is probably an extra markdown element in the message you are sending. Usernames can contain underscores which has caused my bots to generate this message before I changed to HTML style. https://core.telegram.org/bots/api#markdown-style

As @monkeydave suggests, this is probably due to formatting issues with your message text. If you do not need markdown support, disable it entirely to avoid such issues.

I need markdown :( I'm gonna try to debug my templates thanks!

Solution
bot.sendMessage(chatId,message, {parse_mode: 'HTML'});

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Lemmmy picture Lemmmy  路  3Comments

dimawebmaker picture dimawebmaker  路  3Comments

qunatumwhiskey picture qunatumwhiskey  路  4Comments

lenny76 picture lenny76  路  3Comments

jacopocappelli1989 picture jacopocappelli1989  路  4Comments