我想制作类似“一个按钮,当用户按下此按钮时,他会出现一个问题:你想与机器人分享你的联系方式吗?”我想在 bash 脚本中使用 curl:
我尝试这样,但它不起作用
#!/bin/bash
clear
token=""
old=$(curl -s "https://api.telegram.org/bot$token/getUpdates" | awk 'END{print}' | sed -n -e 's/^.*"date"://p' | cut -d ',' -f1)
while true; do
new=$(curl -s "https://api.telegram.org/bot$token/getUpdates" | awk 'END{print}')
if [[ "$new" =~ \"chat\"\:\{\"id\"\:([\-0-9]+)\, ]]; then
CHATID=${BASH_REMATCH[1]};
fi
if [[ "$new" =~ \"date\"\:([0-9]+)\, ]]; then
DATE=${BASH_REMATCH[1]};
fi
TEXT=$(echo "$new" | sed -n -e 's/^.*"text":"//p' | cut -d '"' -f1)
if ! [ "$DATE" = "$old" ]; then
echo "text: $TEXT, from: $USERNAME, id: $CHATID"
if [ "$TEXT" = "/start" ]; then
curl "https://api.telegram.org/bot$token/KeyboardButton?chat_id=$CHATID&text=flase&request_contact=true"
fi
old="$DATE"
fi
done
错误代码是:
{"ok":false,"error_code":404,"description":"Not Found"}%
我尝试这样,但它现在正在工作我怎样才能以正确的方式做到这一点?