summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjason2012-08-09 01:07:40 -0600
committerjason2012-08-09 01:07:40 -0600
commitee4693f34dd2841be620c020062171babb3150ba (patch)
treeebafd43d91807f0e1a8518984ff1f7db45b54807
parent842e185c613f3ea11132ff4e9fe024f0101e4813 (diff)
downloadwarmachine-ee4693f34dd2841be620c020062171babb3150ba.tar.gz
warmachine-ee4693f34dd2841be620c020062171babb3150ba.zip
fixed reloading
-rw-r--r--wmd/actions/modules.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/wmd/actions/modules.py b/wmd/actions/modules.py
index 3431ab6..f44fe4e 100644
--- a/wmd/actions/modules.py
+++ b/wmd/actions/modules.py
@@ -10,22 +10,28 @@ class ReloadModule(Action):
10 args = obj_data.params.split(" ") 10 args = obj_data.params.split(" ")
11 if "PRIVMSG" in obj_data.command and "RELOADMODULE" in args[1].upper(): 11 if "PRIVMSG" in obj_data.command and "RELOADMODULE" in args[1].upper():
12 12
13 class_name = args[2] 13 module_name, class_name = args[2].rsplit('.', 1)
14 14
15 if not module in irc.actions: 15
16 irc.privmsg(username, "Invalid Module: %s") 16 if not module_name in irc.actions:
17 irc.privmsg(username, "Invalid Module: %s" % module_name)
17 return 18 return
18 elif module == self.__class__.__name__: 19 elif not class_name in irc.actions[module_name][1]:
20 irc.privmsg(self, username, "Invalid Plugin" % class_name)
21 elif class_name == self.__class__.__name__:
19 irc.privmsg(username, "Unable to reload self. Try restarting") 22 irc.privmsg(username, "Unable to reload self. Try restarting")
20 return 23 return
21 module_class = irc.actions[module].__module__
22 module_path = module_class + '.' + module
23 24
24 print dir(irc.actions[module]) 25 reload(irc.actions[module_name][0])
26 try:
27 classz = getattr(irc.actions[module_name][0], class_name)
28 except AttributeError:
29 self.log("Class does not exist in module")
30 return
25 31
26 #reload(module_class) 32 irc.actions[module_name][1][class_name] = classz()
27 33
28 msg = "Reloaded %s" % (module_path,) 34 msg = "Reloaded %s.%s" % (module_name, class_name)
29 self.log(msg) 35 self.log(msg)
30 irc.privmsg(username, msg) 36 irc.privmsg(username, msg)
31 37