Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate new line character in telegram message?

Tags:

php

telegram

When I send the data I read from mysql database to telegram user, the user gets underline and etc instead of new line character. So this way I can't format message text correctly.

How can I format a telegram message that is a question with 4 or more possible answers?

What else is going to be changed that I don't expect? By the way I'm sending non-english characters.

$qsBody = $rowQuestion['body']; // This is what I read from database that contains some new line characters
$strReply = $qsBody;
$strSendMethod = "SendMessage?chat_id=$ChatId&text='$strReply'";
file_get_contents( BOT_TARGET_ADDRESS . $strSendMethod );
// The message received by user contains _ instead of new line.
like image 859
Stack crawler Avatar asked Oct 20 '22 04:10

Stack crawler


People also ask

How do I start a new line in Telegram chat?

On WhatsApp, Telegram desktop or web, you can use shift + enter for a newline.

How can I type multiple lines in telegram?

Put “\n” inside your string if you want a new line.

How many characters can a telegram message have?

Usage. To send a message: telegram-send "Hello, World!" There is a maximum message length of 4096 characters, larger messages will be automatically split up into smaller ones and sent separately.

How can I underline in telegram?

Telegram for iOS and Android: How to format your text For all options, launch the context menu (the three-dot icon on the right or top right on Android). Choose from the options Bold, Italic, Mono, Strikeout, Underline, Create Link, and Normal.


1 Answers

Well, it was very easy! I just had to encode message in url.

$qsBody = $rowQuestion['body']; // This is what I read from database that contains some new line characters
$strReply = $qsBody;
$strReply = urlencode($strReply ); // encode message
$strSendMethod = "SendMessage?chat_id=$ChatId&text='$strReply'";
file_get_contents( BOT_TARGET_ADDRESS . $strSendMethod );
// The message received by user contains _ instead of new line.
like image 66
Stack crawler Avatar answered Oct 21 '22 22:10

Stack crawler