From dc2139df240a444a10d0f13b6cdeeb68a724d63b Mon Sep 17 00:00:00 2001 From: Yigit Colakoglu Date: Tue, 10 Sep 2024 17:16:59 +0000 Subject: [PATCH] Polling intervals fixed --- config.py | 11 ++++++----- tgbot.py | 8 ++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/config.py b/config.py index 7139443..9ffc728 100644 --- a/config.py +++ b/config.py @@ -5,11 +5,12 @@ DB_PATH = "data.db" CHROMEDRIVER_PATH = "chromedriver" INTERVALS = { - 3600 * 0.5: 30, - 3600 * 1.0: 60, - 3600 * 1.5: 150, - 3600 * 2.0: 300, - 3600 * 3.0: 1800, + 1800 + 3600 * 0.0: 1800, + 1800 + 3600 * 0.5: 30, + 1800 + 3600 * 1.0: 60, + 1800 + 3600 * 1.5: 150, + 1800 + 3600 * 2.0: 300, + 1800 + 3600 * 3.0: 1800, } diff --git a/tgbot.py b/tgbot.py index a91d49d..3372cab 100644 --- a/tgbot.py +++ b/tgbot.py @@ -8,6 +8,8 @@ import sqlite3 from xclient import XClient import config +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) class TelegramBot: def __init__(self, bot_token, db_path="bot_database.db"): @@ -441,7 +443,6 @@ class TelegramBot: def poll_periodically(self): # Continuously poll the watchlist at dynamically adjusted intervals - logging.info(f"POLLING {self.watchlist}") while True: self.check_watchlist() @@ -457,7 +458,10 @@ class TelegramBot: polling_interval = min(polling_interval, interval) if watching == 0: - polling_interval = 15 + polling_interval = 5 + + logger.info(f"POLLING {self.watchlist}. Sleeping {polling_interval}") + time.sleep(polling_interval) # Wait before checking the watchlist again