[英]Using HTML in Telegram bot
This is not a duplicated question.这不是一个重复的问题。 I want to use html codes in my telegram bot that is written by c#.
我想在我的电报机器人中使用由 c# 编写的 html 代码。 I searched in SO but I did not find any answer.
我在 SO 中搜索,但没有找到任何答案。 How to do that?
怎么做? I used TelegramBotSharp.
我使用了 TelegramBotSharp。 Here is my code related to the part that I explained:
这是与我解释的部分相关的代码:
MessageTarget target = (MessageTarget)update.Chat ?? update.From;
if(Text.StartsWith("Hello")) {
bot.SendMessage(target, "Hello <a href='http://google.com'> dear</a>", true);
}
Use the following syntax in your message:
*bold text*
_italic text_
[inline URL](http://www.example.com/)
[inline mention of a user](tg://user?id=123456789)
pre-formatted fixed-width code block
Note: Only the tags mentioned above are currently supported.注意:目前仅支持上述标签。
Tags must not be nested.标签不得嵌套。
All <, > and & symbols that are not a part of a tag or an HTML entity must be replaced with the corresponding HTML entities (< with <, > with > and & with &).
所有不属于标签或 HTML 实体的 <、> 和 & 符号必须替换为相应的 HTML 实体
(< with <, > with > and & with &).
All numerical HTML entities are supported.支持所有数字 HTML 实体。
The API currently supports only the following named HTML entities: <, >, & and ".
API 当前仅支持以下命名的 HTML 实体:
<, >, & and ".
<, >, & and ".
If you need to format using html you need to set "parse_mode" as "html";如果您需要使用 html 进行格式化,则需要将“parse_mode”设置为“html”;
https://api.telegram.org/bot1328912345:BBCCDDExVAKD2GOEA1mXWfXfhQ_z8Y6rRh8/sendmessage?chat_id=12345678&text=Sample message&parse_mode=html)
As of now only following tags are supported by Bot:截至目前,Bot 仅支持以下标签:
<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>
Source: https://core.telegram.org/bots/api#formatting-options来源: https : //core.telegram.org/bots/api#formatting-options
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.