diff --git a/modules/alert_bot.py b/modules/alert_bot.py index 5ba4d99a..c618dae0 100644 --- a/modules/alert_bot.py +++ b/modules/alert_bot.py @@ -85,6 +85,7 @@ def __init__(self, ton, local, *args, **kwargs): self.hostname = None self.token = self.ton.local.db.get("BotToken") self.chat_id = self.ton.local.db.get("ChatId") + self.last_db_check = None def send_message(self, text: str): if self.token is None: @@ -189,6 +190,9 @@ def test_alert(self, args): self.send_message('Test alert') def check_db_usage(self): + if time.time() - self.last_db_check < 600: + return + self.last_db_check = time.time() usage = self.ton.GetDbUsage() if usage > 95: self.send_alert("db_usage_95") @@ -206,12 +210,15 @@ def check_validator_wallet_balance(self): def check_efficiency(self): if not self.ton.using_validator(): return - validator = self.validator_module.find_myself(self.ton.GetValidatorsList(fast=True)) - if validator is None or validator.is_masterchain is False or validator.efficiency is None: + validator = self.validator_module.find_myself(self.ton.GetValidatorsList()) + if validator is None or validator.efficiency is None: return config34 = self.ton.GetConfig34() if (time.time() - config34.startWorkTime) / (config34.endWorkTime - config34.startWorkTime) < 0.8: return # less than 80% of round passed + if validator.is_masterchain is False: + if validator.efficiency != 0: + return if validator.efficiency < 90: self.send_alert("low_efficiency", efficiency=validator.efficiency) @@ -255,6 +262,8 @@ def check_adnl_connection_failed(self): self.send_alert("adnl_connection_failed") def check_status(self): + if not self.ton.using_alert_bot(): + return if not self.inited: self.init() diff --git a/modules/validator.py b/modules/validator.py index 39317924..a0fdfa9c 100644 --- a/modules/validator.py +++ b/modules/validator.py @@ -54,10 +54,10 @@ def check_efficiency(self, args): end_time = timestamp2utcdatetime(config32.endWorkTime) color_print(f"Previous round time: {{yellow}}from {start_time} to {end_time}{{endc}}") if validator: - if validator.is_masterchain == False: - print(f"Validator index is greater than {config32['mainValidators']} in the previous round - no efficiency data.") - elif validator.get('efficiency') is None: + if validator.get('efficiency') is None: print('Failed to get efficiency for the previous round') + elif validator.is_masterchain is False and validator.get('efficiency') != 0: + print(f"Validator index is greater than {config32['mainValidators']} in the previous round - no efficiency data.") else: efficiency = 100 if validator.efficiency > 100 else validator.efficiency color_efficiency = GetColorInt(efficiency, 90, logic="more", ending="%") @@ -74,7 +74,7 @@ def check_efficiency(self, args): end_time = timestamp2utcdatetime(int(get_timestamp())) color_print(f"Current round time: {{green}}from {start_time} to {end_time}{{endc}}") if validator: - if validator.is_masterchain == False: + if validator.is_masterchain is False and validator.efficiency != 0: print(f"Validator index is greater than {config34['mainValidators']} in the current round - no efficiency data.") elif (time.time() - config34.startWorkTime) / (config34.endWorkTime - config34.startWorkTime) < 0.8: print("The validation round has started recently, there is not enough data yet. " diff --git a/mytoncore/functions.py b/mytoncore/functions.py index 148c07d1..0dd136ff 100755 --- a/mytoncore/functions.py +++ b/mytoncore/functions.py @@ -569,9 +569,8 @@ def General(local): from modules.custom_overlays import CustomOverlayModule local.start_cycle(CustomOverlayModule(ton, local).custom_overlays, sec=60, args=()) - if ton.get_mode_value('alert-bot'): - from modules.alert_bot import AlertBotModule - local.start_cycle(AlertBotModule(ton, local).check_status, sec=1000, args=()) + from modules.alert_bot import AlertBotModule + local.start_cycle(AlertBotModule(ton, local).check_status, sec=60, args=()) thr_sleep() # end define diff --git a/mytonctrl/resources/translate.json b/mytonctrl/resources/translate.json index 929eea8a..22915e59 100644 --- a/mytonctrl/resources/translate.json +++ b/mytonctrl/resources/translate.json @@ -445,9 +445,9 @@ "zh_TW": "{red}錯誤 - 驗證器的 UDP 端口無法從外部訪問.{endc}" }, "slashed_warning": { - "en": "{red}You were fined by {0} TON for low efficiency in the previous round.{endc}", - "ru": "{red}Вы были оштрафованы на {0} TON за низкую эффективность в предыдущем раунде.{endc}", - "zh_TW": "{red}您因上一輪效率低而被罰款 {0} TON。{endc}" + "en": "{{red}}You were fined by {0} TON for low efficiency in the previous round.{{endc}}", + "ru": "{{red}}Вы были оштрафованы на {0} TON за низкую эффективность в предыдущем раунде.{{endc}}", + "zh_TW": "{{red}}您因上一輪效率低而被罰款 {0} TON。{{endc}}" }, "add_custom_overlay_cmd": { "en": "Add custom overlay",