Michael Korolev
Michael Korolev

Reputation: 11

telegram bot send_message() hangs with HTML text

I am new to Telegram Bot API (python telegram.ext), here is my question: I am trying to send formatted message in reply to received message. For simplicity I removed everything from the code below

    mtxt = "<ul><li>line 1</li></ul>"
    res = bot.send_message(chat_id=update.message.chat_id, text=mtxt, parse_mode='HTML')
    print(res)

Nothing is returned to telegram (no answer from bot) and print() never happens. If I remove 'parse_mode...' clause from the call it works.

I must be fundamentally wrong somewhere... This is very basic staff, what is missing?

Upvotes: 1

Views: 5635

Answers (3)

wormhit
wormhit

Reputation: 3827

You need to specify parse_mode parameter. Either use ParseMode.HTML or just simple "HTML" should do the trick.

Example code that worked for me:

send_message(chat_id=chat_id, text=answer, parse_mode="HTML")

Upvotes: 1

Sascha Hendel
Sascha Hendel

Reputation: 11

The usable tags are listed here: https://core.telegram.org/bots/api#formatting-options

If You use other tags the telegram API fails.

Upvotes: 0

Sean Wei
Sean Wei

Reputation: 7985

There only have limited tags :(

You can use emoji to format, or make a suggestion to Telegram.

Upvotes: 2

Related Questions