-
Notifications
You must be signed in to change notification settings - Fork 0
/
pushover.py
32 lines (26 loc) · 899 Bytes
/
pushover.py
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
26
27
28
29
30
import requests
import json
class pushover:
user = ''
application = ''
s = requests.session()
header = {'Content-Type': "application/json"}
def __init__(self, user, application):
self.user = user
self.application = application
def push(self, message):
session = self.s
dict_payload = {
"token": self.application,
"user": self.user,
"message": message}
print(message)
print(json.dumps(dict_payload))
resp = session.post('https://api.pushover.net/1/messages.json', headers=self.header, data=json.dumps(dict_payload))
dict_resp = resp.json()
if dict_resp["status"] == 1:
print(dict_resp)
print('Push message {} success'.format(message))
else:
print(dict_resp)
print('Push message {} failed'.format(message))