'How to send a colored text message?
I am trying to send a colored text message to a user as reply, using sendMessage with HTML parsing.
bot.sendMessage(update.message.chat_id, "<span style=\"color:blue\">foo</span>", telegram.ParseMode.HTML)
Sending <span style="color:blue">foo</span> doesn't work, as span is not supported:
Bad Request: Can't parse message text: Unsupported start tag "span" at byte offset 0 (400)
I am using the python-telegram-bot v. 4.0.3.
Is there another way?
Solution 1:[1]
Your can enlight piece of text with grave character "`"
AAAA `
enlight piece` BBB
Solution 2:[2]
According to the core API docs, Telegram only supports the <span> tag for spoiler text. I tried to send a message with HTML parsing and the text:
"<span style=\"color:#fc5252;\">text</span>"
And got:
Can't parse entities: tag "span" must have class "tg-spoiler" at byte offset 0
I'm guessing this means the <span> tag can only be used for spoiler text.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | veaceslav.kunitki |
| Solution 2 | wraithie |
