Skip to content

Commit 0c398a1

Browse files
committed
update alert message format
1 parent eacd508 commit 0c398a1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

modules/alert_bot.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def __init__(self, ton, local, *args, **kwargs):
115115
self.inited = False
116116
self.hostname = None
117117
self.ip = None
118+
self.adnl = None
118119
self.token = None
119120
self.chat_id = None
120121
self.last_db_check = 0
@@ -141,16 +142,19 @@ def send_alert(self, alert_name: str, *args, **kwargs):
141142
alert = ALERTS.get(alert_name)
142143
if alert is None:
143144
raise Exception(f"Alert {alert_name} not found")
144-
text = f'''
145-
❗️ <b>MyTonCtrl Alert {alert_name}</b> ❗️
145+
alert_name_readable = alert_name.replace('_', ' ').title()
146+
text = '🆘' if alert.severity != 'info' else ''
147+
text += f'''
148+
️ <b>Node {self.hostname}: {alert_name_readable} </b>
149+
150+
{alert.text.format(*args, **kwargs)}
146151
147152
Hostname: <code>{self.hostname}</code>
148153
Node IP: <code>{self.ip}</code>
154+
ADNL: <code>{self.adnl}</code>
149155
Time: <code>{time_}</code> (<code>{int(time.time())}</code>)
156+
Alert name: <code>{alert_name}</code>
150157
Severity: <code>{alert.severity}</code>
151-
152-
Alert text:
153-
<blockquote> {alert.text.format(*args, **kwargs)} </blockquote>
154158
'''
155159
if time.time() - last_sent > alert.timeout:
156160
self.send_message(text, alert.severity == "info") # send info alerts without sound
@@ -174,6 +178,8 @@ def init(self):
174178
from modules.validator import ValidatorModule
175179
self.validator_module = ValidatorModule(self.ton, self.local)
176180
self.hostname = get_hostname()
181+
adnl = self.ton.GetAdnlAddr()
182+
self.adnl = adnl[:4] + '...' + adnl[-4:]
177183
self.ip = self.ton.get_node_ip()
178184
self.set_global_vars()
179185
init_alerts()

0 commit comments

Comments
 (0)