在Telegram机器人中使用HTML [英] Using HTML in Telegram bot
问题描述
这不是重复的问题.我想在由C#编写的电报机器人中使用html代码.我在SO中搜索,但未找到任何答案.怎么做?我使用了TelegramBotSharp.这是与我所解释的部分有关的代码:
This is not a duplicated question. I want to use html codes in my telegram bot that is written by c#. I searched in SO but I did not find any answer. How to do that? I used 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.
标签不能嵌套.
所有<,>和&不属于标记或HTML实体一部分的符号必须替换为相应的HTML实体(<带有& lt ;、>带有& gt;和&带有& amp;).
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实体均受支持.
All numerical HTML entities are supported.
该API当前仅支持以下命名的HTML实体:& lt ;、& gt ;、& amp;和& quot ..
The API currently supports only the following named HTML entities: <, >, & and ".
这篇关于在Telegram机器人中使用HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!