def unknown_message_handler(update, context):
    """
    For any msg that we didn't registered explicit
    """
    context.bot.send_message(
        chat_id=update.effective_chat.id,
        text="הפקודה האחרונה לא הובנה, נסו להשתמש ב: /help",
        reply_markup=create_main_user_reply_keyboard())
Exemplo n.º 2
0
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_season_details_handler(update, context):
    """
    Shows the given season details, such as wins/losses/ties amount and which titles maccabi won in this season
    """
    full_season_id = format_season_id(update.message.text)
    context.bot.send_message(
        chat_id=update.effective_chat.id,
        parse_mode=ParseMode.HTML,
        text=extract_season_details_from_maccabipedia_as_html_text(
            full_season_id),
        reply_markup=create_main_user_reply_keyboard())

    return ConversationHandler.END
def start_handler(update, context):
    """
    First msg the user sees
    """
    user_name = update.effective_chat.username
    if user_name is not None:
        hello_message = f"שלום {user_name}."
    else:
        hello_message = f"שלום."

    context.bot.send_message(chat_id=update.effective_chat.id,
                             text=f"{hello_message}",
                             reply_markup=create_main_user_reply_keyboard())

    help_handler(update, context)
def help_handler(update, context):
    """
    Shows the help for this bot.
    """
    context.bot.send_message(
        chat_id=update.effective_chat.id,
        parse_mode=ParseMode.HTML,
        reply_markup=create_main_user_reply_keyboard(),
        text=f"בכדי לקבל סטטיסטיקות, השתמשו בתפריט מטה ולחצו על:"
        f"\n1) 'סנן משחקים' בכדי להחליט אילו משחקים לכלול"
        f"\n2) לחצו על 'סטטיסטיקה'"
        f"\n\nתוכלו לעיין באופציות נוספות בתפריט שנפתח מטה."
        f"\nבכל שלב ניתן לחזור לתיאור זה באמצעות הפקודה: /help"
        f"\nבכדי לחזור לתפריט הראשי תוכלו לשלוח 'חזור' בכל שלב."
        f"\n\nרוצים לעזור למכביפדיה לגדול?"
        f"\nיש המון מה לעשות וכולם יכולים לתרום!"
        f"\nכנסו לקבוצה שלנו: @MaccabiPedia, מחכים לכם."
        f"\nבתודה, <a href='www.maccabipedia.co.il'>מכביפדיה.</a>")
def show_uniforms_handler(update, context):
    """
    Shows the given uniforms (by the chosen season).
    """
    full_season_id = format_season_id(update.message.text)
    html_text, uniforms = extract_season_uniforms_from_maccabipedia(
        full_season_id)
    input_media_uniforms = [
        InputMediaPhoto(photo_url) for photo_url in uniforms
    ]
    context.bot.send_message(chat_id=update.effective_chat.id,
                             parse_mode=ParseMode.HTML,
                             text=html_text,
                             reply_markup=create_main_user_reply_keyboard())
    if input_media_uniforms:
        context.bot.send_media_group(chat_id=update.effective_chat.id,
                                     media=input_media_uniforms)

    return ConversationHandler.END
def show_song_details_handler(update, context):
    """
    :return: Lyrics of the given song & link to the page
    """
    song_name = update.message.text

    if not song_exists_on_maccabipedia(song_name):
        similar_songs_pages_names = SimilarMaccabiPediaSong(song_name).find_most_similar_songs()
        if similar_songs_pages_names:
            pretty_print_of_similar_songs_pages = "\n".join(page_name for page_name in similar_songs_pages_names)
            context.bot.send_message(chat_id=update.effective_chat.id, text=f"לא נמצא שיר בשם: '{song_name}', אלו השירים עם השם הדומה ביותר:"
                                                                            f"\n{pretty_print_of_similar_songs_pages}"
                                                                            f"\n\nשלח את שם השיר הרצוי")
        else:
            context.bot.send_message(chat_id=update.effective_chat.id, text=f"לא נמצא שיר בשם: '{song_name}' נסה בשנית")

        return _show_song_details_state
    else:  # This song exists on maccabipedia, lets show it!
        context.bot.send_message(chat_id=update.effective_chat.id, parse_mode=ParseMode.HTML, text=get_song_lyrics(song_name),
                                 reply_markup=create_main_user_reply_keyboard())

        return ConversationHandler.END