skip running periodic tasks for inactive bots

This commit is contained in:
2025-08-09 15:36:22 +03:00
parent 0fd45977cf
commit 69abbaa395

View File

@@ -40,7 +40,8 @@ class TelegramBot(models.Model):
return dispatcher
def run_periodic_task(self):
if not hasattr(self.config, 'periodic_task') or not self.periodic_interval or \
if not self.active or \
not hasattr(self.config, 'periodic_task') or not self.periodic_interval or \
(self.periodic_last_run and self.periodic_last_run > timezone.now() - self.periodic_interval):
return
self.config.periodic_task(self.get_bot())