Skip to content

Instantly share code, notes, and snippets.

@lucarin91
Last active November 3, 2018 16:50
Show Gist options
  • Save lucarin91/ab5dca257e9560c087b8ff238ae544f4 to your computer and use it in GitHub Desktop.
Save lucarin91/ab5dca257e9560c087b8ff238ae544f4 to your computer and use it in GitHub Desktop.
Send a telegram message when something happens on a remote server
#!/bin/sh
###
# Send message to your telegram chat when something happens to a remote server.
# Before use the sript update the TOKEN and CHAT_ID variable with your data.
#
# Usage:
# tsend 'ALL DONE!'
# cat myfile.txt | tsend
#
# license: MIT
# created-by: lucarin91
###
TOKEN=671384880:AAHl9elaskdjlaksdjalksjdddbsVrw0
CHAT_ID=234444
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
MESSAGE=$@
if [ -z "$MESSAGE" ] ; then
read MESSAGE > /dev/null
fi
curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MESSAGE" > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment