Ejemplo n.º 1
0
def players_page(bot: Bot,
                 chat_id: int,
                 page_num: int,
                 mode: AnswerMode,
                 message_info: dict = None):
    request_is_correct = True
    players_list: List[PlayerPage] = get_players_page(page_num, 5)
    custom_navigation_keyboard = []
    if len(players_list) == 0:
        request_is_correct = False
    else:
        total = players_list[0].total
        custom_navigation_keyboard = five_buttons_pagination_menu(
            total, page_num, 'pr_pg', chat_id)
    if request_is_correct:
        custom_keyboard = [[
            InlineKeyboardButton(text=pr.secondname_name + ' ' +
                                 ('✅' if pr.rosterstatus == 't' else '❌'),
                                 callback_data='pr_#' + str(pr.player_id))
        ] for pr in players_list]
        custom_keyboard.append(custom_navigation_keyboard)
        if mode == AnswerMode.SEND_NEW:
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   False)
        elif mode == AnswerMode.EDIT:
            print(message_info)
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   True)
    else:
        bot.send_message(chat_id=chat_id,
                         text="<b>There is no page with this number</b>",
                         parse_mode='HTML')
Ejemplo n.º 2
0
def seasons_page(bot: Bot,
                 chat_id: int,
                 page_num: int,
                 mode: AnswerMode,
                 message_info: dict = None):
    request_is_correct = True
    seasons_list: List[SeasonPage] = get_seasons_page(page_num, 5)
    custom_navigation_keyboard = []
    if len(seasons_list) == 0:
        request_is_correct = False
    else:
        total = seasons_list[0].total
        custom_navigation_keyboard = five_buttons_pagination_menu(
            total, page_num, 'sn_pg', chat_id)
    if request_is_correct:
        custom_keyboard = [[
            InlineKeyboardButton(text=sn.season_name,
                                 callback_data='sn_#' + str(sn.season_id))
        ] for sn in seasons_list]
        custom_keyboard.append(custom_navigation_keyboard)
        if mode == AnswerMode.SEND_NEW:
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   False)
        elif mode == AnswerMode.EDIT:
            print(message_info)
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   True)
    else:
        bot.send_message(chat_id=chat_id,
                         text="<b>There is no page with this number</b>",
                         parse_mode='HTML')
Ejemplo n.º 3
0
def team_in_season_page(bot: Bot,
                        chat_id: int,
                        season_id: int,
                        page_num: int,
                        mode: AnswerMode,
                        message_info: dict = None):
    request_is_correct = True
    teams_list: List[TeamsPage] = get_teams_in_seasons_page(
        season_id, page_num, 5)
    custom_navigation_keyboard = []
    if len(teams_list) == 0:
        request_is_correct = False
    else:
        total = teams_list[0].total
        custom_navigation_keyboard = five_buttons_pagination_menu(
            total, page_num, 'tmsn_pg#' + str(season_id), chat_id)
    if request_is_correct:
        custom_keyboard = [[
            InlineKeyboardButton(
                text=tm.team_name + " (" + tm.abbreviation + ")",
                callback_data='tmsn_#' + str(tm.team_id) + "#" +
                str(season_id))
        ] for tm in teams_list]
        custom_keyboard.append(custom_navigation_keyboard)
        custom_keyboard.append(
            [InlineKeyboardButton(text="BACK", callback_data='b_')])
        if mode == AnswerMode.SEND_NEW:
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   False)
        elif mode == AnswerMode.EDIT:
            print(message_info)
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   True)
    else:
        bot.send_message(chat_id=chat_id,
                         text="<b>There is no page with this number</b>",
                         parse_mode='HTML')
Ejemplo n.º 4
0
def games_with_player_page(bot: Bot,
                           chat_id: int,
                           player_id: int,
                           page_num: int,
                           mode: AnswerMode,
                           message_info: dict = None):
    request_is_correct = True
    games_list: List[GamePage] = get_games_with_player_page(
        player_id, page_num, 5)
    custom_navigation_keyboard = []
    if len(games_list) == 0:
        request_is_correct = False
    else:
        total = games_list[0].total
        custom_navigation_keyboard = five_buttons_pagination_menu(
            total, page_num, 'gmpl_pg#' + str(player_id), chat_id)
    if request_is_correct:
        custom_keyboard = [[
            InlineKeyboardButton(text=gm.home_abbreviation + " vs " +
                                 gm.away_abbreviation + " on " + gm.game_date,
                                 callback_data='gm_#' + str(gm.game_id))
        ] for gm in games_list]
        custom_keyboard.append(custom_navigation_keyboard)
        custom_keyboard.append(
            [InlineKeyboardButton(text="BACK", callback_data='b_')])
        if mode == AnswerMode.SEND_NEW:
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   False)
        elif mode == AnswerMode.EDIT:
            print(message_info)
            send_message_with_save(bot, message_info['message_id'], chat_id,
                                   invisible_character(), custom_keyboard,
                                   True)
    else:
        bot.send_message(chat_id=chat_id,
                         text="<b>There is no page with this number</b>",
                         parse_mode='HTML')