monolith/commands/del.py

38 lines
1.4 KiB
Python

import main
class DelCommand:
def __init__(self, *args):
self.delete(*args)
def delete(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
if authed:
if length == 3:
if not spl[1] in main.network.keys():
failure("No such network: %s" % spl[1])
return
if not spl[2].isdigit():
failure("Must be integer, not %s" % spl[2])
return
if not int(spl[2]) in main.network[spl[1]].relays.keys():
failure("No such relay: %s in network %s" % (spl[2], spl[1]))
return
main.network[spl[1]].delete_relay(int(spl[2]))
name = spl[1]+spl[2]
if name in main.ReactorPool.keys():
if name in main.FactoryPool.keys():
main.FactoryPool[name].stopTrying()
main.ReactorPool[name].disconnect()
if name in main.IRCPool.keys():
del main.IRCPool[name]
del main.ReactorPool[name]
del main.FactoryPool[name]
success("Successfully removed bot: %s" % spl[1])
main.saveConf("network")
return
else:
incUsage("del")
return
else:
incUsage(None)