-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification_pusher.py
68 lines (54 loc) · 2.88 KB
/
notification_pusher.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from winotify import Notification, audio
from pathlib import Path
RES_DIRECTORY = Path(__file__).parent.resolve()
RES_DIRECTORY = RES_DIRECTORY / "res"
APP_ID = "Syosetu notifier"
novels_url = "https://ncode.syosetu.com/"
def new_chapter_notification(author, title, ncode):
toast = Notification(app_id=APP_ID,
title=f"New chapter for: {title}",
msg=f"{author} has added a new chapter for {title}",
icon=str(RES_DIRECTORY.joinpath("bookmark-book.png").absolute()))
toast.set_audio(audio.Default, loop=False)
# Using uppercase n-codes in URL results in a redirect page despite that format being used by the API
toast.add_actions(label="Go to novel's homepage",
launch=f"https://ncode.syosetu.com/{ncode.lower()}/")
toast.show()
def novel_modified_notification(author, title, ncode):
toast = Notification(app_id=APP_ID,
title=f"Novel modified: {title}",
msg=f"{author} has made modifications to {title}",
icon=str(RES_DIRECTORY.joinpath("edit-pencil.png").absolute()))
toast.set_audio(audio.Default, loop=False)
# Using uppercase n-codes in URL results in a redirect page despite that format being used by the API
toast.add_actions(label="Go to novel's homepage",
launch=f"https://ncode.syosetu.com/{ncode.lower()}/")
toast.show()
def history_file_not_found_notification():
toast = Notification(app_id=APP_ID,
title="History file missing",
msg="History file could not be found despite previously being defined",
icon=str(RES_DIRECTORY.joinpath("file-not-found.png").absolute()))
toast.set_audio(audio.Default, loop=False)
toast.show()
def config_file_not_found_notification():
toast = Notification(app_id=APP_ID,
title="Config file missing or corrupted",
msg="The config file is either missing or has incorrect values.",
icon=str(RES_DIRECTORY.joinpath("file-not-found.png").absolute()))
toast.set_audio(audio.Default, loop=False)
toast.show()
def custom_error_notification(title, msg):
toast = Notification(app_id=APP_ID,
title=title,
msg=msg,
icon=str(RES_DIRECTORY.joinpath("cloud-xmark.png").absolute()))
toast.set_audio(audio.Default, loop=False)
toast.show()
def no_updates_notification():
toast = Notification(app_id=APP_ID,
title="No novel updates found",
msg="No new novel information found during scheduled syosetu API check",
icon=str(RES_DIRECTORY.joinpath("bookmark-book.png").absolute()))
toast.set_audio(audio.Default, loop=False)
toast.show()