From 19d42fc1af8cdb645a8d1fe86ea3fd9f88821689 Mon Sep 17 00:00:00 2001 From: HgO Date: Mon, 11 Jul 2022 23:43:27 +0200 Subject: [PATCH] don't send message for nothing --- matrix_alertbot/command.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/matrix_alertbot/command.py b/matrix_alertbot/command.py index f21a98c..8560c77 100644 --- a/matrix_alertbot/command.py +++ b/matrix_alertbot/command.py @@ -126,11 +126,12 @@ class Command: f"Sorry, I couldn't find {count_alert_not_found} alerts, and thus I couldn't acknowledge them.", ) - await send_text_to_room( - self.client, - self.room.room_id, - f"Created {count_created_silences} silences with a duration of {duration}.", - ) + if count_created_silences > 0: + await send_text_to_room( + self.client, + self.room.room_id, + f"Created {count_created_silences} silences with a duration of {duration}.", + ) async def _unack(self) -> None: """Delete an alert's acknowledgement of an alert and remove corresponding silence in Alertmanager""" @@ -179,11 +180,12 @@ class Command: f"Sorry, I couldn't find {count_alert_not_found} alerts, and thus I couldn't unacknowledge them.", ) - await send_text_to_room( - self.client, - self.room.room_id, - f"Removed {count_removed_silences} silences.", - ) + if count_removed_silences > 0: + await send_text_to_room( + self.client, + self.room.room_id, + f"Removed {count_removed_silences} silences.", + ) async def _show_help(self) -> None: """Show the help text"""