From 3ba0c9b4c6b8ae3bbdeca5752937686cb731ea13 Mon Sep 17 00:00:00 2001 From: Ashish D'Souza Date: Sun, 19 Nov 2023 05:21:27 -0600 Subject: [PATCH] Another bugfix --- ntfy_router/src/config.yaml | 11 +++++------ ntfy_router/src/rabbitmq_publisher.py | 2 +- ntfy_router/src/router.py | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ntfy_router/src/config.yaml b/ntfy_router/src/config.yaml index 383afff..a63e73e 100644 --- a/ntfy_router/src/config.yaml +++ b/ntfy_router/src/config.yaml @@ -1,10 +1,4 @@ notification: - test2: - system: - title: '(?<=\[).+(?=\])' - message: - title: '^.+(?=\s\[)' - message: '[^\n]+$' jenkins: system: title: '.*' @@ -16,6 +10,11 @@ notification: message: title: '^.+(?=\s\[)' message: '[^\n]+$' + Dsatp58_alerts: + system: + title: '(?<=\s)[\w.]+' + message: + message: '[^\n]+(?=\n---------)' call: call_ashish: caller: diff --git a/ntfy_router/src/rabbitmq_publisher.py b/ntfy_router/src/rabbitmq_publisher.py index 3c0cc12..caf4b1e 100644 --- a/ntfy_router/src/rabbitmq_publisher.py +++ b/ntfy_router/src/rabbitmq_publisher.py @@ -37,7 +37,7 @@ class RabbitMQPublisher: def send_notification(self, system: str, user: str, priority: str, message: str) -> None: self._publish(f'notification.{system}.{user}.{priority}', message) - def send_call() -> None: + def send_call(self, caller: str, user: str, message: str) -> None: self._publish(f'call.{caller}.{user}', json.dumps({ 'ringtone': { 'filename': 'Magic.mp3', diff --git a/ntfy_router/src/router.py b/ntfy_router/src/router.py index 363e1f9..133ea5c 100644 --- a/ntfy_router/src/router.py +++ b/ntfy_router/src/router.py @@ -45,11 +45,11 @@ class NtfyRouter: def route_message(self, topic: str, title: str, message: str): if topic in self._formatters['notification']: - notification_args = {notification_arg: self._formatters['notification'][topic][call_arg](topic=topic, title=title, message=message) for notification_arg in self._formatters['notification'][topic]} - self._send_notification(user='ashish', priority='high', **notification_args) + notification_args = {notification_arg: self._formatters['notification'][topic][notification_arg](topic=topic, title=title, message=message) for notification_arg in self._formatters['notification'][topic]} + self._rabbitmq_publisher.send_notification(user='ashish', priority='high', **notification_args) elif topic in self._call_topics: call_args = {call_arg: self._formatters['call'][topic][call_arg](topic=topic, title=title, message=message) for call_arg in self._formatters['call'][topic]} - self._send_call(user='ashish', **call_args) + self._rabbitmq_publisher.send_call(user='ashish', **call_args) async def start(self, rabbitmq_host: str, rabbitmq_port: int): self._ntfy_subscriber = NtfySubscriber([topic for message_type in self._formatters for topic in self._formatters[message_type]])