Telegram.Bot.Examples icon indicating copy to clipboard operation
Telegram.Bot.Examples copied to clipboard

Add an Example for TelegramBotClient.SendTextMessageAsync Method (String, String, Boolean, Boolean, Int32, IReplyMarkup, ParseMode, CancellationToken)

Open A-Programmer opened this issue 10 years ago • 3 comments

Please add an example for TelegramBotClient.SendTextMessageAsync Method (String, String, Boolean, Boolean, Int32, IReplyMarkup, ParseMode, CancellationToken). I want to send Html content (just <br/> tag and <a> tag i need.) TODO (optional): Describe a specific scenario you would like to see addressed.

Help Topic: https://mrroundrobin.github.io/telegram.bot/html/M_Telegram_Bot_TelegramBotClient_SendTextMessageAsync_1.htm

A-Programmer avatar Oct 03 '16 14:10 A-Programmer

var reply = "<b>Hello</b>\n"
            + "<a href=\"https://www.google.de\">This is a link</a>\n"
            + "<code>and a little bit code</code>";

await Bot.SendTextMessageAsync(message.Chat.Id, reply, parseMode: ParseMode.Html);

be aware that you can't use all html tags: https://core.telegram.org/bots/api#html-style

<b>bold</b>, <strong>bold</strong> <i>italic</i>, <em>italic</em> <a href="http://www.example.com/">inline URL</a> <code>inline fixed-width code</code> <pre>pre-formatted fixed-width code block</pre>

MrRoundRobin avatar Oct 07 '16 00:10 MrRoundRobin

Hello Sir.. what to do if i want to send parameters in url??

i tried as
var reply = "Hello\n" + "<a href="..url?loginid=""+loginId+" > Click to login \n" + "and a little bit code"; await Bot.SendTextMessageAsync(chatId, reply, parseMode: ParseMode.Html);

but it is not appending that 'loginId' with url sometime it gives Exception as An exception of type 'Telegram.Bot.Exceptions.ApiRequestException' occurred in mscorlib.dll but was not handled in user code Additional information: Bad Request: can't parse entities in message text: Expected equal sign in declaration of attribute of the tag "a" at byte offset 38

var reply = "Hello\n <a href="...url?loginid= '" + loginId + "' "> This is a link"; this is not showing link

omegalogs4 avatar Jun 13 '17 09:06 omegalogs4

@omegalogs4 you can try with StringBuilder and send after StringBulider object in the message. it's working for me.

Coderwill avatar Sep 11 '17 09:09 Coderwill