-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (38 loc) · 1.3 KB
/
main.py
File metadata and controls
53 lines (38 loc) · 1.3 KB
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
from notifiers.notifier import Notifier
from notifiers.sms_decorator import SMSDecorator
from notifiers.slack_decorator import SlackDecorator
from notifiers.facebook_decorator import FacebookDecorator
def get_user_input():
return (
input(
"Select additional notification channels to enable (sms, facebook, slack). Choose done to stop:"
)
.strip()
.lower()
)
def get_notification_choices():
selected_notifications = []
choice = get_user_input()
while choice != "done":
if choice in ["sms", "facebook", "slack"]:
selected_notifications.append(choice)
else:
print(f"Unknown option: {choice}")
choice = get_user_input()
return selected_notifications
def build_notifier(choices: list[str]) -> Notifier:
notifier: Notifier = Notifier()
for choice in choices:
if choice == "sms":
notifier = SMSDecorator(notifier)
elif choice == "slack":
notifier = SlackDecorator(notifier)
elif choice == "facebook":
notifier = FacebookDecorator(notifier)
return notifier
def main():
choices = get_notification_choices()
notifier = build_notifier(choices)
notifier.send_notification("Hello World!")
if __name__ == "__main__":
main()