diff --git a/commands/alias.py b/commands/alias.py index b501c36..baccad5 100644 --- a/commands/alias.py +++ b/commands/alias.py @@ -11,16 +11,6 @@ class AliasCommand: if length == 1: info(dump(main.alias)) 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: if spl[1] == "add": if not spl[2].isdigit(): @@ -28,7 +18,10 @@ class AliasCommand: return num = int(spl[2]) 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() success("Generated new alias: %i" % nextNum) main.saveConf("alias") @@ -38,6 +31,9 @@ class AliasCommand: failure("Must be a number, not %s" % spl[2]) return num = int(spl[2]) + if not num in main.alias.keys(): + failure("No such alias: %i" % num) + return failed = False for i in main.network.keys(): if num in main.network[i].aliases.keys(): diff --git a/conf/help.json b/conf/help.json index 1e00114..5730e73 100644 --- a/conf/help.json +++ b/conf/help.json @@ -20,12 +20,13 @@ "users": "users [ ...]", "relay": "relay [] []", "network": "network [
]", - "alias": "alias []", + "alias": "alias [] []", "auto": "auto ", "cmd": "cmd ", "token": "token [] []", "all": "all ", "allc": "allc <(network)|(alias)> ", "admall": "admall ", - "swho": "swho []" + "swho": "swho []", + "exec": "exec " } diff --git a/modules/network.py b/modules/network.py index e4eefb3..6b45880 100644 --- a/modules/network.py +++ b/modules/network.py @@ -38,14 +38,8 @@ class Network: # self.start_bot(num) return num, main.alias[num]["nick"] - 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! - - def seppuku(self): - # Removes all bots in preperation for deletion - for i in self.relays.keys(): + def killAliases(self, aliasList): + for i in aliasList: name = self.net+str(i) if name in main.ReactorPool.keys(): if name in main.FactoryPool.keys(): @@ -56,6 +50,16 @@ class Network: del main.ReactorPool[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): # a single name is given to relays in the backend # e.g. freenode1 for the first relay on freenode network