-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnotificationservice.py
35 lines (29 loc) · 1.12 KB
/
notificationservice.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
from textnotifier import TextNotifier
from discordnotifier import DiscordNotifier
from datamodels import APIConfig
class NotificationService:
"""
Set silent=True to stop the annoying texts for debug
"""
def __init__(self, api_config: APIConfig, user_config: dict, silent: bool):
notifiers = []
if user_config["channels"]["sms"]["enable"]:
phone_number = user_config["channels"]["sms"]["phone_number"]
text_notifier = TextNotifier(
api_config,
phone_number,
user_config["contract_address"],
user_config["collection_name"] if "collection_name" in user_config else None,
silent=silent
)
notifiers.append(text_notifier)
if user_config["channels"]["discord"]["enable"]:
discord_notifier = DiscordNotifier(
api_config,
user_config
)
notifiers.append(discord_notifier)
self.notifiers = notifiers
def notify(self, raw_data):
for notifier in self.notifiers:
notifier.notify(raw_data)