summaryrefslogtreecommitdiffstats
path: root/wmd/irc.py
diff options
context:
space:
mode:
Diffstat (limited to 'wmd/irc.py')
-rw-r--r--wmd/irc.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/wmd/irc.py b/wmd/irc.py
index dd99f5c..813f743 100644
--- a/wmd/irc.py
+++ b/wmd/irc.py
@@ -64,7 +64,12 @@ class IRC(object):
64 Loads the provided action 64 Loads the provided action
65 """ 65 """
66 module_name, class_name = path.rsplit('.', 1) 66 module_name, class_name = path.rsplit('.', 1)
67 module = __import__(module_name, globals(), locals(), [class_name], -1) 67 try:
68 module = __import__(module_name, globals(), locals(), [class_name], -1)
69 except ImportError:
70 self.log("Error loading module: %s" %(path,))
71 return
72
68 classz = getattr(module, class_name) 73 classz = getattr(module, class_name)
69 self.actions[class_name] = classz() 74 self.actions[class_name] = classz()
70 75
@@ -93,13 +98,19 @@ class IRC(object):
93 print "<- " + obj_data.prefix + "~" + obj_data.command + "~" + obj_data.params 98 print "<- " + obj_data.prefix + "~" + obj_data.command + "~" + obj_data.params
94 99
95 modules_to_load = [] 100 modules_to_load = []
101 modules_to_unload = []
96 for plugin_name in self.actions: 102 for plugin_name in self.actions:
97 retval = self.actions[plugin_name].recv_msg(self, obj_data) 103 retval = self.actions[plugin_name].recv_msg(self, obj_data)
98 if type(retval) == type(dict()): 104 if type(retval) == type(dict()):
99 if retval.has_key('load'): 105 if retval.has_key('load'):
100 modules_to_load.append(retval['load']) 106 modules_to_load.append(retval['load'])
107 if retval.has_key('unload'):
108 modules_to_unload.append(retval['unload'])
101 elif type(retval) == type('str is str'): 109 elif type(retval) == type('str is str'):
102 self.rawsend(retval) 110 self.rawsend(retval)
103 111
104 for module in modules_to_load: 112 for module in modules_to_load:
105 self.load_action(module) 113 self.load_action(module)
114 for module in modules_to_unload:
115 if self.actions.has_key(module):
116 del(self.actions[module])