Skip to content

Instantly share code, notes, and snippets.

@a-toms
Created March 21, 2024 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a-toms/9450829b0a6be1ceeb7016e898fa7fc9 to your computer and use it in GitHub Desktop.
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
# 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