Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 使用电报机器人向文本消息添加换行符_Linux_Bash_Telegram Bot - Fatal编程技术网

Linux 使用电报机器人向文本消息添加换行符

Linux 使用电报机器人向文本消息添加换行符,linux,bash,telegram-bot,Linux,Bash,Telegram Bot,我正在尝试使用curl从LinuxBash发送电报消息。我目前的问题是,我无法发送消息中的换行符 我的代码是这样的: msg="<a href=\"${img}\">&#160;</a><b>${title}</b><a href=\"${lnk}\">MORE INFO</a>" curl --data chat_id=$chatID --data-urlencode "text=${msg}" "https:/

我正在尝试使用curl从LinuxBash发送电报消息。我目前的问题是,我无法发送消息中的换行符

我的代码是这样的:

msg="<a href=\"${img}\">&#160;</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"
msg=“${title}”
curl--data chat_id=$chatID--data urlencode“text=${msg}”https://api.telegram.org/bot${apik}/sendMessage?parse_mode=HTML“

我尝试了

\n
%0D%0A
,但没有成功。

也许可以尝试将
$msg
变量设置为

#!/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"
#/bin/bash
img=“一”
title=“两个”
lnk=“三”

read-r-d''msg使用简单引号
msg='something'$variable'something'
@IporSircer使用简单引号作为HTML属性分隔符并在变量周围保留双引号不是更好吗?i、 e.
msg=”“
更多关于主题的信息。然而,我看到它支持
标记,其中空白将按原样显示,因此
中的
\n
应导致换行。我不知道电报的第一件事,所以我不知道它是否是处理这个问题的正确方法,但它可能是一个解决方案。它还可能导致其他样式的更改。