Update keyboard and Hello at startup

This commit is contained in:
2021-09-08 19:17:25 +08:00
parent 75faeab67f
commit f41496bb3c

15
bot.sh
View File

@ -15,11 +15,6 @@ function sendPhoto {
--data '{"chat_id": "'"$user"'", "photo": "'"$1"'", "caption": "'"$2"'"'"$3"'}' --data '{"chat_id": "'"$user"'", "photo": "'"$1"'", "caption": "'"$2"'"'"$3"'}'
} }
# 傳送貼圖
function sendSticker {
curl "https://api.telegram.org/bot$token/sendSticker?chat_id=$user&sticker=$1$2"
}
function getRandomPhoto { function getRandomPhoto {
declare -a PHOTO_URLS=( declare -a PHOTO_URLS=(
"https://imgur.com/p3Y0XU8.png" "https://imgur.com/p3Y0XU8.png"
@ -29,21 +24,19 @@ function getRandomPhoto {
echo ${PHOTO_URLS[RANDOM % ${#PHOTO_URLS[@]}]} echo ${PHOTO_URLS[RANDOM % ${#PHOTO_URLS[@]}]}
} }
sendMessage "你好,我會在你需要吃藥的時候提醒你哦~"
while true; do while true; do
# 早上 10 點 # 早上 10 點
if [ "$(date "+%H:%M")" == "10:00" ]; then if [ "$(date "+%H:%M")" == "10:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI" sendPhoto $(getRandomPhoto) "該吃藥囉~" ', "reply_markup": {"resize_keyboard": true, "keyboard": [[{"text": "😊吃了"}, {"text": "😢等等"}]]}'
sendPhoto $(getRandomPhoto) "吃了嗎~" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃了", "callback_data": "1"}, {"text": "😢等等", "callback_data": "2"}]]}'
fi fi
# 晚上 7 點半 # 晚上 7 點半
if [ "$(date "+%H:%M")" == "19:30" ]; then if [ "$(date "+%H:%M")" == "19:30" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI" sendPhoto $(getRandomPhoto) "該吃藥囉~" ', "reply_markup": {"resize_keyboard": true, "keyboard": [[{"text": "😊吃了"}, {"text": "😢等等"}]]}'
sendPhoto $(getRandomPhoto) "吃了嗎~" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃了", "callback_data": "1"}, {"text": "😢等等", "callback_data": "2"}]]}'
fi fi
# 晚上 11 點半 # 晚上 11 點半
if [ "$(date "+%H:%M")" == "23:30" ]; then if [ "$(date "+%H:%M")" == "23:30" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI" sendPhoto $(getRandomPhoto) "該吃藥囉~" ', "reply_markup": {"resize_keyboard": true, "keyboard": [[{"text": "😊吃了"}, {"text": "😢等等"}]]}'
sendPhoto $(getRandomPhoto) "吃了嗎" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃了", "callback_data": "1"}, {"text": "😢等等", "callback_data": "2"}]]}'
fi fi
sleep 60 sleep 60
done done