skip running periodic tasks for inactive bots
This commit is contained in:
@@ -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())
|
||||
|
Reference in New Issue
Block a user