I´m developing a telegram bot in c#.
Using the class TelegramBotClient
in Telegram.Bot
library.
I want to send a message with SendTextMessageAsync
using HTML option.
In the official documentation (https://core.telegram.org/bots/api#markdown-style) I can see this:
string texto = @"<b>bold</b>, <strong> bold </strong>" +
@"<i> italic </i>, <em> italic </em>" +
@"<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>";
Bot.SendTextMessageAsync(chatId: id_chat,
text: texto,
parseMode: ParseMode.HTML);
It works corretly but I want to use “New Lines” and “List”. I have seen them on telegram official notificacion like in this photo:
I have tried <br>, </br>, <br/>
… etc.
But I have get the
Telegram.Bot.Exceptions.ApiRequestException: ‘Bad Request: can’t parse entities: Unexpected end tag at byte offset 36
Does anyone know if it´s possible to do it?
Also if possible to link a telephone number?
2
Answers
If you read the next paragraph below the html-examples in the documentation, you can see that it says that
only the tags mentioned mentioned above are currently supported.
Therefore, I would suggest you use markdown, since there are no restrictions mentioned for this way of parsing. A linebreak in MD is achieved by either
two spaces
or<br/>
. A list in MD can be created by using*, + or -
in front of the list’s items, for more information refer to this documentation on MD for example.For the second part of your question, phone numbers get highlighted by the Telegram phone app automatically, but there is no such function for Desktop-clients and no built-in way in the API/libraries. Also, it only works for messages within the range of 0-200 characters, as stated here:
How to make phone number a link in Telegram Bot?
I am working with
PHP
and usingparse_mode=HTML
I had the same problem but solved with.