Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Last active June 8, 2020 06:39
Show Gist options
  • Save HirbodBehnam/6c6b218645efe5087759ac2ce09bd7fc to your computer and use it in GitHub Desktop.
Save HirbodBehnam/6c6b218645efe5087759ac2ce09bd7fc to your computer and use it in GitHub Desktop.
A simple script to watch a url for changes
#!/bin/bash
URL="$1"
TOKEN="Telegram Bot Token"
CHAT_ID="Your Chat ID" # for example use @myidbot
temp_file=$(mktemp)
curl -o $temp_file "$URL"
sum=$(md5sum $temp_file)
while :
do
sleep 3600
curl -o $temp_file "$URL"
sum2=$(md5sum $temp_file)
if [[ "$sum" != "$sum2" ]]; then
curl -X POST -d text="$URL" -d chat_id=$CHAT_ID https://api.telegram.org/bot$TOKEN/sendMessage
rm $temp_file
exit
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment