Clarify nick-deletion mechanism
This commit is contained in:
parent
11ddd26c7e
commit
3e5f2ef68a
1 changed files with 20 additions and 9 deletions
|
|
@ -173,25 +173,36 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
|
||||||
|
|
||||||
if 'delete' in switches or 'del' in switches:
|
if 'delete' in switches or 'del' in switches:
|
||||||
if not self.args or not self.lhs:
|
if not self.args or not self.lhs:
|
||||||
caller.msg("usage nick/delete #num ('nicks' for list)")
|
caller.msg("usage nick/delete <nick> or <#num> ('nicks' for list)")
|
||||||
return
|
return
|
||||||
# see if a number was given
|
# see if a number was given
|
||||||
arg = self.args.lstrip("#")
|
arg = self.args.lstrip("#")
|
||||||
|
oldnicks = []
|
||||||
if arg.isdigit():
|
if arg.isdigit():
|
||||||
# we are given a index in nicklist
|
# we are given a index in nicklist
|
||||||
delindex = int(arg)
|
delindex = int(arg)
|
||||||
if 0 < delindex <= len(nicklist):
|
if 0 < delindex <= len(nicklist):
|
||||||
oldnick = nicklist[delindex - 1]
|
oldnicks.append(nicklist[delindex - 1])
|
||||||
_, _, old_nickstring, old_replstring = oldnick.value
|
|
||||||
else:
|
else:
|
||||||
caller.msg("Not a valid nick index. See 'nicks' for a list.")
|
caller.msg("Not a valid nick index. See 'nicks' for a list.")
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
|
if not specified_nicktype:
|
||||||
|
nicktypes = ("object", "account", "inputline")
|
||||||
|
for nicktype in nicktypes:
|
||||||
|
oldnicks.append(caller.nicks.get(arg, category=nicktype, return_obj=True))
|
||||||
|
|
||||||
|
oldnicks = [oldnick for oldnick in oldnicks if oldnick]
|
||||||
|
if oldnicks:
|
||||||
|
for oldnick in oldnicks:
|
||||||
nicktype = oldnick.category
|
nicktype = oldnick.category
|
||||||
nicktypestr = "%s-nick" % nicktype.capitalize()
|
nicktypestr = "%s-nick" % nicktype.capitalize()
|
||||||
|
_, _, old_nickstring, old_replstring = oldnick.value
|
||||||
caller.nicks.remove(old_nickstring, category=nicktype)
|
caller.nicks.remove(old_nickstring, category=nicktype)
|
||||||
caller.msg("%s removed: '|w%s|n' -> |w%s|n." % (
|
caller.msg("%s removed: '|w%s|n' -> |w%s|n." % (
|
||||||
nicktypestr, old_nickstring, old_replstring))
|
nicktypestr, old_nickstring, old_replstring))
|
||||||
|
else:
|
||||||
|
caller.msg("No matching nicks to remove.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.rhs and self.lhs:
|
if not self.rhs and self.lhs:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue