def save_specific_coach_action(update, context): user_coach = update.message.text if user_coach not in get_maccabipedia_games().available_coaches: similar_coaches_names = get_similar_coaches_names(user_coach) if similar_coaches_names: pretty_print_of_similar_coaches_names = "\n".join( coach_name for coach_name in similar_coaches_names) context.bot.send_message( chat_id=update.effective_chat.id, text=f'לא נמצא מאמן בשם "{user_coach}", מאמנים בעלי שם דומה:' f"\n{pretty_print_of_similar_coaches_names}" f"\n\nהקלד את שם המאמן הרצוי:") else: context.bot.send_message( chat_id=update.effective_chat.id, text=f'לא נמצא מאמן בשם "{user_coach}", נסה בשנית:') return select_coach_filter else: context.user_data[_USER_DATE_GAMES_FILTER_KEY].update_coach_filter( user_coach) games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() context.bot.send_message( chat_id=update.effective_chat.id, text=f"בחרת ב: {user_coach}, {len(games)} משחקים נבחרו") return go_back_to_main_games_filter_menu(update, context)
def save_specific_team_action(update, context): team_name = update.message.text if team_name not in get_maccabipedia_games().available_opponents: similar_team_names = get_similar_teams_names(team_name) if similar_team_names: pretty_print_of_similar_team_names = "\n".join( team for team in similar_team_names) context.bot.send_message( chat_id=update.effective_chat.id, text= f"קבוצה בשם {team_name} לא נמצאה, אלו בעלות השם הדומה ביותר:\n" f"{pretty_print_of_similar_team_names}" f"\n\nשלח את שם הקבוצה הרצויה:") else: context.bot.send_message( chat_id=update.effective_chat.id, text=f"קבוצה בשם {team_name} לא נמצאה, נסה בשנית") return select_team_filter else: context.user_data[_USER_DATE_GAMES_FILTER_KEY].update_team_filter( team_name) games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() context.bot.send_message( chat_id=update.effective_chat.id, text=f"בחרת ב: {team_name}, {len(games)} משחקים נבחרו") return go_back_to_main_games_filter_menu(update, context)
def save_specific_played_player_action(update, context): user_player_name = update.message.text if user_player_name not in get_maccabipedia_games( ).available_players_names: similar_players_names = get_similar_player_names(user_player_name) if similar_players_names: pretty_print_of_similar_players_names = "\n".join( player_name for player_name in similar_players_names) context.bot.send_message( chat_id=update.effective_chat.id, text= f"שחקן בשם {user_player_name} לא נמצא, אלו בעלי השם הדומה ביותר:\n" f"{pretty_print_of_similar_players_names}" f"\n\nשלח את שם השחקן הרצוי:") else: context.bot.send_message( chat_id=update.effective_chat.id, text=f"שחקן בשם {user_player_name} לא נמצא, נסה בשנית") return select_played_player_filter else: context.user_data[ _USER_DATE_GAMES_FILTER_KEY].update_played_player_filter( user_player_name) games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() context.bot.send_message( chat_id=update.effective_chat.id, text=f"בחרת ב: {user_player_name}, {len(games)} משחקים נבחרו") return go_back_to_main_games_filter_menu(update, context)
def show_teams_streaks_maccabi_with_clean_sheets_action(update, context): games = MaccabiGamesFiltering(context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() top = games.teams_streaks.get_teams_with_best_clean_sheets_streak() top_teams_html_text = transform_teams_with_maccabi_games_to_telegram_html_text(top) query = update.callback_query query.edit_message_text(parse_mode=ParseMode.HTML, text=f"היריבות עם הרצף 'מכבי שמרה על רשת נקייה' הארוך ביותר: \n{top_teams_html_text}") return go_to_more_stats_or_finish_menu(update, context)
def show_teams_streaks_maccabi_score_at_least_a_goal_action(update, context): games = MaccabiGamesFiltering(context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() top = games.teams_streaks.get_teams_with_current_maccabi_score_goal_streak() top_teams_html_text = transform_teams_with_maccabi_games_to_telegram_html_text(top) query = update.callback_query query.edit_message_text(parse_mode=ParseMode.HTML, text=f"היריבות עם הרצף 'מכבי הבקיעה לפחות גול אחד' הארוך ביותר: \n{top_teams_html_text}") return go_to_more_stats_or_finish_menu(update, context)
def show_summary_stats_action(update, context): games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() summary_stats = transform_stats_to_pretty_hebrew_text( games.results.json_dict()) query = update.callback_query query.edit_message_text(text=summary_stats) return go_to_more_stats_or_finish_menu(update, context)
def save_date_decision(update, context): query = update.callback_query context.user_data[_USER_DATE_GAMES_FILTER_KEY].update_date_filter( query.data) games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() button_text_the_user_chose = get_button_text_from_query_data(query) query.edit_message_text( text=f"בחרת ב: {button_text_the_user_chose}, {len(games)} משחקים נבחרו" ) # Showing the main menu and moving to the step of choosing a game filter again return go_back_to_main_games_filter_menu(update, context)
def finished_to_create_games_action(update, context): filtered_games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() query = update.callback_query query.edit_message_text( text=f"סיימת לסנן משחקים, {len(filtered_games)} משחקים נבחרו!") context.bot.send_message(chat_id=update.effective_chat.id, text=" בכדי להמשיך לחץ מטה על 'סטטיסטיקה'", reply_markup=create_main_user_reply_keyboard()) return ConversationHandler.END
def show_most_captain_action(update, context): games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() top = games.players.most_captains[0:10] top_players_html_text = transform_players_with_amount_to_telegram_html_text( top) query = update.callback_query query.edit_message_text( parse_mode=ParseMode.HTML, text=f"השחקנים שהיו קפטן הכי הרבה פעמים: \n{top_players_html_text}") return go_to_more_stats_or_finish_menu(update, context)
def show_players_winning_streaks_action(update, context): games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() top = games.players_streaks.get_players_with_best_win_streak() top_players_html_text = transform_players_with_maccabi_games_to_telegram_html_text( top) query = update.callback_query query.edit_message_text( parse_mode=ParseMode.HTML, text=f"השחקנים עם רצף הנצחונות הארוך ביותר: \n{top_players_html_text}") return go_to_more_stats_or_finish_menu(update, context)
def save_coach_decision(update, context): query = update.callback_query if query.data == CoachFilteringMenuOptions.ALL_COACHES: context.user_data[ _USER_DATE_GAMES_FILTER_KEY].update_coach_filter_to_all_coaches() games = MaccabiGamesFiltering( context.user_data[_USER_DATE_GAMES_FILTER_KEY]).filter_games() button_text_the_user_chose = get_button_text_from_query_data(query) query.edit_message_text( text= f"בחרת ב: {button_text_the_user_chose}, {len(games)} משחקים נבחרו") return go_back_to_main_games_filter_menu(update, context) else: query.edit_message_text(text="הקלד את שם המאמן הרצוי:") return select_coach_filter