im trying to send telegram messages from Linux bash using curl. My current problem is that i am unable to send line breaks in the message.
My code is something like this:
msg="<a href=\"${img}\"> </a><b>${title}</b><a href=\"${lnk}\">MORE INFO</a>"
curl --data chat_id=$chatID --data-urlencode "text=${msg}" "https://api.telegram.org/bot${apik}/sendMessage?parse_mode=HTML"
i tried with </br> \n %0D%0A, and none work.
Maybe try setting your $msg variable as a heredoc:
#!/bin/bash
img="one"
title="two"
lnk="three"
read -r -d '' msg <<EOT
<a href="${img}"></a>
<b>"${title}"</b>
<a href="${lnk}">MORE INFO</a>
EOT
curl --data chat_id="$chatID" --data-urlencode "text=${msg}" "https://api.telegram.org/bot${apik}/sendMessage?parse_mode=HTML"
↳ Wikipedia : Here Documents
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With