Python 如何发送彩色短信?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37092909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 18:50:15  来源:igfitidea点击:

How to send a colored text message?

pythonpython-3.xpython-telegram-bot

提问by Rakete1111

I am trying to send a colored text message to a user as reply, using sendMessagewith HTML parsing.

我正在尝试使用sendMessageHTML 解析向用户发送彩色文本消息作为回复。

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 spanis not supported:

发送<span style="color:blue">foo</span>不起作用,因为span不支持:

Bad Request: Can't parse message text: Unsupported start tag "span" at byte offset 0 (400)

错误请求:无法解析消息文本:字节偏移量 0 (400) 处不支持的起始标记“span”

I am using the python-telegram-botv. 4.0.3.

我正在使用python-telegram-botv. 4.0.3。

Is there another way?

还有其他方法吗?

回答by edoput

Unfortunately there is no documentation about the tag accepted by the bot, except the unit test for parsemode.

不幸的是,除了parsemode单元测试之外,没有关于机器人接受的标签的文档。

The tags that work are b, i, afor bold, italic and link elements, this is what is offered, maybe there's more but I couldn't find it in the docs

有效的标签是b, i,a用于粗体、斜体和链接元素,这就是所提供的,也许还有更多,但我在文档中找不到

回答by veaceslav.kunitki

Your can enlight piece of text with grave character "`"

您可以点亮带有严重字符“`”的文本

AAAA ` enlight piece` BBB

AAAA` enlight piece` BBB