Skip to content

Commit

Permalink
revert: bot.unregister and bot.unregister_jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
Exirel committed Jun 17, 2020
1 parent 761c8c9 commit 13efdd5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,9 @@ def unregister(self, obj):
"""
callable_name = getattr(obj, "__name__", 'UNKNOWN')

if hasattr(obj, 'interval'):
self.unregister_jobs([obj])

if callable_name == "shutdown" and obj in self.shutdown_methods:
self.unregister_shutdowns([obj])

Expand Down Expand Up @@ -496,6 +499,10 @@ def register_jobs(self, jobs):
job = sopel.tools.jobs.Job.from_callable(self.settings, func)
self._scheduler.register(job)

def unregister_jobs(self, jobs):
for job in jobs:
self._scheduler.remove_callable_job(job)

def register_shutdowns(self, shutdowns):
# Append plugin's shutdown function to the bot's list of functions to
# call on shutdown
Expand Down

0 comments on commit 13efdd5

Please sign in to comment.