Created
February 7, 2019 00:11
-
-
Save amirulabu/33a4c82f3a0f1b27a6a34e5847cb7ddf to your computer and use it in GitHub Desktop.
A simple telegram bot that notifies whether some website is up or not. Install requests library, setup crontab and your done!
This file contains 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
#!/usr/bin/python3 | |
import requests | |
r = requests.get('<your website>') | |
if r.status_code is 200: | |
r = requests.post( | |
'https://api.telegram.org/bot<your telegram bot token>/sendMessage', | |
data = {'chat_id':<your telegram chat id>,'text':'Good news, Status code for %s is %s' % (r.url,r.status_code), | |
'disable_notification': True} | |
) | |
else: | |
r = requests.post( | |
'https://api.telegram.org/bot<your telegram bot token>/sendMessage', | |
data = {'chat_id':<your telegram chat id>,'text':'Bad news, Status code for %s is %s' % (r.url,r.status_code)} | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment