def setUp(self):
        super().setUp()
        self.old_games_db_file = os.environ.get('GAMES_DB_FILE')
        os.environ['GAMES_DB_FILE'] = 'test_known_games.json'

        for game in get_known_games():
            db.clear_game(game)
        self.bot_responses = []
Exemple #2
0
 def get_all_responses(self, message):
     messages = ['Bot alive']
     ready_messages = []
     for game in get_known_games():
         players = game.get_available_players()
         if players:
             messages.append('%s has %s' % (game, len(players)))
             ready_messages += get_any_ready_messages(game)
     return ['\n'.join(messages + ready_messages)]
 def get_all_responses(self, message):
     messages = ['Bot alive']
     for game in get_known_games():
         ready_would_plays_for_game = db.get_ready_would_plays_for_game(
             game)
         unready_would_plays_for_game = db.get_unready_would_plays_for_game(
             game)
         if ready_would_plays_for_game or unready_would_plays_for_game:
             messages.append("%s %s" % (game.name,
                                        generate_ready_at_time_messages(
                                            ready_would_plays_for_game,
                                            unready_would_plays_for_game,
                                            list_players=True)))
     return ['\n'.join(messages)]
    def get_all_responses(self, message):
        mention, remainder = split_by_first_mention(message)
        found_keyword, remainder = self.split_string_by_keywords(remainder)

        if message_pertains_to_all_games(remainder):
            return ['\n'.join([game.name for game in get_known_games()])]
        else:
            attribute, game_name = remainder.split(' ')[:2]
            game = lookup_game_by_name_or_alias(game_name)
            attribute_display = {
                'aliases': lambda z: ', '.join([alias for alias in z])
            }
            display_function = attribute_display.get(attribute,
                                                     lambda x: str(x))
            return [
                "%s: %s" %
                (attribute, display_function(getattr(game, attribute)))
            ]
Exemple #5
0
 def setUp(self):
     super().setUp()
     for game in get_known_games():
         db.clear_game(game)
     self.bot_responses = []