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

Getting `Bad Request: can't parse message text` exception #131

Closed
avinassh opened this Issue Dec 23, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@avinassh

avinassh commented Dec 23, 2015

I am on Python 3 and using latest version library. Whenever I try to send following text, I am getting above exception:

"Title: The Color of Magic (Discworld, #1; Rincewind #1) by Terry Pratchett,\nRating: 3.94 by 151538 users,\nDescription: Terry Pratchett's profoundly irreverent, bestselling novels have garnered him a revered position in the halls of parody next to the likes of Mark Twain, Kurt Vonnegut, Douglas Adams, and Carl Hiaasen. The Color of Magic is Terry Pratchett's maiden voyage through the now-legendary land of Discworld. This is where it all begins -- with the tourist Twoflower and his wizard guide, Rincewind. On a world supported on the back of a giant turtle (sex unknown), a gleeful, explosive, wickedly eccentric expedition sets out. There's an avaricious but inept wizard, a naive tourist whose luggage moves on hundreds of dear little legs, dragons who only exist if you believe in them, and of course THE EDGE of the planet...\n,\nLink: http://www.goodreads.com/book/show/34497.The_Color_of_Magic\n\nTip: Use author name also for better search results"

In [14]: response
Out[14]: "**Title:** The Color of Magic (Discworld, #1; Rincewind #1) by Terry Pratchett,\n**Rating:** 3.94 by 151538 users,\n**Description:** Terry Pratchett's profoundly irreverent, bestselling novels have garnered him a revered position in the halls of parody next to the likes of Mark Twain, Kurt Vonnegut, Douglas Adams, and Carl Hiaasen. _The Color of Magic_ is Terry Pratchett's maiden voyage through the now-legendary land of Discworld. This is where it all begins -- with the tourist Twoflower and his wizard guide, Rincewind. _On a world supported on the back of a giant turtle (sex unknown), a gleeful, explosive, wickedly eccentric expedition sets out. There's an avaricious but inept wizard, a naive tourist whose luggage moves on hundreds of dear little legs, dragons who only exist if you believe in them, and of course THE EDGE of the planet..._\n,\n**Link**: http://www.goodreads.com/book/show/34497.The_Color_of_Magic\n\nTip: Use author name also for better search results"

In [15]: bot.sendMessage(parse_mode='Markdown', disable_web_page_preview=True, reply_to_message_id=273, chat_id=-86257015, text=response)
...

TelegramError: [Error]: Bad Request: can't parse message text: Can't find end of the entity starting at byte offset 915

Full traceback - http://dpaste.com/2827V8Y

@jh0ker

This comment has been minimized.

Show comment
Hide comment
@jh0ker

jh0ker Dec 23, 2015

Member

Hi! :) you're using markdown. If the markdown parser finds an opening markdown symbol without the corresponding closing one, it throws an error. So probably, you have an odd number of * or _ in your text.

Edit: Telegram uses a single *bold* and not **bold**, maybe that's the problem

Member

jh0ker commented Dec 23, 2015

Hi! :) you're using markdown. If the markdown parser finds an opening markdown symbol without the corresponding closing one, it throws an error. So probably, you have an odd number of * or _ in your text.

Edit: Telegram uses a single *bold* and not **bold**, maybe that's the problem

@avinassh

This comment has been minimized.

Show comment
Hide comment
@avinassh

avinassh Dec 24, 2015

Hey thanks for replying! I stripped down most of the special characters and started using single asteriks for bold, but I am not able to send it. Here's my current string:

"*Title:* The Color of Magic (Discworld, #1; Rincewind #1) by Terry Pratchett \n *Rating:* 3.94 by 151574 users \n *Description:* Terry Pratchett's profoundly irreverent, bestselling novels have garnered him a revered position in the halls of parody next to the likes of Mark Twain, Kurt Vonnegut, Douglas Adams, and Carl Hiaasen.The Color of Magic is Terry Pratchett's maiden voyage through the now-legendary land of Discworld. This is where it all begins -- with the tourist Twoflower and his wizard guide, Rincewind.On a world supported on the back of a giant turtle (sex unknown), a gleeful, explosive, wickedly eccentric expedition sets out. There's an avaricious but inept wizard, a naive tourist whose luggage moves on hundreds of dear little legs, dragons who only exist if you believe in them, and of course THE EDGE of the planet... \n *Link*: http://www.goodreads.com/book/show/34497.The_Color_of_Magic \n Tip: Use author name also for better search results"

avinassh commented Dec 24, 2015

Hey thanks for replying! I stripped down most of the special characters and started using single asteriks for bold, but I am not able to send it. Here's my current string:

"*Title:* The Color of Magic (Discworld, #1; Rincewind #1) by Terry Pratchett \n *Rating:* 3.94 by 151574 users \n *Description:* Terry Pratchett's profoundly irreverent, bestselling novels have garnered him a revered position in the halls of parody next to the likes of Mark Twain, Kurt Vonnegut, Douglas Adams, and Carl Hiaasen.The Color of Magic is Terry Pratchett's maiden voyage through the now-legendary land of Discworld. This is where it all begins -- with the tourist Twoflower and his wizard guide, Rincewind.On a world supported on the back of a giant turtle (sex unknown), a gleeful, explosive, wickedly eccentric expedition sets out. There's an avaricious but inept wizard, a naive tourist whose luggage moves on hundreds of dear little legs, dragons who only exist if you believe in them, and of course THE EDGE of the planet... \n *Link*: http://www.goodreads.com/book/show/34497.The_Color_of_Magic \n Tip: Use author name also for better search results"
@avinassh

This comment has been minimized.

Show comment
Hide comment
@avinassh

avinassh Dec 24, 2015

Observed it closely again and this was the culprit:

http://www.goodreads.com/book/show/34497.The_Color_of_Magic

avinassh commented Dec 24, 2015

Observed it closely again and this was the culprit:

http://www.goodreads.com/book/show/34497.The_Color_of_Magic
@rootux

This comment has been minimized.

Show comment
Hide comment
@rootux

rootux Mar 21, 2018

This error message is quite confusing. I would write something like
"Markdown text is invalid - please check for any odd number of * or _ in the text

rootux commented Mar 21, 2018

This error message is quite confusing. I would write something like
"Markdown text is invalid - please check for any odd number of * or _ in the text

@tsnoam

This comment has been minimized.

Show comment
Hide comment
@tsnoam

tsnoam Mar 21, 2018

Member

@rootux Please don't resurrect ancient issues.
For the record, the error text is received from telegram servers, ptb is merely relaying the error message as an exception.

Member

tsnoam commented Mar 21, 2018

@rootux Please don't resurrect ancient issues.
For the record, the error text is received from telegram servers, ptb is merely relaying the error message as an exception.

@python-telegram-bot python-telegram-bot locked as resolved and limited conversation to collaborators Mar 21, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.