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-07 00:51:59 +08:00

43 lines
1.0 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"
}
# 傳送照片
function sendPhoto {
curl "https://api.telegram.org/bot$token/sendPhoto?chat_id=$user&photo=$1&caption=$2"
}
# 傳送貼圖
function sendSticker {
curl "https://api.telegram.org/bot$token/sendSticker?chat_id=$user&sticker=$1"
}
# 主程式
while true; do
# 早上 9 點ㄘ吃黃色藥
if [ "$(date "+%H:%M")" == "09:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendMessage "這次吃這顆 https://i.imgur.com/JA0tQPV.jpg"
sleep 1m
fi
# 晚上 6 點ㄘ吃黃色藥
if [ "$(date "+%H:%M")" == "18:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendMessage "這次吃這顆 https://i.imgur.com/JA0tQPV.jpg"
sleep 1m
fi
# 晚上 11 點ㄘ吃白色藥
if [ "$(date "+%H:%M")" == "23:00" ]; then
sendSticker "CAADAQADWAQAAvoPCRQhPbMdi-bNqQI"
sendMessage "這次吃這顆 https://i.imgur.com/hVZGmEH.jpg"
sleep 1m
fi
sleep 10s
done