Created
March 21, 2024 13:40
-
-
Save a-toms/9450829b0a6be1ceeb7016e898fa7fc9 to your computer and use it in GitHub Desktop.
Telegram bot notifications for HeyFocus when starting, stopping, pausing, and resuming pomodoros
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Started tomato. | |
MINUTES_REMAINING=$(awk "BEGIN {print int($FOCUS_SESSION_INTENDED_DURATION/60)}") # Bash doesn't support floating point arithmetic, so we use awk to round down to the nearest integer | |
MESSAGE="π *Tomato started* π \n Tomato due to finish at $FOCUS_SESSION_END_DATE ($MINUTES_REMAINING minutes left).\n\n" | |
curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"chat_id\": \"<YOUR_CHAT_ID>\", \"text\": \"$MESSAGE\", \"disable_notification\": false, \"parse_mode\": \"Markdown\"}" \ | |
https://api.telegram.org/bot<BOT_API_TOKEN>/sendMessage | |
# Completed tomato. | |
DURATION_MINUTES=$(awk "BEGIN {print int($FOCUS_SESSION_DURATION/60)}") # Bash doesn't support floating point arithmetic, so we use awk to round down to the nearest integer | |
MESSAGE="π *Tomato finished! * π \n. Duration was: $DURATION_MINUTES" | |
curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"chat_id\": \"<YOUR_CHAT_ID>\", \"text\": \"$MESSAGE\", \"disable_notification\": false, \"parse_mode\": \"Markdown\"}" \ | |
https://api.telegram.org/bot<BOT_API_TOKEN>/sendMessage | |
# Paused tomato. | |
MESSAGE="βΈοΈ *Tomato paused* π " | |
curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"chat_id\": \"<YOUR_CHAT_ID>\", \"text\": \"$MESSAGE\", \"disable_notification\": false, \"parse_mode\": \"Markdown\"}" \ | |
https://api.telegram.org/bot<BOT_API_TOKEN>/sendMessage | |
# Resumed tomato. | |
MESSAGE="βΆοΈ *Tomato resumed* π " | |
curl -X POST \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"chat_id\": \"<YOUR_CHAT_ID>\", \"text\": \"$MESSAGE\", \"disable_notification\": false, \"parse_mode\": \"Markdown\"}" \ | |
https://api.telegram.org/bot<BOT_API_TOKEN>/sendMessage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment