在 telegram 按钮 bash 中发送自定义 URL

Jho*_*man 4 bash curl telegram telegram-bot

我用 bash 编写了这段代码,用于使用电报机器人发送消息,现在我需要使用自定义 URL 发送消息。

这是我的实际代码:

sendTelegram() {
        curl -s \
        -X POST \
        https://api.telegram.org/bot$apiToken/sendMessage \
        -d text="$download" \
        -d chat_id=$userChatId
}
Run Code Online (Sandbox Code Playgroud)

如何在 URL 按钮中发送消息 $download,例如:

URL 按钮电报

Ciz*_*ita 8

您需要使用reply_markup中的inline_keyboard并发送带有JSON内容类型标头的POST请求:

curl -d '{"chat_id":7455490, "text":"pruebax", "reply_markup": {"inline_keyboard": [[{"text":"LaResistencia.co", "url": "http://laresistencia.co"}]]} }' -H "Content-Type: application/json" -X POST https://api.telegram.org/bot$apiToken/sendMessage
Run Code Online (Sandbox Code Playgroud)

有关参数的更多信息,请查看 Telegram bot API inline_keyboard 部分: https: //core.telegram.org/bots/api#inlinekeyboardbutton

Telegram 机器人 bash inline_keyboard