diff options
| author | jason | 2012-07-21 16:33:46 -0600 |
|---|---|---|
| committer | jason | 2012-07-21 16:33:46 -0600 |
| commit | d79ae36d9f22c4df1b87f891150b804f036c1c7b (patch) | |
| tree | dab4fe5478a4e5877a4c23040bc772c0e801f67b /wmd/actions/modules.py | |
| parent | 6019b7e376698dcb6dfdf3239388467ab4615aab (diff) | |
| download | warmachine-d79ae36d9f22c4df1b87f891150b804f036c1c7b.tar.gz warmachine-d79ae36d9f22c4df1b87f891150b804f036c1c7b.zip | |
Added support for unloading modules.
Diffstat (limited to 'wmd/actions/modules.py')
| -rw-r--r-- | wmd/actions/modules.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/wmd/actions/modules.py b/wmd/actions/modules.py index 60a1436..eb726c2 100644 --- a/wmd/actions/modules.py +++ b/wmd/actions/modules.py | |||
| @@ -32,9 +32,9 @@ class LoadModule(Action): | |||
| 32 | 32 | ||
| 33 | if username in settings.ADMINS: | 33 | if username in settings.ADMINS: |
| 34 | args = obj_data.params.split(" ") | 34 | args = obj_data.params.split(" ") |
| 35 | if "PRIVMSG" in obj_data.command and "LOADMODULE" in args[1].upper(): | 35 | if "PRIVMSG" in obj_data.command and ":LOADMODULE" in args[1].upper(): |
| 36 | module_path = args[2] | 36 | module_path = args[2] |
| 37 | if module_path in irc.actions: | 37 | if module_path.split(".")[-1] in irc.actions: |
| 38 | irc.privmsg(username, "Module %s already loaded" % (module_path,)) | 38 | irc.privmsg(username, "Module %s already loaded" % (module_path,)) |
| 39 | return | 39 | return |
| 40 | #irc.load_action(module_path) | 40 | #irc.load_action(module_path) |
| @@ -50,7 +50,25 @@ class ListModules(Action): | |||
| 50 | 50 | ||
| 51 | if username in settings.ADMINS: | 51 | if username in settings.ADMINS: |
| 52 | args = obj_data.params.split(" ") | 52 | args = obj_data.params.split(" ") |
| 53 | if "PRIVMSG" in obj_data.command and "LISTMODULES" in args[1].upper(): | 53 | if "PRIVMSG" in obj_data.command and ":LISTMODULES" in args[1].upper(): |
| 54 | for module in irc.actions: | 54 | for module in irc.actions: |
| 55 | msg = module | 55 | msg = module |
| 56 | irc.privmsg(username, msg) | 56 | irc.privmsg(username, msg) |
| 57 | |||
| 58 | class UnloadModule(Action): | ||
| 59 | def recv_msg(self, irc, obj_data): | ||
| 60 | username = obj_data.get_username() | ||
| 61 | |||
| 62 | if username in settings.ADMINS: | ||
| 63 | args = obj_data.params.split(" ") | ||
| 64 | if "PRIVMSG" in obj_data.command and ":UNLOADMODULE" in args[1].upper(): | ||
| 65 | module_name = args[2] | ||
| 66 | if not module_name in irc.actions: | ||
| 67 | irc.privmsg(username, "Module %s already unloaded" % (module_name,)) | ||
| 68 | return | ||
| 69 | #irc.load_action(module_path) | ||
| 70 | |||
| 71 | msg = "Unloading %s" % (module_name,) | ||
| 72 | self.log(msg) | ||
| 73 | irc.privmsg(username, msg) | ||
| 74 | return {'unload': module_name} \ No newline at end of file | ||