summaryrefslogtreecommitdiff
path: root/src/plugin.py
diff options
context:
space:
mode:
authorFlorent Le Coz <louiz@louiz.org>2011-09-24 22:26:31 +0200
committerFlorent Le Coz <louiz@louiz.org>2011-09-24 22:26:31 +0200
commitf27556747896aeb891ce71cfdd0ac349d68c5b3d (patch)
treedda3389310142b1783732f27a9393daf228a9c5d /src/plugin.py
parente3b933445fe4b18af6ec462fc40da5f482e447a0 (diff)
downloadpoezio-f27556747896aeb891ce71cfdd0ac349d68c5b3d.tar.gz
poezio-f27556747896aeb891ce71cfdd0ac349d68c5b3d.tar.bz2
poezio-f27556747896aeb891ce71cfdd0ac349d68c5b3d.tar.xz
poezio-f27556747896aeb891ce71cfdd0ac349d68c5b3d.zip
[teisenbe] Use the imp module to import modules.
Also add a simple translator module
Diffstat (limited to 'src/plugin.py')
-rw-r--r--src/plugin.py26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/plugin.py b/src/plugin.py
index e8386d16..728dfe21 100644
--- a/src/plugin.py
+++ b/src/plugin.py
@@ -1,5 +1,3 @@
-import inspect
-
class BasePlugin(object):
"""
Class that all plugins derive from. Any methods beginning with command_
@@ -7,14 +5,9 @@ class BasePlugin(object):
event handlers
"""
- def __init__(self, core):
+ def __init__(self, plugin_manager, core):
self.core = core
- for k, v in inspect.getmembers(self, inspect.ismethod):
- if k.startswith('on_'):
- core.xmpp.add_event_handler(k[3:], v)
- elif k.startswith('command_'):
- command = k[len('command_'):]
- core.commands[command] = (v, v.__doc__, None)
+ self.plugin_manager = plugin_manager
self.init()
def init(self):
@@ -24,10 +17,13 @@ class BasePlugin(object):
pass
def unload(self):
- for k, v in inspect.getmembers(self, inspect.ismethod):
- if k.startswith('on_'):
- self.core.xmpp.del_event_handler(k[3:], v)
- elif k.startswith('command_'):
- command = k[len('command_'):]
- del self.core.commands[command]
self.cleanup()
+
+ def add_command(self, name, handler, help, completion=None):
+ return self.plugin_manager.add_command(self.__module__, name, handler, help, completion)
+
+ def add_event_handler(self, event_name, handler):
+ return self.plugin_manager.add_event_handler(self.__module__, event_name, handler)
+
+ def del_event_handler(self, event_name, handler):
+ return self.plugin_manager.del_event_handler(self.__module__, event_name, handler)