Skip to content

Commit 68c459f

Browse files
committed
send info alerts without sound
1 parent 2ff3588 commit 68c459f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

modules/alert_bot.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,13 @@ def __init__(self, ton, local, *args, **kwargs):
9999
self.chat_id = None
100100
self.last_db_check = 0
101101

102-
def send_message(self, text: str):
102+
def send_message(self, text: str, silent: bool = False):
103103
if self.token is None:
104104
raise Exception("send_message error: token is not initialized")
105105
if self.chat_id is None:
106106
raise Exception("send_message error: chat_id is not initialized")
107107
request_url = f"https://api.telegram.org/bot{self.token}/sendMessage"
108-
data = {'chat_id': self.chat_id, 'text': text, 'parse_mode': 'HTML'}
108+
data = {'chat_id': self.chat_id, 'text': text, 'parse_mode': 'HTML', 'disable_notification': silent}
109109
response = requests.post(request_url, data=data, timeout=3)
110110
if response.status_code != 200:
111111
raise Exception(f"send_message error: {response.text}")
@@ -133,7 +133,7 @@ def send_alert(self, alert_name: str, *args, **kwargs):
133133
<blockquote> {alert.text.format(*args, **kwargs)} </blockquote>
134134
'''
135135
if time.time() - last_sent > alert.timeout:
136-
self.send_message(text)
136+
self.send_message(text, alert.severity == "info") # send info alerts without sound
137137
self.set_alert_sent(alert_name)
138138

139139
def set_global_vars(self):

0 commit comments

Comments
 (0)