Polling intervals fixed

This commit is contained in:
Yigit Colakoglu 2024-09-10 17:16:59 +00:00
parent 30cb4df6dc
commit dc2139df24
2 changed files with 12 additions and 7 deletions

View File

@ -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,
}

View File

@ -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