Beispiel #1
0
 def run(self, args, conn):
     number = args[0]
     if number >= len(tourney.tourneys):
         conn.write('Tourney number %d not found.\n' % number)
         return
     conn.write(
         '+----------------------------------------------------------+\n')
     conn.write(
         '| Player Handle             | Rating | Score | Status      |\n')
     conn.write(
         '+---------------------------+--------+-------+-------------+\n')
     for u in tourney.tourneys[number].players:
         rating = tourney.tourneys[number].player_ratings[u]
         score = tourney.tourneys[number].player_scores[u]
         # get status of player
         if not user.find_by_name_exact(u).is_online:
             status = "Offline"
         elif u in tourney.tourneys[number].players_bye:
             status = "Ready (BYE)"
         elif user.find_by_name_exact(u).session.game:
             status = "Playing"
         else:
             status = "Ready"
         conn.write('| %-26s| %-7s| %-6s| %-12s|\n' %
                    (u, rating, score, status))
     conn.write(
         '+----------------------------------------------------------+\n')
Beispiel #2
0
 def run(self, args, conn):
     if not conn.user.has_title('TD'):
         conn.write(_('Only TD programs are allowed to use this command\n'))
         return
     msg = args[1].replace('\\n', '\n:').replace('\\b', '\x07').replace('\\H', '\x1b[7m').replace('\\h', '\x1b[0m')
     msg = '\n:%s\n' % msg
     ret = 0 # 0 means success
     if type(args[0]) == type(1):
         # qtell channel
         try:
             ch = channel.chlist[args[0]]
         except KeyError:
             ret = 1
         else:
             ch.qtell(msg)
     else:
         # qtell user
         try:
             u = user.find_by_name_exact(args[0])
             if not u or not u.is_online:
                 ret = 1
             else:
                 args[0] = u.name
                 u.write(msg)
         except user.UsernameException:
             ret = 1
     conn.write('*qtell %s %d*\n' % (args[0], ret))
Beispiel #3
0
 def announce(self, message):
     for user_name in self.players_in:
         u = user.find_by_name_exact(user_name)
         if u.is_online:
             # fix concat issue - 8/11/2011 -- Ryan
             u.write("> Tournament #" + str(self.number) + ": " + message +
                     "\n")
Beispiel #4
0
 def run(self, args, conn):
     if not conn.user.has_title('TD'):
         conn.write(
             _('Only TD programs are allowed to use this command.\n'))
         return
     try:
         u = user.find_by_name_exact(args[0], online_only=True)
         if u and u.is_online:
             if u.is_guest:
                 # it's not clear why the lasker server only prints
                 # 3 numbers here; I don't know if FICS is any
                 # different
                 conn.write('*getpi %s -1 -1 -1*\n' % u.name)
             else:
                 # on original FICS the wild, blitz, standard, and
                 # lightning ratings are given
                 # TODO: some way to update this for the new system
                 # where each speed and variant has a separate rating?
                 conn.write(
                     '*getpi %s %d %d %d %d*\n' %
                     (u.name, u.get_rating(speed_variant.blitz_chess960),
                      u.get_rating(speed_variant.blitz_chess),
                      u.get_rating(speed_variant.standard_chess),
                      u.get_rating(speed_variant.lightning_chess)))
         else:
             # do nothing
             pass
     except user.UsernameException:
         # do nothing
         pass
Beispiel #5
0
 def run(self, args, conn):
     if not conn.user.has_title('TD'):
         conn.write(_('Only TD programs are allowed to use this command.\n'))
         return
     try:
         u = user.find_by_name_exact(args[0], online_only=True)
         if u and u.is_online:
             if u.is_guest:
                 # it's not clear why the lasker server only prints
                 # 3 numbers here; I don't know if FICS is any
                 # different
                 conn.write('*getpi %s -1 -1 -1*\n' % u.name)
             else:
                 # on original FICS the wild, blitz, standard, and
                 # lightning ratings are given
                 # TODO: some way to update this for the new system
                 # where each speed and variant has a separate rating?
                 conn.write('*getpi %s %d %d %d %d*\n' % (u.name,
                     u.get_rating(speed_variant.blitz_chess960),
                     u.get_rating(speed_variant.blitz_chess),
                     u.get_rating(speed_variant.standard_chess),
                     u.get_rating(speed_variant.lightning_chess)))
         else:
             # do nothing
             pass
     except user.UsernameException:
         # do nothing
         pass
Beispiel #6
0
 def run(self, args, conn):
     if not conn.user.has_title('TD'):
         conn.write(_('Only TD programs are allowed to use this command\n'))
         return
     msg = args[1].replace('\\n', '\n:').replace('\\b', '\x07').replace(
         '\\H', '\x1b[7m').replace('\\h', '\x1b[0m')
     msg = '\n:%s\n' % msg
     ret = 0  # 0 means success
     if type(args[0]) == type(1):
         # qtell channel
         try:
             ch = channel.chlist[args[0]]
         except KeyError:
             ret = 1
         else:
             ch.qtell(msg)
     else:
         # qtell user
         try:
             u = user.find_by_name_exact(args[0])
             if not u or not u.is_online:
                 ret = 1
             else:
                 args[0] = u.name
                 u.write(msg)
         except user.UsernameException:
             ret = 1
     conn.write('*qtell %s %d*\n' % (args[0], ret))
Beispiel #7
0
    def get_user(self, name, conn):
        u = None
        if name.lower() == 'g' or name.lower() == 'guest':
            u = user.GuestUser(None)
            conn.write(_('\nLogging you in as "%s"; you may use this name to play unrated games.\n(After logging in, do "help register" for more info on how to register.)\n\nPress return to enter the server as "%s":\n') % (u.name, u.name))
        elif name != '':
            try:
                u = user.find_by_name_exact(name)
            except user.UsernameException as e:
                conn.write('\n' + e.reason + '\n')
            else:
                if u:
                    if u.is_guest:
                        # It's theoretically possible that
                        # a new user registers but is blocked
                        # from logging in by a guest with the
                        # same name.  We ignore that case.
                        conn.write(_('Sorry, %s is already logged in. Try again.\n') % name)
                        u = None
                    else:
                        conn.write(_('\n"%s" is a registered name.  If it is yours, type the password.\nIf not, just hit return to try another name.\n\npassword: '******'\n"%s" is not a registered name.  You may play unrated games as a guest.\n(After logging in, do "help register" for more info on how to register.)\n\nPress return to enter the server as "%s":\n') % (name, name))

        if u:
            if u.is_guest:
                if filter_.check_filter(conn.ip):
                    # not translated, since the player hasn't logged on
                    conn.write('Due to abuse, guest logins are blocked from your address.\n')
                    conn.loseConnection('filtered')
                    u = None
                if u and online.online.guest_count >= config.maxguest:
                    conn.write(db.get_server_message('full_unreg'))
                    conn.loseConnection('guests full')
                    u = None
            else:
                if u.is_banned:
                    # not translated, since the player hasn't logged on
                    conn.write('Player "%s" is banned.\n' % u.name)
                    conn.loseConnection('banned')
                    u = None

        if u:
            pmax = config.maxplayer if u.is_admin() else (config.maxplayer -
                config.admin_reserve)
            if len(online.online) >= pmax:
                conn.write(db.get_server_message('full'))
                conn.loseConnection('players full')
                u = None

        return u
Beispiel #8
0
 def run(self, args, conn):
     number = args[0]
     if number >= len(tourney.tourneys):
         conn.write('Tourney number %d not found.\n' % number)
         return
     conn.write('+----------------------------------------------------------+\n')
     conn.write('| Player Handle             | Rating | Score | Status      |\n')
     conn.write('+---------------------------+--------+-------+-------------+\n')
     for u in tourney.tourneys[number].players:
         rating = tourney.tourneys[number].player_ratings[u]
         score = tourney.tourneys[number].player_scores[u]
         # get status of player
         if not user.find_by_name_exact(u).is_online:
             status = "Offline"
         elif u in tourney.tourneys[number].players_bye:
             status = "Ready (BYE)"
         elif user.find_by_name_exact(u).session.game:
             status = "Playing"
         else:
             status = "Ready"
         conn.write('| %-26s| %-7s| %-6s| %-12s|\n' % (u, rating, score, status))
     conn.write('+----------------------------------------------------------+\n')
Beispiel #9
0
 def run(self, args, conn):
     [name, email, real_name] = args
     try:
         u = user.find_by_name_exact(name, conn)
     except user.UsernameException:
         conn.write(_('"%s" is not a valid handle.\n') % name)
         return
     if u:
         conn.write(A_('A player named %s is already registered.\n')
             % u.name)
     else:
         passwd = user.make_passwd()
         user_id = user.add_user(name, email, passwd, real_name)
         #db.add_comment(conn.user.id, user_id,
         #    'Player added by %s using addplayer.' % conn.user.name)
         conn.write(A_('Added: >%s< >%s< >%s< >%s<\n')
             % (name, real_name, email, passwd))
Beispiel #10
0
 def run(self, args, conn):
     if not conn.user.has_title('TD'):
         conn.write(
             _('Only TD programs are allowed to use this command.\n'))
         return
     try:
         u = user.find_by_name_exact(args[0], online_only=True)
         if u and u.is_online and not u.is_guest:
             g = u.session.game
             if g and g.gtype == game.PLAYED:
                 conn.write('*getgi %s %s %s %d %d %d %d %d*\n' %
                            (u.name, g.white.name, g.black.name, g.number,
                             g.white_time, g.inc, g.rated, g.private))
             else:
                 conn.write(_('%s is not playing a game.\n') % u.name)
         else:
             # do nothing
             pass
     except user.UsernameException:
         # do nothing
         pass
Beispiel #11
0
 def run(self, args, conn):
     if not conn.user.has_title('TD'):
         conn.write(_('Only TD programs are allowed to use this command.\n'))
         return
     try:
         u = user.find_by_name_exact(args[0], online_only=True)
         if u and u.is_online and not u.is_guest:
             g = u.session.game
             if g and g.gtype == game.PLAYED:
                 conn.write('*getgi %s %s %s %d %d %d %d %d*\n' % (u.name,
                     g.white.name, g.black.name, g.number,
                     g.white_time, g.inc,
                     g.rated, g.private))
             else:
                 conn.write(_('%s is not playing a game.\n') % u.name)
         else:
             # do nothing
             pass
     except user.UsernameException:
         # do nothing
         pass
Beispiel #12
0
    def get_user(self, name, conn):
        u = None
        if name.lower() == 'g' or name.lower() == 'guest':
            u = user.GuestUser(None)
            conn.write(
                _('\nLogging you in as "%s"; you may use this name to play unrated games.\n(After logging in, do "help register" for more info on how to register.)\n\nPress return to enter the server as "%s":\n'
                  ) % (u.name, u.name))
        elif name != '':
            try:
                u = user.find_by_name_exact(name)
            except user.UsernameException as e:
                conn.write('\n' + e.reason + '\n')
            else:
                if u:
                    if u.is_guest:
                        # It's theoretically possible that
                        # a new user registers but is blocked
                        # from logging in by a guest with the
                        # same name.  We ignore that case.
                        conn.write(
                            _('Sorry, %s is already logged in. Try again.\n') %
                            name)
                        u = None
                    else:
                        conn.write(
                            _('\n"%s" is a registered name.  If it is yours, type the password.\nIf not, just hit return to try another name.\n\npassword: '******'\n"%s" is not a registered name.  You may play unrated games as a guest.\n(After logging in, do "help register" for more info on how to register.)\n\nPress return to enter the server as "%s":\n'
                          ) % (name, name))

        if u:
            if u.is_guest:
                if filter_.check_filter(conn.ip):
                    # not translated, since the player hasn't logged on
                    conn.write(
                        'Due to abuse, guest logins are blocked from your address.\n'
                    )
                    conn.loseConnection('filtered')
                    u = None
                if u and online.online.guest_count >= config.maxguest:
                    conn.write(db.get_server_message('full_unreg'))
                    conn.loseConnection('guests full')
                    u = None
            else:
                if u.is_banned:
                    # not translated, since the player hasn't logged on
                    conn.write('Player "%s" is banned.\n' % u.name)
                    conn.loseConnection('banned')
                    u = None

        if u:
            pmax = config.maxplayer if u.is_admin() else (config.maxplayer -
                                                          config.admin_reserve)
            if len(online.online) >= pmax:
                conn.write(db.get_server_message('full'))
                conn.loseConnection('players full')
                u = None

        return u