summaryrefslogtreecommitdiffstats
path: root/wmd/actions/modules.py
diff options
context:
space:
mode:
Diffstat (limited to 'wmd/actions/modules.py')
-rw-r--r--wmd/actions/modules.py56
1 files changed, 56 insertions, 0 deletions
diff --git a/wmd/actions/modules.py b/wmd/actions/modules.py
new file mode 100644
index 0000000..ed55609
--- /dev/null
+++ b/wmd/actions/modules.py
@@ -0,0 +1,56 @@
1from wmd.actions import Action
2
3import settings
4
5class ReloadModule(Action):
6 def recv_msg(self, irc, obj_data):
7 username = obj_data.get_username()
8
9 if username in settings.ADMINS:
10 args = obj_data.params.split(" ")
11 if "PRIVMSG" in obj_data.command and "RELOAD" in args[1].upper():
12 module = args[2]
13 if not module in irc.actions:
14 irc.privmsg(username, "Invalid Module: %s")
15 return
16 elif module == self.__class__.__name__:
17 irc.privmsg(username, "Unable to reload self. Try restarting")
18 return
19 module_class = irc.actions[module].__module__
20 module_path = module_class + '.' + module
21
22 del(irc.actions[module])
23 irc.load_action(module_path)
24
25 msg = "Reloaded %s" % (module_path,)
26 self.log(msg)
27 irc.privmsg(username, msg)
28
29class LoadModule(Action):
30 def recv_msg(self, irc, obj_data):
31 username = obj_data.get_username()
32
33 if username in settings.ADMINS:
34 args = obj_data.params.split(" ")
35 if "PRIVMSG" in obj_data.command and "LOAD" in args[1].upper():
36 module_path = args[2]
37 if module_path in irc.actions:
38 irc.privmsg(username, "Module %s already loaded" % (module_path,))
39 return
40 #irc.load_action(module_path)
41
42 msg = "Loading %s" % (module_path,)
43 self.log(msg)
44 irc.privmsg(username, msg)
45 return {'load': module_path}
46
47class ListModules(Action):
48 def recv_msg(self, irc, obj_data):
49 username = obj_data.get_username()
50
51 if username in settings.ADMINS:
52 args = obj_data.params.split(" ")
53 if "PRIVMSG" in obj_data.command and "LIST" in args[1].upper():
54 for module in irc.actions:
55 msg = module
56 irc.privmsg(username, msg)