- Crea un bot
- Invia un messaggio al nuovo bot
- Questo comando richiede gli ultimi messaggi da processare del Bot e permette di estrarre l'ID dell'utente.
curl -s https://api.telegram.org/bot$BOT_TOKEN/getUpdates | jq .result[].message.chat.id - Avvia il seguente scirpt dopo aver impostato tutti i parametri
Last active
September 18, 2020 14:36
-
-
Save aziis98/c3928433ed144b0941ef046ace88c85f to your computer and use it in GitHub Desktop.
Controlla un sito per degli aggiornamenti
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
| #!/bin/bash | |
| BOT_TOKEN= | |
| BUFFER_FILE=page.tmp | |
| CHECK_WAIT=15m | |
| TELEGRAM_USER_ID= | |
| URL="<url>" | |
| curl -s $URL -o $BUFFER_FILE | |
| while true; do | |
| echo -e "[`date +"%x %T"`] Checking the given URL..." | |
| if ! cmp -s $BUFFER_FILE <(curl -s $URL); then | |
| echo -e "[`date +"%x %T"`] Difference found, aborting...!" | |
| # Custom Action | |
| curl -X POST \ | |
| -H 'Content-Type: application/json' \ | |
| -d '{"chat_id": "'"$TELEGRAM_USER_ID"'", "text": "The file '"$URL"' has changed"}' \ | |
| https://api.telegram.org/bot$BOT_TOKEN/sendMessage | |
| exit 0 | |
| fi | |
| echo -e "[`date +"%x %T"`] Sleeping for a bit..." | |
| sleep $CHECK_WAIT | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment