def check_to_photos_task(update, context): _ = set_lang(update, context) text = update.effective_message.text if text in [_(PHOTOS), _(COMPRESSED)]: return pdf_to_photos(update, context) elif text == _(BACK): return ask_doc_task(update, context)
def check_scale_task(update, context): _ = set_lang(update, context) text = update.effective_message.text if text in [_(BY_PERCENT), _(TO_DIMENSIONS)]: return ask_scale_value(update, context) elif text == _(BACK): return ask_doc_task(update, context)
def check_crop_task(update, context): _ = set_lang(update, context) text = update.effective_message.text if text in [_(BY_PERCENT), _(BY_SIZE)]: return ask_crop_value(update, context) elif text == _(BACK): return ask_doc_task(update, context)
def check_rotate_degree(update, context): _ = set_lang(update, context) text = update.effective_message.text if text in [_(ROTATE_90), _(ROTATE_180), _(ROTATE_270)]: return rotate_pdf(update, context) elif text == _(BACK): return ask_doc_task(update, context)
def check_text_task(update, context): _ = set_lang(update, context) text = update.effective_message.text if text == _(TEXT_MESSAGE): return get_pdf_text(update, context, is_file=False) elif text == _(TEXT_FILE): return get_pdf_text(update, context, is_file=True) elif text == _(BACK): return ask_doc_task(update, context)
def check_doc(update, context): doc = update.effective_message.document if doc.mime_type.startswith("image"): return ask_photo_task(update, context, doc) elif not doc.mime_type.endswith("pdf"): return ConversationHandler.END elif doc.file_size >= MAX_FILESIZE_DOWNLOAD: _ = set_lang(update, context) update.effective_message.reply_text( _("Your PDF file is too big for me to download\n\nI can't perform any tasks on it" )) return ConversationHandler.END context.user_data[PDF_INFO] = doc.file_id, doc.file_name return ask_doc_task(update, context)
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