summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsand <daniel@spatof.org>2013-05-13 16:33:28 (GMT)
committer sand <daniel@spatof.org>2013-05-13 16:33:28 (GMT)
commitda9e7f248f3c95be10c755ded3d70e93c9e8e7dd (patch)
tree4c7e445516b6d3e1ef790b5113eb1f5064bd37f2
parent60bf9dccbabb162ee30931c018f83385434d113d (diff)
supporto per plugin disattivati
-rw-r--r--pinolo/irc.py26
-rw-r--r--pinolo/plugins/__init__.py3
-rw-r--r--pinolo/plugins/prcd.py (renamed from pinolo/prcd.py)0
3 files changed, 17 insertions, 12 deletions
diff --git a/pinolo/irc.py b/pinolo/irc.py
index 464e312..21311ca 100644
--- a/pinolo/irc.py
+++ b/pinolo/irc.py
@@ -267,17 +267,21 @@ class IRCConnection(object):
def dispatch_event(self, event):
log.debug("Dispatching %r" % event)
-
- for handler in [self] + self.bot.plugins:
- if hasattr(handler, event.name):
- fn = getattr(handler, event.name)
- try:
- fn(event)
- except Exception, e:
- import traceback
- print "Exception in IRC callback {0}: {1}".format(
- event.name, str(e))
- print traceback.format_exc()
+
+ # Check only enabled plugins
+ plugins = [plugin for plugin in self.bot.plugins if plugin.enabled]
+ for handler in [self] + plugins:
+ if not hasattr(handler, event.name):
+ continue
+
+ fn = getattr(handler, event.name)
+ try:
+ fn(event)
+ except Exception, e:
+ import traceback
+ print "Exception in IRC callback {0}: {1}".format(
+ event.name, str(e))
+ print traceback.format_exc()
def check_in_buffer(self):
"""Check for complete lines in the input buffer, encode them in UTF-8
diff --git a/pinolo/plugins/__init__.py b/pinolo/plugins/__init__.py
index d1e44de..cff90ed 100644
--- a/pinolo/plugins/__init__.py
+++ b/pinolo/plugins/__init__.py
@@ -26,9 +26,10 @@ class Plugin(object):
if name != "Plugin":
registry.append((name, cls))
- def __init__(self, bot):
+ def __init__(self, bot, enabled=True):
"""Initialize the plugin instance with a pointer to the bot object"""
self.bot = bot
+ self.enabled = enabled
def activate(self):
"""Activate the plugin"""
diff --git a/pinolo/prcd.py b/pinolo/plugins/prcd.py
index 40f1206..40f1206 100644
--- a/pinolo/prcd.py
+++ b/pinolo/plugins/prcd.py