Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
A-Programmer opened this issue Oct 3, 2016 · 3 comments

Comments

@A-Programmer
Copy link

A-Programmer commented Oct 3, 2016

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

@MrRoundRobin
Copy link
Member

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/"&gt;inline URL</a>
<code>inline fixed-width code</code>
<pre>pre-formatted fixed-width code block</pre>

@omegalogs4
Copy link

omegalogs4 commented Jun 13, 2017

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

@Coderwill
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants