def main(handle=u''): """ Main procedure. """ # pylint: disable=R0914 # Too many local variables from x84.bbs import getsession, getterminal, echo, ini, User, goto from x84.bbs import showcp437 session, term = getsession(), getterminal() import os session.activity = u'Applying for an account' artfile = os.path.join(os.path.dirname(__file__), 'art', 'nua.asc') msg_header = u'NEW USER APPliCAtiON' # pylint: disable=E1103 # Instance of '_Chainmap' has no 'split' member # (but some types could not be inferred) newcmds = ini.CFG.get('matrix', 'newcmds').split() topscript = ini.CFG.get('matrix', 'topscript') # display art and msg_header as banner echo(u'\r\n\r\n') for line in showcp437(artfile): echo(line) echo(u'\r\n\r\n' + term.reverse + msg_header.center(term.width)) # create new user record for manipulation user = User(handle if handle.lower() not in newcmds else u'') while True: set_handle(user) set_location(user) set_email(user) set_password(user) set_sacookies(user) if prompt_ok(): user.save() goto(topscript, user.handle)
def refresh(): """ Refresh main menu. """ # pylint: disable=R0914 # Too many local variables from x84.bbs import getsession, getterminal, echo, showcp437, ini import os session, term = getsession(), getterminal() session.activity = u'Main menu' artfile = os.path.join(os.path.dirname(__file__), 'art', 'main.asc') echo(u''.join(( u'\r\n\r\n', term.blue(u'/'.rjust(term.width / 2)), term.bold_black(u'/ '), term.bold('x'), term.bold_blue('/'), term.bold('84'), u' ', 'MAiN MENU', u'\r\n'))) for line in showcp437(artfile): echo(line) echo(u'\r\n\r\n') entries = [ ('b', 'bS NEXUS'), ('l', 'ASt CAllS'), ('o', 'NE liNERS'), ('w', "hO'S ONliNE"), ('n', 'EWS'), ('c', 'hAt'), ('!', 'ENCOdiNG'), ('t', 'EtRiS'), ('s', 'YS. iNfO'), ('u', 'SER LiST'), ('f', 'ORECASt'), ('e', 'dit PROfilE'), ('p', 'OSt A MSG'), ('r', 'EAd All MSGS'), ('g', 'OOdbYE /lOGOff'),] # add LORD to menu only if enabled, if ini.CFG.getboolean('dosemu', 'enabled') and ( ini.CFG.get('dosemu', 'lord_path') != 'no'): entries.insert(0, ('#', 'PlAY lORd!')) if 'sysop' in session.user.groups: entries += (('v', 'idEO CASSEttE'),) buf_str = u'' for key, name in entries: out_str = u''.join(( term.bold(u'('), term.bold_blue_underline(key), term.bold(u')'), term.bold_blue(name.split()[0]), u' ', u' '.join(name.split()[1:]), u' ')) ansilen = term.length(buf_str + out_str) if ansilen >= (term.width * .8): echo(term.center(buf_str) + u'\r\n\r\n') buf_str = out_str else: buf_str += out_str echo(term.center(buf_str) + u'\r\n\r\n') echo(u' [%s]:' % ( term.blue_underline(''.join([key for key, name in entries]))))
def refresh_all(idx=None): """ refresh screen, database, and return database index """ echo(u''.join((u'\r\n\r\n', term.clear_eol,))) for line in showcp437(artfile): echo(line) idx = refresh_automsg(-1 if idx is None else idx) refresh_prompt(prompt_msg) return idx
def refresh_all(idx=None): """ refresh screen, database, and return database index """ echo(u''.join(( u'\r\n\r\n', term.clear_eol, ))) for line in showcp437(artfile): echo(line) idx = refresh_automsg(-1 if idx is None else idx) refresh_prompt(prompt_msg) return idx
def banner(): """ Return centered banner """ from x84.bbs import getterminal, from_cp437, showcp437 import os term = getterminal() output = u'' output += u'\r\n\r\n' + term.normal if term.width >= 78: output += term.home + term.normal + term.clear artfile = os.path.join(os.path.dirname(__file__), 'art', 'ol.ans') for line in showcp437(artfile): output = output + term.move_x((term.width/2)-40)+line return output + term.normal
def display_intro(): """ Display art, 256-color badge, and '!'encoding help. """ from x84.bbs import getterminal, showcp437, echo import os term = getterminal() # display random artwork .. artfile = os.path.join(os.path.dirname(__file__), 'art', '*.ans' if term.number_of_colors != 0 else '*.asc') echo(u'\r\n\r\n') for line in showcp437(artfile): echo(line) if term.number_of_colors == 256 and term.kind.startswith('xterm'): echo(u''.join(( term.normal, '\r\n\r\n', BADGE256, u'\r\n', u'\r\n'))) echo(u'! to change encoding\r\n')
def banner(): session, term = getsession(), getterminal() art_file = os.path.join(os.path.dirname(__file__), 'art', 'automsg.ans') echo(term.clear) for line in showcp437(art_file): echo(line) if not os.path.exists(get_datafile_path()): with codecs.open(get_datafile_path(), 'w', 'utf-8') as fo: fo.write('big brother\n') fo.write('behave yourselves.\n') fo.write('\n\n') echo(term.move(9, 9) + term.white(u'Public message from:')) with codecs.open(get_datafile_path(), 'r', 'utf-8') as fo: handle = fo.readline().strip() echo(term.move(9, 30) + term.blue_on_green(handle)) for row in range(1, 4): echo(term.move(10 + row, 9) + term.yellow(fo.readline().strip())) ask(u'do you want to write a new public message? ')
def refresh(items=[ 'all', ]): """ Refresh main menu. """ # pylint: disable=R0914 # Too many local variables from x84.bbs import getsession, getterminal, echo, Ansi, showcp437, ini, AnsiWindow import os import random, time, glob session, term = getsession(), getterminal() session.activity = u'Main menu' headers = glob.glob( os.path.join(os.path.dirname(__file__), "art", "YOSBBS*.ANS")) bannername = "YOSBBS" + str(random.randrange( 1, len(headers))).zfill(2) + ".ANS" artfile = os.path.join(os.path.dirname(__file__), 'art', bannername) echo(term.clear()) for line in showcp437(artfile): echo(line) echo(u'\r\n\r\n') entries = [ # ('b', 'bS NEXUS'), ('y', 'OsPOsT'), ('l', 'ASt CAllS'), ('o', 'NE liNERS'), ('w', "hO'S ONliNE"), ('n', 'EWS'), # ('c', 'hAt'), ('!', 'ENCOdiNG'), # ('t', 'EtRiS'), # ('s', 'YS. iNfO'), ('f', 'ORECASt'), ('e', 'dit PROfilE'), # ('p', 'OSt A MSG'), # ('r', 'EAd All MSGS'), ('g', 'eT OUt'), ] # add LORD to menu only if enabled, #if ini.CFG.getboolean('dosemu', 'enabled'):# and ( #ini.CFG.get('dosemu', 'lord_path') != 'no'): entries.insert(0, ('#', 'PlAY lORd!')) #if 'sysop' in session.user.groups: # entries += (('v', 'idEO CASSEttE'),) menu_item_width = 20 #allows us 16 char columns after pad/key menu_columns = 4 menulist = list() buf_str = u'' menucol = 1 for key, name in entries: menutext = u''.join(( term.green(name.split()[0]), u' ', u' '.join(name.split()[1:]), )) out_str = Ansi(u''.join( (term.bold(u'('), term.bold_green_underline(key), term.bold(u')'), menutext, u' '))).ljust(menu_item_width) buf_str += out_str menucol += 1 if menucol > menu_columns: menulist.append(buf_str) buf_str = u'' menucol = 1 if len(buf_str) > 0: menulist.append(buf_str) echo(term.move(term.height - len(menulist) - 1, 0)) for i, m in enumerate(menulist): echo(term.move(term.height - i - 2, 0)) echo(Ansi(m).ljust(term.width)) echo(term.move(term.height - 1, 0)) echo(u' [%s]:' % (term.blue_underline(''.join([key for key, name in entries]))))
def main(): """ Main procedure. """ # pylint: disable=R0914,R0911 # Too many local variables import logging from x84.bbs import getsession, getterminal, ini, echo, get_user, goto from x84.bbs import find_user, showcp437 from x84.engine import __url__ as url logger = logging.getLogger() session, term = getsession(), getterminal() session.activity = u'Logging in' handle = (session.env.get('USER', '').decode('iso8859-1', 'replace')) anon_allowed_msg = u"'%s' login enabled.\r\n" % ( term.bold_cyan('anonymous',)) # pylint: disable=E1103 # Instance of '_Chainmap' has no 'split' member # (but some types could not be inferred) newcmds = ini.CFG.get('matrix', 'newcmds').split() apply_msg = u"'%s' to create new account.\r\n" % ( term.bold_cyan(newcmds[0]),) allow_apply = ini.CFG.getboolean('nua', 'allow_apply') enable_anonymous = ini.CFG.getboolean('matrix', 'enable_anonymous') enable_pwreset = ini.CFG.getboolean('matrix', 'enable_pwreset') bbsname = ini.CFG.get('system', 'bbsname') artfile = os.path.join(os.path.dirname(__file__), 'art', 'xz-1984.ans') topscript = ini.CFG.get('matrix', 'topscript') max_tries = 10 session.flush_event('refresh') #uname() # display banner echo(u''.join(( term.normal, u'\r\n', u'Connected to %s, see %s for source\r\n' % (bbsname, url),))) for line in showcp437(artfile): echo(line) echo(term.normal) echo (u''.join(( u'\r\n\r\n', term.bold(u'tERM'), u': ', term.cyan_underline(session.env['TERM']), u'\r\n', term.bold(u'diMENSiONs'), u': ', '%s%s%s' % ( term.bold_cyan(str(term.width)), term.cyan(u'x'), term.bold_cyan(str(term.height)),), u'\r\n', term.bold(u'ENCOdiNG'), u': ', term.cyan_underline(session.encoding), u'\r\n\r\n', anon_allowed_msg if enable_anonymous else u'', apply_msg if allow_apply else u'', ))) # http://www.termsys.demon.co.uk/vtansi.htm # disable line-wrapping echo(unichr(27) + u'[7l') # http://www.xfree86.org/4.5.0/ctlseqs.html # Save xterm icon and window title on stack. echo(unichr(27) + u'[22;0t') if handle: echo('\r\nHello, %s!' % (handle,)) match = find_user(handle) if match is not None: handle = match else: handle = '' # prompt for username & password for _num in range(0, max_tries): handle = get_username(handle) if handle != u'': session.activity = u'Logging in' user = get_user(handle) if try_pass(user): goto(topscript, user.handle) echo(u'\r\n\r\n') if enable_pwreset: try_reset(user) else: logger.info('%r failed password', handle) logger.warn('maximum tries exceeded') goto('logoff')
def refresh(items=['all',]): """ Refresh main menu. """ # pylint: disable=R0914 # Too many local variables from x84.bbs import getsession, getterminal, echo, Ansi, showcp437, ini, AnsiWindow import os import random, time, glob session, term = getsession(), getterminal() session.activity = u'Main menu' headers = glob.glob(os.path.join(os.path.dirname(__file__),"art","YOSBBS*.ANS")) bannername = "YOSBBS"+str(random.randrange(1,len(headers))).zfill(2)+".ANS" artfile = os.path.join(os.path.dirname(__file__), 'art', bannername) echo(term.clear()) for line in showcp437(artfile): echo(line) echo(u'\r\n\r\n') entries = [ # ('b', 'bS NEXUS'), ('y', 'OsPOsT'), ('l', 'ASt CAllS'), ('o', 'NE liNERS'), ('w', "hO'S ONliNE"), ('n', 'EWS'), # ('c', 'hAt'), ('!', 'ENCOdiNG'), # ('t', 'EtRiS'), # ('s', 'YS. iNfO'), ('f', 'ORECASt'), ('e', 'dit PROfilE'), # ('p', 'OSt A MSG'), # ('r', 'EAd All MSGS'), ('g', 'eT OUt'),] # add LORD to menu only if enabled, #if ini.CFG.getboolean('dosemu', 'enabled'):# and ( #ini.CFG.get('dosemu', 'lord_path') != 'no'): entries.insert(0, ('#', 'PlAY lORd!')) #if 'sysop' in session.user.groups: # entries += (('v', 'idEO CASSEttE'),) menu_item_width = 20; #allows us 16 char columns after pad/key menu_columns = 4 menulist = list() buf_str = u'' menucol = 1 for key, name in entries: menutext =u''.join((term.green(name.split()[0]), u' ', u' '.join(name.split()[1:]), )) out_str = Ansi(u''.join(( term.bold(u'('), term.bold_green_underline(key), term.bold(u')'), menutext, u' '))).ljust(menu_item_width) buf_str += out_str menucol += 1 if menucol > menu_columns: menulist.append(buf_str) buf_str = u'' menucol = 1 if len(buf_str) > 0: menulist.append(buf_str) echo(term.move(term.height - len(menulist) - 1,0)) for i, m in enumerate(menulist): echo(term.move(term.height - i - 2,0)) echo(Ansi(m).ljust(term.width)) echo(term.move(term.height - 1,0)) echo(u' [%s]:' % ( term.blue_underline(''.join([key for key, name in entries]))))
def main(): """ Main procedure. """ # pylint: disable=R0914,R0911 # Too many local variables import logging from x84.bbs import getsession, getterminal, ini, echo, get_user, goto from x84.bbs import find_user, showcp437 from x84.engine import __url__ as url import random, time, glob logger = logging.getLogger() session, term = getsession(), getterminal() session.activity = u'Logging in' handle = (session.env.get('USER', '').decode('iso8859-1', 'replace')) anon_allowed_msg = u"'%s' login enabled.\r\n" % (term.bold_cyan( 'anonymous', )) # pylint: disable=E1103 # Instance of '_Chainmap' has no 'split' member # (but some types could not be inferred) newcmds = ini.CFG.get('matrix', 'newcmds').split() apply_msg = u"'%s' to create new account.\r\n" % (term.bold_cyan( newcmds[0]), ) allow_apply = ini.CFG.getboolean('nua', 'allow_apply') enable_anonymous = ini.CFG.getboolean('matrix', 'enable_anonymous') enable_pwreset = ini.CFG.getboolean('matrix', 'enable_pwreset') bbsname = ini.CFG.get('system', 'bbsname') headers = glob.glob( os.path.join(os.path.dirname(__file__), "art", "YOSBBS*.ANS")) bannername = "YOSBBS" + str(random.randrange( 1, len(headers))).zfill(2) + ".ANS" artfile = os.path.join(os.path.dirname(__file__), 'art', bannername) topscript = ini.CFG.get('matrix', 'topscript') max_tries = 10 session.flush_event('refresh') #uname() # display banner echo(u''.join(( term.normal, u'\r\n', u'Connected to %s, see %s for source\r\n' % (bbsname, url), ))) time.sleep(1) echo(term.clear()) for line in showcp437(artfile): echo(line) echo(term.normal) echo(term.move(term.height - 2, 0)) echo(u''.join(( term.bold(u'tERM'), u': ', term.cyan_underline(session.env['TERM']), term.bold(u' diMENSiONs'), u': ', '%s%s%s' % ( term.bold_cyan(str(term.width)), term.cyan(u'x'), term.bold_cyan(str(term.height)), ), term.bold(u' ENCOdiNG'), u': ', term.cyan_underline(session.encoding), anon_allowed_msg if enable_anonymous else u'', u' ', apply_msg if allow_apply else u'', ))) # http://www.termsys.demon.co.uk/vtansi.htm # disable line-wrapping echo(unichr(27) + u'[7l') # http://www.xfree86.org/4.5.0/ctlseqs.html # Save xterm icon and window title on stack. echo(unichr(27) + u'[22;0t') if handle: echo('\r\nHello, %s!' % (handle, )) match = find_user(handle) if match is not None: handle = match else: handle = '' # prompt for username & password for _num in range(0, max_tries): handle = get_username(handle) if handle != u'': session.activity = u'Logging in' user = get_user(handle) if try_pass(user): goto(topscript, user.handle) echo(u'\r\n\r\n') if enable_pwreset: try_reset(user) else: logger.info('%r failed password', handle) logger.warn('maximum tries exceeded') goto('logoff')