skip to Main Content

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


  1. using ‘n’ is possible :

    string a = "First Line n Second Line n Third Line";
    
    Login or Signup to reply.
  2. 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);
    
    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search