Skip to content

Commit 79bf05b

Browse files
committed
update alerting thread time
1 parent f94a7dc commit 79bf05b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

modules/alert_bot.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def __init__(self, ton, local, *args, **kwargs):
8585
self.hostname = None
8686
self.token = self.ton.local.db.get("BotToken")
8787
self.chat_id = self.ton.local.db.get("ChatId")
88+
self.last_db_check = None
8889

8990
def send_message(self, text: str):
9091
if self.token is None:
@@ -189,6 +190,9 @@ def test_alert(self, args):
189190
self.send_message('Test alert')
190191

191192
def check_db_usage(self):
193+
if time.time() - self.last_db_check < 600:
194+
return
195+
self.last_db_check = time.time()
192196
usage = self.ton.GetDbUsage()
193197
if usage > 95:
194198
self.send_alert("db_usage_95")
@@ -258,6 +262,8 @@ def check_adnl_connection_failed(self):
258262
self.send_alert("adnl_connection_failed")
259263

260264
def check_status(self):
265+
if not self.ton.using_alert_bot():
266+
return
261267
if not self.inited:
262268
self.init()
263269

mytoncore/functions.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -569,9 +569,8 @@ def General(local):
569569
from modules.custom_overlays import CustomOverlayModule
570570
local.start_cycle(CustomOverlayModule(ton, local).custom_overlays, sec=60, args=())
571571

572-
if ton.get_mode_value('alert-bot'):
573-
from modules.alert_bot import AlertBotModule
574-
local.start_cycle(AlertBotModule(ton, local).check_status, sec=1000, args=())
572+
from modules.alert_bot import AlertBotModule
573+
local.start_cycle(AlertBotModule(ton, local).check_status, sec=60, args=())
575574

576575
thr_sleep()
577576
# end define

0 commit comments

Comments
 (0)