diff --git a/main.py b/main.py index f4e4f7e..6f482d7 100755 --- a/main.py +++ b/main.py @@ -59,6 +59,10 @@ class Server(BaseServer): self.handlers[i].append([name, getattr(mod, i)]) self.states[name] = None + def unload_mod(self, name): + for i in EVENTS: + self.handlers[i] = [j for j in self.handlers[i] if not j[0] == name] + def event_get(self, line: Line): if line.command.lower() in EVENTS[2:]: return line.command.lower() diff --git a/mods/default.py b/mods/default.py index 6c382b3..4717787 100644 --- a/mods/default.py +++ b/mods/default.py @@ -11,3 +11,12 @@ def cmd(line, srv): else: utils.message(srv, line.params[0], "loaded: `" + params[0] + "'") + elif command == "unload": + try: + srv.unload_mod(params[0]) + except: + utils.message(srv, line.params[0], + "failed to unload `" + params[0] + "'") + else: + utils.message(srv, line.params[0], + "unloaded: `" + params[0] + "'"