forked from henrytriplette/penplotter-webserver
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotification.py
More file actions
executable file
·25 lines (21 loc) · 792 Bytes
/
notification.py
File metadata and controls
executable file
·25 lines (21 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import configparser
import requests
# Read Configuration
config = configparser.ConfigParser()
config.read('config.ini')
TELEGRAM_TOKEN = False
if (config.has_option('telegram', 'telegram_token')):
TELEGRAM_TOKEN = config['telegram']['telegram_token']
TELEGRAM_CHAT_ID = False
if (config.has_option('telegram', 'telegram_chatid')):
TELEGRAM_CHAT_ID = config['telegram']['telegram_chatid']
def telegram_sendNotification(notification):
if ( TELEGRAM_TOKEN and TELEGRAM_CHAT_ID ):
payload = {
'chat_id': TELEGRAM_CHAT_ID,
'text': notification,
'parse_mode': 'HTML'
}
return requests.post("https://api.telegram.org/bot{token}/sendMessage".format(token=TELEGRAM_TOKEN),data=payload).content
else:
return False