Exemple #1
0
def get_back_markup(update, context):
    _ = set_lang(update, context)
    reply_markup = ReplyKeyboardMarkup([[_(BACK)]],
                                       one_time_keyboard=True,
                                       resize_keyboard=True)

    return reply_markup
Exemple #2
0
def ask_doc_task(update, context):
    _ = set_lang(update, context)
    keywords = sorted([
        _(DECRYPT),
        _(ENCRYPT),
        _(ROTATE),
        _(SCALE),
        _(SPLIT),
        _(PREVIEW),
        _(TO_PHOTO),
        _(EXTRACT_PHOTO),
        _(RENAME),
        _(CROP),
        _(EXTRACT_TEXT),
        OCR,
        _(COMPRESS),
    ])
    keywords.append(CANCEL)
    keyboard_size = 3
    keyboard = [
        keywords[i:i + keyboard_size]
        for i in range(0, len(keywords), keyboard_size)
    ]

    reply_markup = ReplyKeyboardMarkup(keyboard,
                                       resize_keyboard=True,
                                       one_time_keyboard=True)
    update.effective_message.reply_text(
        _("Select the task that you'll like to perform"),
        reply_markup=reply_markup)

    return WAIT_DOC_TASK
Exemple #3
0
def check_back_user_data(update, context):
    """
    Check for back action and if user data is valid
    Args:
        update: the update object
        context: the context object

    Returns:
        A state if it is a back action of the user data is invalid, else None
    """
    _ = set_lang(update, context)
    result = None

    if update.effective_message.text == _(BACK):
        result = ask_doc_task(update, context)
    elif not check_user_data(update, context, PDF_INFO):
        result = ConversationHandler.END

    return result