Exemple #1
0
def _searchByIdInline(id_):
    """Searches for a game by ID and returns an inline answer.

    Args:
        id_ (int): The ID of the game to search.

    Returns:
        answer.TelegramInlineAnswer: An object containing all the information
            about a single entry in the list of results which is to be returned.
    """
    game = http.searchById(id_)
    return output_formatter.formatInlineGame(game)
Exemple #2
0
def _searchById(id_, chatId, more=False):
    """Searches for a boardgame by ID.
    
    Args:
        id_ (int): The ID of the game to search.
        chatId (int): The ID of the chat where the request came from.
        more (bool): True if the answer should show additional info.

    Returns:
        .answer.TelegramAnswer: An object containing all the information to be sent.

    Raises:
        .exceptions.NoResultFound: If no game corresponds to the ID.
    """
    game = http.searchById(id_)
    formattedGame = output_formatter.formatGame(game, more)
    history_manager.updateLastGame(game, formattedGame.formattedAnswer, chatId)
    return formattedGame
Exemple #3
0
def searchByIdInline(id_, cacheTime, isPersonal):
    """Searches for a game by ID and returns an inline answer.

    Args:
        id_ (int): The ID of the game to search.
        cacheTime (int): The time the result should be cached on Telegram server.
        isPersonal (bool): Whether the result should be cached only for the user that made
            the request.

    Returns:
        answer.TelegramInlineAnswerList: An object containing all the information
            to be sent to answer the inline query.
    """
    game = http.searchById(id_)
    formattedInlineGame = output_formatter.formatInlineGame(game)
    inlineList = answer.TelegramInlineAnswerList(cacheTime, isPersonal)
    inlineList.addInlineAnswer(formattedInlineGame)
    return inlineList
Exemple #4
0
import sys
sys.path.insert(0, "../boardgamebot")

from tools import http
import exceptions

try:
    print(http.searchByName("Pandemic Iberia").toString())
    print(http.searchByNameExact("Pandemic").toString())
    print(http.searchById(131691).toString())
except exceptions.BggUnreachable:
    print("Bgg unreachable")
except exceptions.NoResultFound:
    print("No result found")