Exemplo n.º 1
0
def process_keystroke(inp, user):
    """ Process keystroke, ``inp``, for target ``user``. """
    # pylint: disable=R0914,R0912,R0915,R0911,W0603
    #         Too many local variables
    #         Too many branches
    #         Too many statements
    #         Too many return statements
    #         Using the global statement
    # ^ lol, this is one of those things that should be
    #   refactored into smaller subroutines =)
    from x84.bbs import getsession, getterminal, echo, getch, gosub
    from x84.bbs import LineEditor, ScrollingEditor
    from x84.default.nua import set_email, set_location
    from x84.bbs.ini import CFG
    def_timeout = CFG.getint('system', 'timeout')
    global EXIT
    session, term = getsession(), getterminal()
    is_self = bool(user.handle == session.user.handle)
    invalid = u'\r\niNVAlid.'
    assert is_self or 'sysop' in session.user.groups

    if is_self and inp in (u'c', u'C'):
        gosub('charset')

    elif is_self and inp in (u't', u'T'):
        echo(term.move(term.height - 1, 0))
        echo(ABOUT_TERM + u'\r\n')
        echo(u'\r\ntERMiNAl tYPE: ')
        term = LineEditor(30, session.env.get('TERM')).read()
        echo(u"\r\n\r\nset TERM to '%s'? [yn]" % (term,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                session.env['TERM'] = term
                break
            elif inp2 in (u'n', u'N'):
                break

    elif is_self and inp in (u'w', u'W'):
        echo(u'\r\ntERMiNAl Width: ')
        width = LineEditor(3, str(term.width)).read()
        try:
            width = int(width)
        except ValueError:
            echo(invalid)
            return True
        if width < 0 or width > 999:
            echo(invalid)
            return True
        echo(u"\r\n\r\nset COLUMNS=%d? [yn]" % (width,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                term.columns = width
                break
            elif inp2 in (u'n', u'N'):
                break

    elif is_self and inp in (u'h', u'H'):
        echo(u'\r\ntERMiNAl hEiGht: ')
        height = LineEditor(3, str(term.height)).read()
        try:
            height = int(height)
        except ValueError:
            echo(invalid)
            return True
        if height < 0 or height > 999:
            echo(invalid)
            return True
        echo(u"\r\n\r\nset LINES=%d? [yn]" % (height,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                term.rows = height
                break
            elif inp2 in (u'n', u'N'):
                break

    elif 'sysop' in session.user.groups and inp in (u'd', u'D',):
        echo(u"\r\n\r\ndElEtE %s ? [yn]" % (user.handle,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.delete()
                break
            elif inp2 in (u'n', u'N'):
                break
        EXIT = True

    elif 'sysop' in session.user.groups and inp in (u's', u'S',):
        sysop = not 'sysop' in user.groups
        echo(u"\r\n\r\n%s SYSOP ACCESS? [yn]" % (
            'ENAblE' if sysop else 'diSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                if sysop:
                    user.groups.add('sysop')
                else:
                    user.groups.remove('sysop')
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'p', u'P'):
        from x84.default.nua import set_password
        set_password(user)
        echo(u"\r\n\r\nSEt PASSWORd ? [yn]")
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'k', 'K',):
        change = True
        if user.get('pubkey', False):
            echo(u"\r\n\r\nSSh PUbliC kEY AlREAdY SEt, ChANGE ? [yn]")
            while True:
                inp2 = getch()
                if inp2 in (u'y', u'Y'):
                    break
                elif inp2 in (u'n', u'N'):
                    change = False
                    break
        if change:
            echo(u"\r\n\r\njUSt PAStE iN YOUR PUbliC kEY, MAkE SURE itS "
                 u"All iN ONE lINE!\r\n\r\n\r\n")
            editor = ScrollingEditor(width=term.width - 6,
                                     yloc=term.height - 3,
                                     xloc=3)
            echo(term.reverse_yellow)
            pubkey = editor.read()
            echo(term.normal)
            if pubkey is not None:
                if not pubkey.strip():
                    if user.get('pubkey', None):
                        del user['pubkey']
                    echo(u'\r\n\r\nYOUR SECREtS ARE NEVER SAfE!\r\n')
                else:
                    echo(u'\r\n\r\nWElCOME tO thE bROthERhOOd!\r\n')
                    user['pubkey'] = pubkey
                user.save()
                getch(timeout=1.5)
            else:
                echo(u'\r\n\r\nCANCElEd!!\r\n')
                getch(timeout=0.5)

    elif inp in (u'.',):
        echo(term.move(0, 0) + term.normal + term.clear)
        echo(term.move(int(term.height * .8), 0))
        for line in term.wrap(ABOUT_DOT_PLAN, term.width / 3):
            echo(line.center(term.width).rstrip() + u'\r\n')
        echo(u'\r\n\r\nPRESS ANY kEY ...')
        getch()
        if is_self:
            gosub('editor', '.plan')
        else:
            tmpkey = '%s-%s' % (user.handle, user.plan)
            draft = user.get('.plan', u'')
            session.user[tmpkey] = draft
            gosub('editor', tmpkey)
            if session.user.get(tmpkey, u'') != draft:
                echo(u"\r\n\r\nSEt .PlAN ? [yn]")
                while True:
                    inp2 = getch()
                    if inp2 in (u'y', u'Y'):
                        user['.plan'] = session.user[tmpkey]
                        break
                    elif inp2 in (u'n', u'N'):
                        break
    elif inp in (u'l', u'L'):
        echo(term.move(term.height - 1, 0))
        set_location(user)
        echo(u"\r\n\r\nSEt lOCAtiON tO '%s'? [yn]" % (user.location,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'e', u'E'):
        echo(term.move(term.height - 1, 0))
        set_email(user)
        echo(u"\r\n\r\nSEt EMAil tO '%s'? [yn]" % (user.email,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'i', u'I'):
        echo(u'\r\ntiMEOUt (0=NONE): ')
        timeout = LineEditor(6, str(user.get('timeout', def_timeout))).read()
        try:
            timeout = int(timeout)
        except ValueError:
            echo(invalid)
            return True
        if timeout < 0:
            echo(invalid)
            return True
        echo(u"\r\n\r\nSet tiMEOUt=%s? [yn]" % (
            timeout if timeout else 'None',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['timeout'] = timeout
                session.send_event('set-timeout', timeout)
                break
            elif inp2 in (u'n', u'N'):
                break

    elif inp in (u'm', u'M'):
        mesg = False if user.get('mesg', True) else True
        echo(u"\r\n\r\n%s iNStANt MESSAGiNG? [yn]" % (
            'ENAblE' if mesg else 'DiSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['mesg'] = mesg
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'x', u'X'):
        expert = not user.get('expert', False)
        echo(u"\r\n\r\n%s EXPERt MOdE? [yn]" % (
            'ENAblE' if expert else 'DiSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['expert'] = expert
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'q', u'Q',):
        EXIT = True
    else:
        return False
    return True
Exemplo n.º 2
0
def process_keystroke(lightbar, inp, user):
    """ Process keystroke, ``inp``, for target ``user``. """
    # pylint: disable=R0914,R0912,R0915,R0911,W0603
    #         Too many local variables
    #         Too many branches
    #         Too many statements
    #         Too many return statements
    #         Using the global statement
    from x84.bbs import getsession, getterminal, echo, getch, gosub
    from x84.bbs import LineEditor, Ansi
    from x84.default.nua import set_email, set_location
    global EXIT
    session, term = getsession(), getterminal()
    is_self = bool(user.handle == session.user.handle)
    invalid = u'\r\niNVAlid.'
    if lightbar is not None:
        echo(lightbar.process_keystroke(inp))
        if lightbar.moved:
            return False
    assert is_self or 'sysop' in session.user.groups
    # pylint: disable=W0311
    #         Bad indentation. Found 12 spaces, expected 8
    if is_self and (
        inp in (u'c', u'C') or (inp == term.KEY_ENTER and
                                lightbar is not None and
                                lightbar.selection[0] == u'c')):
            gosub('charset')
    elif is_self and (
        inp in (u't', u'T') or (inp == term.KEY_ENTER and
                                lightbar is not None and
                                lightbar.selection[0] == u't')):
            echo(term.move(term.height - 1, 0))
            echo(ABOUT_TERM + u'\r\n')
            echo(u'\r\ntERMiNAl tYPE: ')
            term = LineEditor(30, session.env.get('TERM')).read()
            echo(u"\r\n\r\nset TERM to '%s'? [yn]" % (term,))
            while True:
                inp2 = getch()
                if inp2 in (u'y', u'Y'):
                    session.env['TERM'] = term
                    break
                elif inp2 in (u'n', u'N'):
                    break
    elif is_self and (
        inp in (u'w', u'W') or (inp == term.KEY_ENTER and
                                lightbar is not None and
                                lightbar.selection[0] == u'w')):
            echo(u'\r\ntERMiNAl Width: ')
            width = LineEditor(3, str(term.width)).read()
            try:
                width = int(width)
            except ValueError:
                echo(invalid)
                return True
            if width < 0 or width > 999:
                echo(invalid)
                return True
            echo(u"\r\n\r\nset COLUMNS=%d? [yn]" % (width,))
            while True:
                inp2 = getch()
                if inp2 in (u'y', u'Y'):
                    term.columns = width
                    break
                elif inp2 in (u'n', u'N'):
                    break
    elif is_self and (
            inp in (u'h', u'H') or (inp == term.KEY_ENTER and
                                    lightbar is not None and
                                    lightbar.selection[0] == u'h')):
            echo(u'\r\ntERMiNAl hEiGht: ')
            height = LineEditor(3, str(term.height)).read()
            try:
                height = int(height)
            except ValueError:
                echo(invalid)
                return True
            if height < 0 or height > 999:
                echo(invalid)
                return True
            echo(u"\r\n\r\nset LINES=%d? [yn]" % (height,))
            while True:
                inp2 = getch()
                if inp2 in (u'y', u'Y'):
                    term.rows = height
                    break
                elif inp2 in (u'n', u'N'):
                    break
    elif ('sysop' in session.user.groups and (
        inp in (u'd', u'D',) or (inp == term.KEY_ENTER and
                                 lightbar is not None and
                                 lightbar.selection[0] == u'd'))):
        echo(u"\r\n\r\ndElEtE %s ? [yn]" % (user.handle,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.delete()
                break
            elif inp2 in (u'n', u'N'):
                break
        EXIT = True
    elif 'sysop' in session.user.groups and (
            inp in (u's', u'S',) or (inp == term.KEY_ENTER and
                                     lightbar is not None and
                                     lightbar.selection[0] == u's')):
        sysop = not 'sysop' in user.groups
        echo(u"\r\n\r\n%s SYSOP ACCESS? [yn]" % (
            'ENAblE' if sysop else 'diSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                if sysop:
                    user.groups.add('sysop')
                else:
                    user.groups.remove('sysop')
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'p',) or (inp == term.KEY_ENTER and
                            lightbar is not None and
                            lightbar.selection[0] == u'p'):
        from x84.default.nua import set_password
        set_password(user)
        echo(u"\r\n\r\nSEt PASSWORd ? [yn]")
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'.',) or (inp == term.KEY_ENTER and
                            lightbar is not None and
                            lightbar.selection[0] == u'.'):
        echo(term.move(0, 0) + term.normal + term.clear)
        echo(term.move(int(term.height * .8), 0))
        for line in Ansi(ABOUT_DOT_PLAN).wrap(
                term.width / 3).splitlines():
            echo(line.center(term.width).rstrip() + u'\r\n')
        echo(u'\r\n\r\nPRESS ANY kEY ...')
        getch()
        if is_self:
            gosub('editor', '.plan')
        else:
            tmpkey = '%s-%s' % (user.handle, user.plan)
            draft = user.get('.plan', u'')
            session.user[tmpkey] = draft
            gosub('editor', tmpkey)
            if session.user.get(tmpkey, u'') != draft:
                echo(u"\r\n\r\nSEt .PlAN ? [yn]")
                while True:
                    inp2 = getch()
                    if inp2 in (u'y', u'Y'):
                        user['.plan'] = session.user[tmpkey]
                        break
                    elif inp2 in (u'n', u'N'):
                        break
    elif inp in (u'l', u'L') or (inp == term.KEY_ENTER and
                                 lightbar is not None and
                                 lightbar.selection[0] == u'l'):
        echo(term.move(term.height - 1, 0))
        set_location(user)
        echo(u"\r\n\r\nSEt lOCAtiON tO '%s'? [yn]" % (user.location,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'e', u'E') or (inp == term.KEY_ENTER and
                                 lightbar is not None and
                                 lightbar.selection[0] == u'e'):
        echo(term.move(term.height - 1, 0))
        set_email(user)
        echo(u"\r\n\r\nSEt EMAil tO '%s'? [yn]" % (user.email,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'm', u'M') or (inp == term.KEY_ENTER and
                                 lightbar is not None and
                                 lightbar.selection[0] == u'm'):
        mesg = False if user.get('mesg', True) else True
        echo(u"\r\n\r\n%s iNStANt MESSAGiNG? [yn]" % (
            'ENAblE' if mesg else 'DiSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['mesg'] = mesg
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'x', u'X') or (inp == term.KEY_ENTER and
                                 lightbar is not None and
                                 lightbar.selection[0] == u'x'):
        expert = not user.get('expert', False)
        echo(u"\r\n\r\n%s EXPERt MOdE? [yn]" % (
            'ENAblE' if expert else 'DiSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['expert'] = expert
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'q', u'Q',) or (inp == term.KEY_ENTER and
                                  lightbar is not None and
                                  lightbar.selection[0] == u'q'):
        EXIT = True
    else:
        return False
    return True
Exemplo n.º 3
0
def main(handle):
    """ Main procedure. """
    # pylint: disable=R0914,R0915,R0911
    #         Too many local variables
    #         Too many statements
    #         Too many return statements
    # by request from midget; a password reset form
    session, term = getsession(), getterminal()
    session.activity = 'resetting password for %s' % (handle, )
    user = get_user(handle)
    logger = logging.getLogger()

    prompt_email = u'\r\n\r\nENtER E-MAil fOR %r: '
    msg_nfound = u'\r\n\r\n%r NOt fOUNd iN USERbASE.'
    msg_cancelled = u'\r\n CANCEllEd.'
    msg_wrong = u'\r\n\r\nWRONG'
    msg_mailsubj = u'passkey for %s' % (ini.CFG.get('system', 'bbsname'))
    msg_mailbody = u'Your passkey is %r'
    msg_mailfrom = ini.CFG.get('system', 'mail_addr')
    msg_sent = u'\r\n\r\nPASSkEY hAS bEEN SENt tO %s.'
    prompt_passkey = u'\r\n\r\nENtER PASSkEY: '
    msg_verified = u'\r\n\r\nYOU hAVE bEEN VERifiEd.'

    echo(term.normal)
    if not handle in list_users():
        echo(term.bold_red(msg_nfound))
        getch()
        return False

    width = ini.CFG.getint('nua', 'max_email')
    email = None
    tries = 0
    while True:
        tries += 1
        if tries > 5:
            logger.warn('%r email retries exceeded', handle)
            return False
        echo(prompt_email % (handle, ))
        try_email = LineEditor(width).read()
        if try_email is None or 0 == len(try_email):
            echo(term.normal + msg_cancelled)
            return False

        # fetch user record email
        email = get_user(handle).email
        if email is None or 0 == len(email):
            logger.warn('%r missing email address, cannot send', handle)
            echo(term.bold_red(msg_wrong))

        elif email.lower() != try_email.lower():
            logger.warn('%r failed email %r (try: %r)', handle, email,
                        try_email)
            echo(term.bold_red(msg_wrong))

        else:
            logger.info('%r requests password reset to %r', handle, email)
            break

    # generate a 'passkey' and e-mail out of band, and request input
    passkey = base64.encodestring(os.urandom(ini.CFG.getint(
        'nua', 'max_pass')))[:ini.CFG.getint('nua', 'max_pass')]
    msg = MIMEText(msg_mailbody % (passkey, ))
    msg['From'] = msg_mailfrom
    msg['To'] = email
    msg['Subject'] = msg_mailsubj
    # pylint: disable=W0703
    #         Catching too general exception Exception
    err = None
    try:
        smtp = smtplib.SMTP(ini.CFG.get('system', 'mail_smtphost'))
        smtp.sendmail(msg_mailfrom, [email], msg.as_string())
        smtp.quit()
    except Exception as err:
        logger.exception(err)
        echo('u\r\n\r\n' + term.bold_red(str(err)) + u'\r\n')
        getch(2)
        return False

    echo(msg_sent % (email, ))
    width = len(passkey)
    email = None
    tries = 0
    while True:
        tries += 1
        if tries > 5:
            logger.warn("passkey retries exceeded for user '%s'", handle)
            return False

        echo(term.normal + u'\r\n\r\n')
        echo(prompt_passkey)
        try_passkey = LineEditor(width).read()
        if try_passkey is None or 0 == len(try_passkey):
            echo(term.normal + msg_cancelled)
            logger.warn("cancelled passkey for user '%s'", handle)
            return False

        if passkey == try_passkey:
            echo(term.bold_green(msg_verified))
            echo(u'\r\n\r\n')
            break
        logger.warn("failed passkey for user '%s': '%s', tried '%s')", handle,
                    passkey, try_passkey)
        echo(term.bold_red(msg_wrong))

    set_password(user)
    user.save()
    return True
Exemplo n.º 4
0
def main(handle):
    """ Main procedure. """
    # pylint: disable=R0914,R0915,R0911
    #         Too many local variables
    #         Too many statements
    #         Too many return statements
    # by request from midget; a password reset form
    session, term = getsession(), getterminal()
    session.activity = 'resetting password for %s' % (handle,)
    user = get_user(handle)
    logger = logging.getLogger()

    prompt_email = u'\r\n\r\nENtER E-MAil fOR %r: '
    msg_nfound = u'\r\n\r\n%r NOt fOUNd iN USERbASE.'
    msg_cancelled = u'\r\n CANCEllEd.'
    msg_wrong = u'\r\n\r\nWRONG'
    msg_mailsubj = u'passkey for %s' % (ini.CFG.get('system', 'bbsname'))
    msg_mailbody = u'Your passkey is %r'
    msg_mailfrom = ini.CFG.get('system', 'mail_addr')
    msg_sent = u'\r\n\r\nPASSkEY hAS bEEN SENt tO %s.'
    prompt_passkey = u'\r\n\r\nENtER PASSkEY: '
    msg_verified = u'\r\n\r\nYOU hAVE bEEN VERifiEd.'

    echo(term.normal)
    if not handle in list_users():
        echo(term.bold_red(msg_nfound))
        getch()
        return False

    width = ini.CFG.getint('nua', 'max_email')
    email = None
    tries = 0
    while True:
        tries += 1
        if tries > 5:
            logger.warn('%r email retries exceeded', handle)
            return False
        echo(prompt_email % (handle,))
        try_email = LineEditor(width).read()
        if try_email is None or 0 == len(try_email):
            echo(term.normal + msg_cancelled)
            return False

        # fetch user record email
        email = get_user(handle).email
        if email is None or 0 == len(email):
            logger.warn('%r missing email address, cannot send', handle)
            echo(term.bold_red(msg_wrong))

        elif email.lower() != try_email.lower():
            logger.warn('%r failed email %r (try: %r)', handle,
                        email, try_email)
            echo(term.bold_red(msg_wrong))

        else:
            logger.info('%r requests password reset to %r', handle, email)
            break

    # generate a 'passkey' and e-mail out of band, and request input
    passkey = base64.encodestring(
        os.urandom(ini.CFG.getint('nua', 'max_pass'))
    )[:ini.CFG.getint('nua', 'max_pass')]
    msg = MIMEText(msg_mailbody % (passkey,))
    msg['From'] = msg_mailfrom
    msg['To'] = email
    msg['Subject'] = msg_mailsubj
    # pylint: disable=W0703
    #         Catching too general exception Exception
    err = None
    try:
        smtp = smtplib.SMTP(ini.CFG.get('system', 'mail_smtphost'))
        smtp.sendmail(msg_mailfrom, [email], msg.as_string())
        smtp.quit()
    except Exception as err:
        logger.exception(err)
        echo('u\r\n\r\n' + term.bold_red(str(err)) + u'\r\n')
        getch(2)
        return False

    echo(msg_sent % (email,))
    width = len(passkey)
    email = None
    tries = 0
    while True:
        tries += 1
        if tries > 5:
            logger.warn("passkey retries exceeded for user '%s'", handle)
            return False

        echo(term.normal + u'\r\n\r\n')
        echo(prompt_passkey)
        try_passkey = LineEditor(width).read()
        if try_passkey is None or 0 == len(try_passkey):
            echo(term.normal + msg_cancelled)
            logger.warn("cancelled passkey for user '%s'", handle)
            return False

        if passkey == try_passkey:
            echo(term.bold_green(msg_verified))
            echo(u'\r\n\r\n')
            break
        logger.warn("failed passkey for user '%s': '%s', tried '%s')",
                    handle, passkey, try_passkey)
        echo(term.bold_red(msg_wrong))

    set_password(user)
    user.save()
    return True
Exemplo n.º 5
0
def process_keystroke(inp, user):
    """ Process keystroke, ``inp``, for target ``user``. """
    # pylint: disable=R0914,R0912,R0915,R0911,W0603
    #         Too many local variables
    #         Too many branches
    #         Too many statements
    #         Too many return statements
    #         Using the global statement
    # ^ lol, this is one of those things that should be
    #   refactored into smaller subroutines =)
    from x84.bbs import getsession, getterminal, echo, getch, gosub
    from x84.bbs import LineEditor, Ansi
    from x84.default.nua import set_email, set_location
    from x84.bbs.ini import CFG
    def_timeout = CFG.getint('system', 'timeout')
    global EXIT
    session, term = getsession(), getterminal()
    is_self = bool(user.handle == session.user.handle)
    invalid = u'\r\niNVAlid.'
    assert is_self or 'sysop' in session.user.groups

    if is_self and inp in (u'^',):
        user['sausercookie'] = u''
        user['sapasscookie'] = u''
    if is_self and inp in (u'c', u'C'):
        gosub('charset')

    elif is_self and inp in (u'@',):
        echo(u'\r\neNTER SA \'pass\' cookie: ')
        sapasscookie = LineEditor(50, session.user['sapasscookie']).read()
        echo(u"\r\n\r\nset SA pass cookie to '%s'? [yn]" % (sapasscookie,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                session.user['sapasscookie'] = sapasscookie
                break
            elif inp2 in (u'n', u'N'):
                break

    elif is_self and inp in (u'!',):
        echo(u'\r\neNTER SA \'user\' cookie: ')
        sausercookie = LineEditor(30, session.user['sausercookie']).read()
        echo(u"\r\n\r\nset SA user cookie to '%s'? [yn]" % (sausercookie,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                session.user['sausercookie'] = sausercookie
                break
            elif inp2 in (u'n', u'N'):
                break

    elif is_self and inp in (u't', u'T'):
        echo(term.move(term.height - 1, 0))
        echo(ABOUT_TERM + u'\r\n')
        echo(u'\r\ntERMiNAl tYPE: ')
        term = LineEditor(30, session.env.get('TERM')).read()
        echo(u"\r\n\r\nset TERM to '%s'? [yn]" % (term,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                session.env['TERM'] = term
                break
            elif inp2 in (u'n', u'N'):
                break

    elif is_self and inp in (u'w', u'W'):
        echo(u'\r\ntERMiNAl Width: ')
        width = LineEditor(3, str(term.width)).read()
        try:
            width = int(width)
        except ValueError:
            echo(invalid)
            return True
        if width < 0 or width > 999:
            echo(invalid)
            return True
        echo(u"\r\n\r\nset COLUMNS=%d? [yn]" % (width,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                term.columns = width
                break
            elif inp2 in (u'n', u'N'):
                break

    elif is_self and inp in (u'h', u'H'):
        echo(u'\r\ntERMiNAl hEiGht: ')
        height = LineEditor(3, str(term.height)).read()
        try:
            height = int(height)
        except ValueError:
            echo(invalid)
            return True
        if height < 0 or height > 999:
            echo(invalid)
            return True
        echo(u"\r\n\r\nset LINES=%d? [yn]" % (height,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                term.rows = height
                break
            elif inp2 in (u'n', u'N'):
                break

    elif 'sysop' in session.user.groups and inp in (u'd', u'D',):
        echo(u"\r\n\r\ndElEtE %s ? [yn]" % (user.handle,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.delete()
                break
            elif inp2 in (u'n', u'N'):
                break
        EXIT = True

    elif 'sysop' in session.user.groups and inp in (u's', u'S',):
        sysop = not 'sysop' in user.groups
        echo(u"\r\n\r\n%s SYSOP ACCESS? [yn]" % (
            'ENAblE' if sysop else 'diSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                if sysop:
                    user.groups.add('sysop')
                else:
                    user.groups.remove('sysop')
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'p', u'P'):
        from x84.default.nua import set_password
        set_password(user)
        echo(u"\r\n\r\nSEt PASSWORd ? [yn]")
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'.',):
        echo(term.move(0, 0) + term.normal + term.clear)
        echo(term.move(int(term.height * .8), 0))
        for line in Ansi(ABOUT_DOT_PLAN).wrap(
                term.width / 3).splitlines():
            echo(line.center(term.width).rstrip() + u'\r\n')
        echo(u'\r\n\r\nPRESS ANY kEY ...')
        getch()
        if is_self:
            gosub('editor', '.plan')
        else:
            tmpkey = '%s-%s' % (user.handle, user.plan)
            draft = user.get('.plan', u'')
            session.user[tmpkey] = draft
            gosub('editor', tmpkey)
            if session.user.get(tmpkey, u'') != draft:
                echo(u"\r\n\r\nSEt .PlAN ? [yn]")
                while True:
                    inp2 = getch()
                    if inp2 in (u'y', u'Y'):
                        user['.plan'] = session.user[tmpkey]
                        break
                    elif inp2 in (u'n', u'N'):
                        break
    elif inp in (u'l', u'L'):
        echo(term.move(term.height - 1, 0))
        set_location(user)
        echo(u"\r\n\r\nSEt lOCAtiON tO '%s'? [yn]" % (user.location,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'e', u'E'):
        echo(term.move(term.height - 1, 0))
        set_email(user)
        echo(u"\r\n\r\nSEt EMAil tO '%s'? [yn]" % (user.email,))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user.save()
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'i', u'I'):
        echo(u'\r\ntiMEOUt (0=NONE): ')
        timeout = LineEditor(6, str(user.get('timeout', def_timeout))).read()
        try:
            timeout = int(timeout)
        except ValueError:
            echo(invalid)
            return True
        if timeout < 0:
            echo(invalid)
            return True
        echo(u"\r\n\r\nSet tiMEOUt=%s? [yn]" % (
            timeout if timeout else 'None',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['timeout'] = timeout
                session.send_event('set-timeout', timeout)
                break
            elif inp2 in (u'n', u'N'):
                break

    elif inp in (u'm', u'M'):
        mesg = False if user.get('mesg', True) else True
        echo(u"\r\n\r\n%s iNStANt MESSAGiNG? [yn]" % (
            'ENAblE' if mesg else 'DiSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['mesg'] = mesg
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'x', u'X'):
        expert = not user.get('expert', False)
        echo(u"\r\n\r\n%s EXPERt MOdE? [yn]" % (
            'ENAblE' if expert else 'DiSAblE',))
        while True:
            inp2 = getch()
            if inp2 in (u'y', u'Y'):
                user['expert'] = expert
                break
            elif inp2 in (u'n', u'N'):
                break
    elif inp in (u'q', u'Q',):
        EXIT = True
    else:
        return False
    return True