Error checking on alias removal and clean up when removing relays
This commit is contained in:
parent
a3b81f8849
commit
d35f96de87
|
@ -11,16 +11,6 @@ class AliasCommand:
|
||||||
if length == 1:
|
if length == 1:
|
||||||
info(dump(main.alias))
|
info(dump(main.alias))
|
||||||
return
|
return
|
||||||
elif length == 2:
|
|
||||||
if spl[1] == "add":
|
|
||||||
nextNum = max(main.alias.keys())+1
|
|
||||||
main.alias[nextNum] = alias.generate_alias()
|
|
||||||
success("Generated new alias: %i" % nextNum)
|
|
||||||
main.saveConf("alias")
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
incUsage("alias")
|
|
||||||
return
|
|
||||||
elif length == 3:
|
elif length == 3:
|
||||||
if spl[1] == "add":
|
if spl[1] == "add":
|
||||||
if not spl[2].isdigit():
|
if not spl[2].isdigit():
|
||||||
|
@ -28,7 +18,10 @@ class AliasCommand:
|
||||||
return
|
return
|
||||||
num = int(spl[2])
|
num = int(spl[2])
|
||||||
for i in range(num):
|
for i in range(num):
|
||||||
nextNum = max(main.alias.keys())+1
|
if len(main.alias.keys()) == 0:
|
||||||
|
nextNum = 1
|
||||||
|
else:
|
||||||
|
nextNum = max(main.alias.keys())+1
|
||||||
main.alias[nextNum] = alias.generate_alias()
|
main.alias[nextNum] = alias.generate_alias()
|
||||||
success("Generated new alias: %i" % nextNum)
|
success("Generated new alias: %i" % nextNum)
|
||||||
main.saveConf("alias")
|
main.saveConf("alias")
|
||||||
|
@ -38,6 +31,9 @@ class AliasCommand:
|
||||||
failure("Must be a number, not %s" % spl[2])
|
failure("Must be a number, not %s" % spl[2])
|
||||||
return
|
return
|
||||||
num = int(spl[2])
|
num = int(spl[2])
|
||||||
|
if not num in main.alias.keys():
|
||||||
|
failure("No such alias: %i" % num)
|
||||||
|
return
|
||||||
failed = False
|
failed = False
|
||||||
for i in main.network.keys():
|
for i in main.network.keys():
|
||||||
if num in main.network[i].aliases.keys():
|
if num in main.network[i].aliases.keys():
|
||||||
|
|
|
@ -20,12 +20,13 @@
|
||||||
"users": "users <channel> [<channel> ...]",
|
"users": "users <channel> [<channel> ...]",
|
||||||
"relay": "relay <add|del|list> [<network>] [<num>]",
|
"relay": "relay <add|del|list> [<network>] [<num>]",
|
||||||
"network": "network <add|del|list> [<name> <address> <port> <ssl|plain> <sasl|ns|none>]",
|
"network": "network <add|del|list> [<name> <address> <port> <ssl|plain> <sasl|ns|none>]",
|
||||||
"alias": "alias [<add>]",
|
"alias": "alias [<add|del>] [<num>]",
|
||||||
"auto": "auto <network> <relay>",
|
"auto": "auto <network> <relay>",
|
||||||
"cmd": "cmd <relay> <user> <entity> <text ...>",
|
"cmd": "cmd <relay> <user> <entity> <text ...>",
|
||||||
"token": "token <add|del|list> [<key>] [<relay>]",
|
"token": "token <add|del|list> [<key>] [<relay>]",
|
||||||
"all": "all <entity> <text ...>",
|
"all": "all <entity> <text ...>",
|
||||||
"allc": "allc <network|alias> <(network)|(alias)> <entity> <text ...>",
|
"allc": "allc <network|alias> <(network)|(alias)> <entity> <text ...>",
|
||||||
"admall": "admall <entity> <text ...>",
|
"admall": "admall <entity> <text ...>",
|
||||||
"swho": "swho <network> [<channel>]"
|
"swho": "swho <network> [<channel>]",
|
||||||
|
"exec": "exec <expr ...>"
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,8 @@ class Network:
|
||||||
# self.start_bot(num)
|
# self.start_bot(num)
|
||||||
return num, main.alias[num]["nick"]
|
return num, main.alias[num]["nick"]
|
||||||
|
|
||||||
def delete_relay(self, id):
|
def killAliases(self, aliasList):
|
||||||
del self.relays[id]
|
for i in aliasList:
|
||||||
del self.aliases[id]
|
|
||||||
#del main.alias[id] - Aliases are global per num, so don't delete them!
|
|
||||||
|
|
||||||
def seppuku(self):
|
|
||||||
# Removes all bots in preperation for deletion
|
|
||||||
for i in self.relays.keys():
|
|
||||||
name = self.net+str(i)
|
name = self.net+str(i)
|
||||||
if name in main.ReactorPool.keys():
|
if name in main.ReactorPool.keys():
|
||||||
if name in main.FactoryPool.keys():
|
if name in main.FactoryPool.keys():
|
||||||
|
@ -56,6 +50,16 @@ class Network:
|
||||||
del main.ReactorPool[name]
|
del main.ReactorPool[name]
|
||||||
del main.FactoryPool[name]
|
del main.FactoryPool[name]
|
||||||
|
|
||||||
|
def delete_relay(self, id):
|
||||||
|
del self.relays[id]
|
||||||
|
del self.aliases[id]
|
||||||
|
#del main.alias[id] - Aliases are global per num, so don't delete them!
|
||||||
|
self.killAliases([id])
|
||||||
|
|
||||||
|
def seppuku(self):
|
||||||
|
# Removes all bots in preperation for deletion
|
||||||
|
self.killAliases(self.relay.keys())
|
||||||
|
|
||||||
def start_bot(self, num):
|
def start_bot(self, num):
|
||||||
# a single name is given to relays in the backend
|
# a single name is given to relays in the backend
|
||||||
# e.g. freenode1 for the first relay on freenode network
|
# e.g. freenode1 for the first relay on freenode network
|
||||||
|
|
Loading…
Reference in New Issue