Exemple #1
0
def check_doc_task(update, context):
    _ = set_lang(update, context)
    text = update.effective_message.text

    if text == _(CROP):
        return ask_crop_type(update, context)
    elif text == _(DECRYPT):
        return ask_decrypt_pw(update, context)
    elif text == _(ENCRYPT):
        return ask_encrypt_pw(update, context)
    elif text in [_(EXTRACT_PHOTO), _(TO_PHOTO)]:
        return ask_photo_results_type(update, context)
    elif text == _(PREVIEW):
        return get_pdf_preview(update, context)
    elif text == _(RENAME):
        return ask_pdf_new_name(update, context)
    elif text == _(ROTATE):
        return ask_rotate_degree(update, context)
    elif text in [_(SCALE)]:
        return ask_scale_type(update, context)
    elif text == _(SPLIT):
        return ask_split_range(update, context)
    elif text == _(EXTRACT_TEXT):
        return ask_text_type(update, context)
    elif text == OCR:
        return add_ocr_to_pdf(update, context)
    elif text == COMPRESS:
        return compress_pdf(update, context)
    elif text == _(CANCEL):
        return cancel_without_async(update, context)
Exemple #2
0
def check_text(update, context):
    _ = set_lang(update, context)
    text = update.effective_message.text

    if text == _(BACK):
        return ask_src_doc(update, context)
    elif text == _(CANCEL):
        return cancel_without_async(update, context)
Exemple #3
0
def check_photo_task(update, context):
    _ = set_lang(update, context)
    text = update.effective_message.text

    if text in [_(BEAUTIFY), _(TO_PDF)]:
        return process_photo_task(update, context)
    elif text == _(CANCEL):
        return cancel_without_async(update, context)
Exemple #4
0
def check_text(update, context):
    _ = set_lang(update, context)
    text = update.effective_message.text

    if text == _(REMOVE_LAST):
        return remove_doc(update, context)
    elif text == _(DONE):
        return preprocess_merge_pdf(update, context)
    elif text == _(CANCEL):
        return cancel_without_async(update, context)
Exemple #5
0
def check_text(update, context):
    _ = set_lang(update, context)
    text = update.effective_message.text

    if text == _(REMOVE_LAST):
        return remove_photo(update, context)
    if text in [_(BEAUTIFY), _(TO_PDF)]:
        return process_all_photos(update, context)
    elif text == _(CANCEL):
        return cancel_without_async(update, context)
Exemple #6
0
def text_to_pdf(update, context):
    _ = set_lang(update, context)
    message = update.effective_message
    text = message.text

    if text == _(CANCEL):
        return cancel_without_async(update, context)

    message.reply_text(_("Creating your PDF file"),
                       reply_markup=ReplyKeyboardRemove())
    html = HTML(string=BASE_HTML.format(text.replace("\n", "<br/>")))

    with tempfile.TemporaryDirectory() as dir_name:
        out_fn = os.path.join(dir_name, "Text.pdf")
        html.write_pdf(out_fn)
        send_result_file(update, context, out_fn, "text")

    return ConversationHandler.END