This repository has been archived on 2021-09-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
TakeMedicineLaBot/bot.sh
2018-05-08 00:34:44 +08:00

51 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
token=$1
user=$2
# 傳送訊息
function sendMessage {
curl "https://api.telegram.org/bot$token/sendMessage?chat_id=$user&text=$1$2"
}
# 傳送照片
function sendPhoto {
curl "https://api.telegram.org/bot$token/sendPhoto" \
--header 'content-type: application/json' \
--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"
}
# 主程式
while true; do
# 早上 9 點ㄘ吃黃色藥
if [ "$(date "+%H:%M")" == "09:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendPhoto "https://i.imgur.com/mfAL4SC.jpg" "吃這顆~" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃過了", "callback_data": "1"}, {"text": "😢等等吃", "callback_data": "2"}]]}'
sleep 1m
fi
# 下午 1 點ㄘ吃黃色藥
if [ "$(date "+%H:%M")" == "13:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendPhoto "https://i.imgur.com/mfAL4SC.jpg" "吃這顆~" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃過了", "callback_data": "1"}, {"text": "😢等等吃", "callback_data": "2"}]]}'
sleep 1m
fi
# 晚上 6 點ㄘ吃黃色藥
if [ "$(date "+%H:%M")" == "18:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendPhoto "https://i.imgur.com/mfAL4SC.jpg" "吃這顆~" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃過了", "callback_data": "1"}, {"text": "😢等等吃", "callback_data": "2"}]]}'
sleep 1m
fi
# 晚上 11 點ㄘ吃白色藥
if [ "$(date "+%H:%M")" == "23:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendPhoto "https://i.imgur.com/8k7dXHM.jpg" "吃這顆~" ', "reply_markup": {"inline_keyboard": [[{"text": "😊吃過了", "callback_data": "1"}, {"text": "😢等等吃", "callback_data": "2"}]]}'
sleep 1m
fi
sleep 10s
done