Using HTML in Telegram bot

梦想与她 提交于 2020-07-20 08:29:29

问题


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);
}

回答1:


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 &lt;, > with &gt; and & with &amp;).

All numerical HTML entities are supported.

The API currently supports only the following named HTML entities: &lt;, &gt;, &amp; and &quot;.




回答2:


HTML mode

Pass HTML in the parse_mode field when using sendMessage.



来源:https://stackoverflow.com/questions/49706034/using-html-in-telegram-bot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!