【问题标题】:How to send a message with button in shell to Telegram bot?如何在 shell 中向 Telegram bot 发送带有按钮的消息?
【发布时间】:2022-02-25 22:39:38
【问题描述】:

我正在使用它并且有效。但是如何把一个按钮自爆消息?我试了很多次还是不明白。

对不起,我忘了告诉它是关于 Telegram bot api 的。我想发送一个按钮爆炸的消息。

function sendadmin(){
    if [ "$admin_id" -ne "$chat_id" ]; then
        curl -s \
        -d parse_mode="MarkdownV2" \
        -d text="$stext" \
        -d chat_id="$admin_id" \
        -d -sendChatAction="videos" \
        -d reply_markup="" \
        https://api.telegram.org/bot$bot_token/sendMessage
    fi
}

stext="||Hello darling||"
sendadmin

我尝试了this 的解决方案。它返回Bad Request: can't parse reply keyboard markup JSON object 错误。

【问题讨论】:

标签: bash shell telegram-bot


【解决方案1】:
reply=$(cat <<-EOF
{
    "inline_keyboard": [
        [
            {
                "text": "Button1",
                "callback_data": "lt"
            },
            {
                "text": "Button1",
                "callback_data": "rt"
            }
        ],
        [
            {
                "text": "Button3",
                "callback_data": "ls"
            }
        ]
    ]
}
EOF
)

使用 car &lt;&lt;EOF EOF 将该 json 格式赋予变量,然后像 reply_markup="$reply" 一样使用它。我是这样发现的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-09-21
    • 1970-01-01
    • 2018-05-17
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多