'Create the nickname'

def func(self):

    caller = self.caller
    switches = self.switches
    nicktypes = ([switch for switch in switches if (switch in ('object', 'player', 'inputline'))] or ['inputline'])
    nicklist = utils.make_iter((caller.nicks.get(return_obj=True) or []))
    if (('list' in switches) or (self.cmdstring in ('nicks', '@nicks'))):
        if (not nicklist):
            string = '|wNo    nicks    defined.|n'
        else:
            table = evtable.EvTable('#', 'Type', 'Nick    match', 'Replacement')
            for (inum, nickobj) in enumerate(nicklist):
                (_, _, nickvalue, replacement) = nickobj.value
                table.add_row(str((inum + 1)), nickobj.db_category, nickvalue, replacement)
            string = ('|wDefined    Nicks:|n\n%s' % table)
        caller.msg(string)
        return
    if ('clearall' in switches):
        caller.nicks.clear()
        caller.msg('Cleared    all    nicks.')
        return
    if ((not self.args) or (not self.lhs)):
        caller.msg('Usage:    nick[/switches]    nickname    =    [realname]')
        return
    nickstring = self.lhs
    replstring = self.rhs
    old_nickstring = None
    old_replstring = None
    if (replstring == nickstring):
        caller.msg('No    point    in    setting    nick    same    as    the    string    to    replace...')
        return
    errstring = ''
    string = ''
    for nicktype in nicktypes:
        oldnick = caller.nicks.get(key=nickstring, category=nicktype, return_obj=True)
        if oldnick:
            (_, _, old_nickstring, old_replstring) = oldnick.value
        else:
            arg = self.args.lstrip('#')
            if arg.isdigit():
                delindex = int(arg)
                if (0 < delindex <= len(nicklist)):
                    oldnick = nicklist[(delindex - 1)]
                    (_, _, old_nickstring, old_replstring) = oldnick.value
                else:
                    errstring += 'Not    a    valid    nick    index.'
            else:
                errstring += 'Nick    not    found.'
        if (('delete' in switches) or ('del' in switches)):
            if (old_nickstring and caller.nicks.has(old_nickstring, category=nicktype)):
                caller.nicks.remove(old_nickstring, category=nicktype)
                string += ("\nNick    removed:    '|w%s|n'    ->    |w%s|n." % (old_nickstring, old_replstring))
            else:
                errstring += ("\nNick    '|w%s|n'    was    not    deleted." % old_nickstring)
        elif replstring:
            errstring = ''
            if oldnick:
                string += ("\nNick    '|w%s|n'    updated    to    map    to    '|w%s|n'." % (old_nickstring, replstring))
            else:
                string += ("\nNick    '|w%s|n'    mapped    to    '|w%s|n'." % (nickstring, replstring))
            try:
                caller.nicks.add(nickstring, replstring, category=nicktype)
            except NickTemplateInvalid:
                caller.msg('You    must    use    the    same    $-markers    both    in    the    nick    and    in    the    replacement.')
                return
        elif (old_nickstring and old_replstring):
            string += ("\nNick    '|w%s|n'    maps    to    '|w%s|n'." % (old_nickstring, old_replstring))
            errstring = ''
    string = (errstring if errstring else string)
    caller.msg(string)
