Skip to content

Commit 99500eb

Browse files
authored
Merge pull request #434 from yungwine/bot-ux
Bot ux
2 parents dc480ed + dc7d068 commit 99500eb

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

modules/alert_bot.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def init_alerts():
3131
"low_wallet_balance": Alert(
3232
"low",
3333
"Validator's wallet balance is less than 10 TON",
34-
"Validator's wallet {wallet} balance is less than 10 TON: {balance} TON.",
34+
"Validator's wallet <code>{wallet}</code> balance is less than 10 TON: {balance} TON.",
3535
18 * HOUR
3636
),
3737
"db_usage_80": Alert(
@@ -165,8 +165,12 @@ def send_alert(self, alert_name: str, *args, **kwargs):
165165
166166
Hostname: <code>{self.hostname}</code>
167167
Node IP: <code>{self.ip}</code>
168-
ADNL: <code>{self.adnl}</code>
169-
Wallet: <code>{self.wallet}</code>
168+
ADNL: <code>{self.adnl}</code>'''
169+
170+
if self.ton.using_validator():
171+
text += f"\nWallet: <code>{self.wallet}</code>"
172+
173+
text += f'''
170174
Time: <code>{time_}</code> (<code>{int(time.time())}</code>)
171175
Alert name: <code>{alert_name}</code>
172176
Severity: <code>{alert.severity}</code>
@@ -358,6 +362,7 @@ def check_adnl_connection_failed(self):
358362
utils_module = UtilitiesModule(self.ton, self.local)
359363
ok, error = utils_module.check_adnl_connection()
360364
if not ok:
365+
self.local.add_log(error, "warning")
361366
self.send_alert("adnl_connection_failed")
362367

363368
def get_myself_from_election(self, config: dict):

modules/utilities.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,15 @@ def check_adnl_connection(self):
355355
response = requests.post(url, json=data, timeout=5).json()
356356
except Exception as e:
357357
ok = False
358-
error = f'{{red}}Failed to check ADNL connection to local node: {type(e)}: {e}{{endc}}'
358+
error = f'Failed to check ADNL connection to local node: {type(e)}: {e}'
359359
continue
360360
result = response.get("ok")
361361
if result:
362362
ok = True
363363
break
364364
if not result:
365365
ok = False
366-
error = f'{{red}}Failed to check ADNL connection to local node: {response.get("message")}{{endc}}'
366+
error = f'Failed to check ADNL connection to local node: {response.get("message")}'
367367
return ok, error
368368

369369
def get_pool_data(self, args):

mytonctrl/mytonctrl.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ def check_adnl(local, ton):
488488
utils_module = UtilitiesModule(ton, local)
489489
ok, error = utils_module.check_adnl_connection()
490490
if not ok:
491+
error = "{red}" + error + "{endc}"
491492
print_warning(local, error)
492493
#end define
493494

0 commit comments

Comments
 (0)