add module unloading
This commit is contained in:
parent
d4d6ab9a8e
commit
b23faa1d3f
4
main.py
4
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()
|
||||
|
|
|
@ -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] + "'"
|
||||
|
|
Loading…
Reference in New Issue