使用AtleGram bot以不同字体发送消息

2024-05-29 01:41:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用frameworkpython电报机器人创建一个电报信使机器人

现在,bot必须发送具有特定字体的消息。这意味着bot发送的消息具有不同且漂亮的字体-一种不同于电报信使字体的字体

我怎么做


Tags: 消息bot字体机器人电报信使frameworkpython
3条回答

您可以使用的唯一颜色是红色或将背景色设置为灰色

str = "`Hello`"     #this will turn the text red on Telegram.
str = "```Hello```" #this will turn the background color gray of the text on Telegram

然后在发送消息功能中,您需要添加参数parse_mode,并将其设置为“Markdown”

没有人(即使你是官员)可以用不同的字体/颜色发送消息,但你可以向@Telegram提出建议。他们会考虑将此添加为一个特性。

消息文本中有有限的formatting options,您可能会喜欢它

电报目前支持这些HTML标记:

https://core.telegram.org/bots/api#formatting-options

<b>bold</b>, <strong>bold</strong>
<i>italic</i>, <em>italic</em>
<u>underline</u>, <ins>underline</ins>
<s>strikethrough</s>, <strike>strikethrough</strike>, <del>strikethrough</del>
<b>bold <i>italic bold <s>italic bold strikethrough</s> <u>underline italic bold</u></i> bold</b>
<a href="http://www.example.com/">inline URL</a>
<a href="tg://user?id=123456789">inline mention of a user</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>
<pre><code class="language-python">pre-formatted fixed-width code block written in the Python programming language</code></pre>

相关问题 更多 >

    热门问题