-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotification.py
36 lines (31 loc) · 1.11 KB
/
notification.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
import traceback
from pynotifier import Notification
from GmailNotificationService.gmail import ReturnMessagesAsGmailModels
from GmailNotificationService.model import GmailModel
def CreateNewGmailNotification(subject: str, sender: str, content: str):
return Notification(
title= subject+ ' BY ' + sender,
description=content[0:30] +"....",
icon_path='./utils/gmail.png', # On Windows .ico is required, on Linux - .png
duration=10, # Duration in seconds
urgency='critical'
).send()
def InitiatePushNotification():
messages_array = ReturnMessagesAsGmailModels()
print(messages_array)
try:
message = messages_array.pop()
if (isinstance(message, GmailModel)):
CreateNewGmailNotification(message.subject, message.sender, message.snippet)
except Exception as err:
print(traceback.print_exception(err))
"""
for message in messages_array:
if isinstance(message, GmailModel):
try:
CreateNewGmailNotification(message.subject , message.sender, message.snippet)
except Exception as err:
print(traceback.print_exception(err))
else:
pass
"""