Skip to content

Commit 6fdba7a

Browse files
committed
alert bot ux improves
1 parent 1f18ee2 commit 6fdba7a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

modules/alert_bot.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def init_alerts():
3030
ALERTS = {
3131
"low_wallet_balance": Alert(
3232
"low",
33-
"Validator's wallet balance is low",
33+
"Validator's wallet balance is less than 10 TON",
3434
"Validator's wallet {wallet} balance is less than 10 TON: {balance} TON.",
3535
18 * HOUR
3636
),
@@ -52,13 +52,13 @@ def init_alerts():
5252
),
5353
"low_efficiency": Alert(
5454
"high",
55-
"Validator had low efficiency in the validation round",
55+
"Validator had efficiency less than 90% in the validation round",
5656
"""Validator efficiency is less than 90%: <b>{efficiency}%</b>.""",
5757
VALIDATION_PERIOD // 3
5858
),
5959
"out_of_sync": Alert(
6060
"critical",
61-
"Validator had low efficiency in the round",
61+
"Node is out of sync on more than 20 sec",
6262
"Node is out of sync on more than 20 sec: <b>{sync} sec</b>.",
6363
300
6464
),
@@ -76,7 +76,7 @@ def init_alerts():
7676
),
7777
"zero_block_created": Alert(
7878
"critical",
79-
"Validator has not created any blocks in the last few hours",
79+
f"Validator has not created any blocks in the {int(VALIDATION_PERIOD // 3 // 3600)} hours",
8080
"Validator has not created any blocks in the last {hours} hours.",
8181
VALIDATION_PERIOD // 3
8282
),
@@ -101,18 +101,18 @@ def init_alerts():
101101
"stake_returned": Alert(
102102
"info",
103103
"Validator's stake has been returned (info alert with no sound)",
104-
"Validator's stake {stake} TON has been returned on address {address}. The reward amount is {reward} TON.",
104+
"Validator's stake {stake} TON has been returned on address <code>{address}</code>. The reward amount is {reward} TON.",
105105
60
106106
),
107107
"stake_not_returned": Alert(
108108
"high",
109109
"Validator's stake has not been returned",
110-
"Validator's stake has not been returned on address {address}.",
110+
"Validator's stake has not been returned on address <code>{address}.</code>",
111111
60
112112
),
113113
"voting": Alert(
114114
"high",
115-
"There is an active network proposal that has many votes but is not voted by the validator",
115+
"There is an active network proposal that has many votes (more than 50% of required) but is not voted by the validator",
116116
"Found proposals with hashes `{hashes}` that have significant amount of votes, but current validator didn't vote for them. Please check @tonstatus for more details.",
117117
VALIDATION_PERIOD
118118
),
@@ -166,6 +166,7 @@ def send_alert(self, alert_name: str, *args, **kwargs):
166166
Hostname: <code>{self.hostname}</code>
167167
Node IP: <code>{self.ip}</code>
168168
ADNL: <code>{self.adnl}</code>
169+
Wallet: <code>{self.wallet}</code>
169170
Time: <code>{time_}</code> (<code>{int(time.time())}</code>)
170171
Alert name: <code>{alert_name}</code>
171172
Severity: <code>{alert.severity}</code>
@@ -193,7 +194,8 @@ def init(self):
193194
self.validator_module = ValidatorModule(self.ton, self.local)
194195
self.hostname = get_hostname()
195196
adnl = self.ton.GetAdnlAddr()
196-
self.adnl = adnl[:4] + '...' + adnl[-4:]
197+
self.adnl = adnl
198+
self.wallet = self.ton.GetValidatorWallet().addrB64
197199
self.ip = self.ton.get_node_ip()
198200
self.set_global_vars()
199201
init_alerts()
@@ -251,8 +253,8 @@ def test_alert(self, args):
251253
self.send_message('Test alert')
252254

253255
def send_welcome_message(self):
254-
message = """
255-
👋 Hello, this is alert bot.
256+
message = f"""
257+
This is alert bot. You have connected validator with ADNL <code>{self.ton.GetAdnlAddr()}</code>.
256258
257259
I don't process any commands, I only send notifications.
258260
@@ -263,9 +265,9 @@ def send_welcome_message(self):
263265
message += f"- {alert.description}\n"
264266

265267
message += """
266-
If you want, you can disable some notifications in mytonctrl by the <a href="https://docs.ton.org/v3/guidelines/nodes/maintenance-guidelines/mytonctrl-private-alerting#endisbling-alerts"> instruction </a>.
268+
If you want, you can disable some notifications in mytonctrl by the <a href="https://docs.ton.org/v3/guidelines/nodes/maintenance-guidelines/mytonctrl-private-alerting#endisbling-alerts"> instruction</a>.
267269
268-
Full bot documentation <a href="https://docs.ton.org/v3/guidelines/nodes/maintenance-guidelines/mytonctrl-private-alerting"> here</a>.
270+
Full bot documentation <a href="https://docs.ton.org/v3/guidelines/nodes/maintenance-guidelines/mytonctrl-private-alerting">here</a>.
269271
"""
270272
self.send_message(text=message, disable_web_page_preview=True)
271273

@@ -280,7 +282,7 @@ def on_set_chat_id(self, chat_id):
280282
return True
281283
except Exception as e:
282284
self.local.add_log(f"Error while sending welcome message: {e}", "error")
283-
self.local.add_log(f"If you want the bot to write to a multi-person chat group, make sure the bot is added to that chat group and has admin rights. If it is not - do it and run the command `set ChatId <ChatId>` again.", "info")
285+
self.local.add_log(f"If you want the bot to write to a multi-person chat group, make sure the bot is added to that chat group. If it is not - do it and run the command `set ChatId <ChatId>` again.", "info")
284286
return False
285287

286288
def check_db_usage(self):

0 commit comments

Comments
 (0)