2018-03-14 20:13:40 +00:00
|
|
|
import main
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2019-08-09 22:06:34 +00:00
|
|
|
class DelCommand:
|
2019-01-26 18:58:21 +00:00
|
|
|
def __init__(self, *args):
|
|
|
|
self.delete(*args)
|
2018-02-23 22:05:40 +00:00
|
|
|
|
|
|
|
def delete(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
|
|
|
if authed:
|
2019-08-11 20:58:14 +00:00
|
|
|
if length == 3:
|
|
|
|
if not spl[1] in main.network.keys():
|
|
|
|
failure("No such network: %s" % spl[1])
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
2019-09-28 18:46:10 +00:00
|
|
|
if not spl[2].isdigit():
|
|
|
|
failure("Must be integer, not %s" % spl[2])
|
|
|
|
return
|
2019-08-11 20:58:14 +00:00
|
|
|
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]))
|
2019-09-28 18:46:10 +00:00
|
|
|
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]
|
2018-07-27 21:58:37 +00:00
|
|
|
success("Successfully removed bot: %s" % spl[1])
|
2019-08-11 20:58:14 +00:00
|
|
|
main.saveConf("network")
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("del")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|