Beispiel #1
0
    def __init__(self, UID, botdb):
        self._botdb = botdb
        self._botname = UID
        self._header = (
            u'^*[{}](/r/r2d8)* ^*issues* ^*a* ^*series* ^*of* ^*sophisticated* '
            u'^*bleeps* ^*and* ^*whistles...*\n\n'.format(self._botname))

        dbpath = pjoin(getcwd(), u'{}-bgg.db'.format(self._botname))
        self._bgg = BGG(cache=u'sqlite://{}?ttl=86400'.format(dbpath))
Beispiel #2
0
def getNotFoundGames(games):
    '''take a list of games and return those that are not found.'''
    bgg = BGG()
    not_found = []
    for game in games:
        try:
            log.info(u'Looking for {} on BGG.'.format(game))
            found = bgg.game(game)
        except boardgamegeek.exceptions.BoardGameGeekError as e:
            log.critical(u'Error talking to BGG about {}'.format(game))
            continue

        if not found:
            log.warning(u'Unable to find {} on BGG'.format(game))
            not_found.append(game)

    return not_found
Beispiel #3
0
def getGotWPostText(game_name, next_game_name):
    '''Take the name of a game, and return the GotW text to post to Reddit'''
    bgg = BGG()
    try:
        game = bgg.game(game_name)
    except boardgamegeek.exceptions.BoardGameGeekError as e:
        log.critical(u'Error getting info from BGG on {}: {}'.format(
            game_name, e))
        return None

    if not game:
        log.critical(u'Unable to find {} on BGG'.format(game_name))
        return None

    title = u'Game of the Week: {}'.format(game.name)
    text = u'[//]: # (GOTWS)\n'
    text += (u'This week\'s game is [**{}**](http:{})\n\n'.format(
        game.name, game.image))
    text += u' * **BGG Link**: [{}](http://www.boardgamegeek.com/boardgame/{})\n'.format(
        game.name, game.id)

    designers = getattr(game, u'designers', [u'Unknown'])
    plural = u's' if len(designers) > 1 else u''
    text += u' * **Designer{}**: {}\n'.format(plural, ', '.join(designers))

    publishers = getattr(game, u'publishers', [u'Unknown'])
    plural = u's' if len(publishers) > 1 else u''
    text += u' * **Publisher{}**: {}\n'.format(plural, ', '.join(publishers))

    text += u' * **Year Released**: {}\n'.format(game.year)

    mechanics = getattr(game, u'mechanics', [u'Unknown'])
    plural = u's' if len(mechanics) > 1 else u''
    text += u' * **Mechanic{}**: {}\n'.format(plural, ', '.join(mechanics))

    if game.min_players == game.max_players:
        players = '{}'.format(game.min_players)
    else:
        players = '{} - {}'.format(game.min_players, game.max_players)
    text += u' * **Number of Players**: {}\n'.format(players)

    text += u' * **Playing Time**: {} minutes\n'.format(game.playing_time)

    expansions = getattr(game, 'expansions', None)
    if expansions:
        text += u' * **Expansions**: {}\n'.format(', '.join(
            [e.name for e in expansions]))

    text += u' * **Ratings**:\n'
    people = u'people' if game.users_rated > 1 else u'person'
    text += u'    * Average rating is {} (rated by {} {})\n'.format(
        game.rating_average, game.users_rated, people)
    ranks = u', '.join([
        u'{}: {}'.format(r[u'friendlyname'], r[u'value']) for r in game.ranks
    ])
    text += u'    * {}\n'.format(ranks)

    text += u'\n\n'

    text += u'**Description from Boardgamegeek**:\n\n{}\n\n'.format(
        game.description)

    text += u'[//]: # (GOTWE)\n\n'
    text += '---------------------\n\n'

    if not next_game_name:
        text += u'There is no Game of the Week scheduled for next week.'
    else:
        try:
            game = bgg.game(next_game_name)
        except boardgamegeek.exceptions.BoardGameGeekError as e:
            log.critical(u'Error getting info from BGG on {}: {}'.format(
                next_game_name, e))

        if not game:
            text += u'Next Week: {}'.format(next_game_name)
        else:
            text += (u'Next Week: [**{}**](http://www.boardgamegeek'
                     u'.com/boardgame/{})\n\n'.format(game.name, game.id))

        text += (u' * The GOTW archive and schedule can be found '
                 u'[here](http://www.reddit.com/r/boardgames/wiki/'
                 u'game_of_the_week).\n\n * Vote for future Games of the Week '
                 u'[here](/2l5xum).\n')

    return title, text