bot: respect priority field of plugins
This commit is contained in:
parent
8773141406
commit
474224b64e
|
@ -151,7 +151,9 @@ class Bot(irc.client.SimpleIRCClient, Logger):
|
||||||
def run_plugin_callbacks(self, event):
|
def run_plugin_callbacks(self, event):
|
||||||
"""Run appropriate callbacks for each plugin."""
|
"""Run appropriate callbacks for each plugin."""
|
||||||
etype = event.type
|
etype = event.type
|
||||||
for plugin in filter(lambda p: p.is_ready, self.plugins):
|
plugins = filter(lambda p: p.is_ready, self.plugins)
|
||||||
|
plugins = sorted(plugins, key=lambda p: p.priority, reverse=True)
|
||||||
|
for plugin in plugins:
|
||||||
callbacks = plugin.callbacks
|
callbacks = plugin.callbacks
|
||||||
if etype not in callbacks:
|
if etype not in callbacks:
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Plugin:
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.name = self.__class__.__name__.lower()[:-6] # Remove "Plugin".
|
self.name = self.__class__.__name__.lower()[:-6] # Remove "Plugin".
|
||||||
|
self.priority = 0
|
||||||
self.config = self.__get_config()
|
self.config = self.__get_config()
|
||||||
self.is_ready = self.__check_config()
|
self.is_ready = self.__check_config()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue