Exemplo n.º 1
0
def formatGameList(gameList):
    """Formats an answer containing a game list, creating the body and attaching the markup.

    Args:
        gameList (game.GameList): an object containing all the information on the game list.

    Returns:
        .answer.TelegramAnswer: an object containing all the information to be sent.
    """
    formattedGameListBody = _formatGameListBody(gameList)
    keyboard = []
    offset = gameList.offset
    totalSize = len(gameList.gameList)
    callback_data = gameList.originalSearch + constants.CALLBACK_DATA_SEPARATOR + str(
        offset)
    buttonList = []
    if offset > 0:
        entry = dict(text="Back", callback_data="lp" + callback_data)
        buttonList.append(entry)
    if offset + constants.LIST_PAGE_SIZE < totalSize:
        entry = dict(text="Next", callback_data="ln" + callback_data)
        buttonList.append(entry)
    if buttonList:
        keyboard.append(buttonList)
    return TelegramAnswer(formattedGameListBody,
                          inlineKeyboardMarkup=keyboard if keyboard else None)
Exemplo n.º 2
0
def formatGame(game, more=False):
    """Formats an answer containing a game, creating the body and attaching the markup.

    Args:
        game (game.Game): an object containing all the information on the game.
        more (bool): True if the answer should show additional info.

    Returns:
        .answer.TelegramAnswer: an object containing all the information to be sent.
    """
    if (more):
        formattedGameBody = _formatGameBodyMore(game)
        disableWebPagePreview = True
        text = "Game Info"
        callback_data = "gl" + str(game.id_)
    else:
        formattedGameBody = _formatGameBodyLess(game)
        disableWebPagePreview = False
        text = "Description"
        callback_data = "gm" + str(game.id_)
    keyboard = [[
        dict(text=text, callback_data=callback_data),
        dict(text="Share", switch_inline_query="i " + game.id_)
    ]]
    return TelegramAnswer(formattedGameBody,
                          inlineKeyboardMarkup=keyboard,
                          disableWebPagePreview=disableWebPagePreview)
Exemplo n.º 3
0
def formatHelp():
    """Formats a description of this bot usage.

    Returns:
        .answer.TelegramAnswer: The description of how to use this bot.
    """
    s = "This bot brings the power of [BoardGameGeek](https://boardgamegeek.com/) into Telegram. The sky's the limit now."
    s += "\n\n*Commands:*\n"
    for c in constants.COMMAND_DESCRIPTIONS:
        s += c + " - " + constants.COMMAND_DESCRIPTIONS[c] + "\n"
    s += "\n*Inline Commands:*\n"
    for c in constants.INLINE_COMMAND_DESCRIPTIONS:
        s += c + " - " + constants.INLINE_COMMAND_DESCRIPTIONS[c] + "\n"
    s += "\n For info about how inline mode works, see [the official guide](https://telegram.org/blog/inline-bots)."
    return TelegramAnswer(s)
Exemplo n.º 4
0
def formatGameListIndexNotValid(index):
    return TelegramAnswer("Error, " + index +
                          " is not a valid search index (out of bound).")
Exemplo n.º 5
0
def formatHistoryNotFound():
    return TelegramAnswer(
        "Sorry, last search not found in the history. Try to start a new search."
    )
Exemplo n.º 6
0
def formatCommandNotSupported(command):
    return TelegramAnswer("Sorry, " + _bold("/" + command) +
                          " is not a valid command.")
Exemplo n.º 7
0
def formatBggUnreachable():
    return TelegramAnswer(
        "Sorry, it was not possible to contact Boardgamegeek servers. Try again later!"
    )
Exemplo n.º 8
0
def formatNoResultFound():
    return TelegramAnswer("No result found!")
Exemplo n.º 9
0
def formatCommandNotSupported(command):
    return TelegramAnswer("Sorry, */" + command + "* is not a valid command.")