forked from WojtekK78/parkanizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparkanizer_notifiers.py
40 lines (33 loc) · 1002 Bytes
/
parkanizer_notifiers.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
31
32
33
34
35
36
37
38
39
40
from notifiers import get_notifier
from notifiers.exceptions import BadArguments
pushover = get_notifier("pushover")
gmail = get_notifier("gmail")
gmail.defaults
{
"subject": "Parkanizer notification",
"html": False,
}
def pushover_notify(message, title, token, user, device):
try:
r = pushover.notify(
message=message, title=title, token=token, user=user, device=device
)
except BadArguments as e:
print(f"Pushover failed\n{e}")
return
if r.status != "Success":
print(f"Pushover notification failed:\n{r.errors}")
def gmail_notify(message, title, to, username, password):
try:
r = gmail.notify(
to=to,
message=message,
subject=title,
username=username,
password=password,
)
except BadArguments as e:
print(f"Gmail failed\n{e}")
return
if r.status != "Success":
print(f"Gmail notification failed:\n{r.errors}")