Newline for caption in Telegram Bot Api Library (.Net)

Viewed 2835

I use Telegram Bot Api Library (link) (ver 13.0.1.0) in my Asp.Net project.

I use under code to send image with caption to my channel.

var sb = new StringBuilder();
sb.AppendLine("line1 ");
sb.AppendLine("line2 ");
sb.AppendLine("line3 ");

bot.SendPhotoAsync("@" + channel.Name, fileToSend, sb.ToString(), false, 0);

But my problem is that my newline don't show in output

enter image description here

how can solve this problem and show new line correctly in output?

[Solved]

this is the bug of this library and with upgrade to 13.2.0 the problem solved.

3 Answers

using '\n' is possible :

string a = "First Line \n Second Line \n Third Line";

using "\n" and HttpUtility.UrlEncode(YourText) this is best way for send text as text or caption if you want to put (hastag #)inside your text or caption

    string TextCaption = "First Line \n Second Line \n Third Line \n....";
    bot.SendPhotoAsync("@" + channel.Name, fileToSend, HttpUtility.UrlEncode(TextCaption ), false, 0);

not when using .SendTextMessageAsync();

But OP's original solution using StringBuilder() and .appendLine() worked perfectly for me. Much appreciated...had looked for a similar solution for long time.

Related