如何使用 shell 中的按钮向 Telegram 机器人发送消息?
How to send a message with button in shell to Telegram bot?
我正在使用它并且可以正常工作。但是如何放置一个按钮来触发消息呢?试了很多还是没搞清楚
抱歉,我忘了告诉它是关于 Telegram 机器人的 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
我尝试了 的解决方案。这是 return Bad Request: can't parse reply keyboard markup JSON object
错误。
reply=$(cat <<-EOF
{
"inline_keyboard": [
[
{
"text": "Button1",
"callback_data": "lt"
},
{
"text": "Button1",
"callback_data": "rt"
}
],
[
{
"text": "Button3",
"callback_data": "ls"
}
]
]
}
EOF
)
使用 car <<EOF EOF
将 json 格式赋予变量,然后像 reply_markup="$reply"
一样使用它。我是这样知道的。
我正在使用它并且可以正常工作。但是如何放置一个按钮来触发消息呢?试了很多还是没搞清楚
抱歉,我忘了告诉它是关于 Telegram 机器人的 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
我尝试了 Bad Request: can't parse reply keyboard markup JSON object
错误。
reply=$(cat <<-EOF
{
"inline_keyboard": [
[
{
"text": "Button1",
"callback_data": "lt"
},
{
"text": "Button1",
"callback_data": "rt"
}
],
[
{
"text": "Button3",
"callback_data": "ls"
}
]
]
}
EOF
)
使用 car <<EOF EOF
将 json 格式赋予变量,然后像 reply_markup="$reply"
一样使用它。我是这样知道的。