Esempio n. 1
0
def check_doc(update, context):
    result = check_pdf(update, context, send_msg=False)
    if result in [PDF_INVALID_FORMAT, PDF_TOO_LARGE]:
        return process_invalid_pdf(update, context, result)

    context.user_data[MERGE_IDS].append(
        update.effective_message.document.file_id)
    context.user_data[MERGE_NAMES].append(
        update.effective_message.document.file_name)

    return ask_next_doc(update, context)
Esempio n. 2
0
def check_second_doc(update, context):
    if not check_user_data(update, context, COMPARE_ID):
        return ConversationHandler.END

    result = check_pdf(update, context)
    if result == PDF_INVALID_FORMAT:
        return WAIT_SECOND
    elif result != PDF_OK:
        return ConversationHandler.END

    return compare_pdf(update, context)
Esempio n. 3
0
def check_wmk_doc(update, context):
    if not check_user_data(update, context, WMK_ID):
        return ConversationHandler.END

    result = check_pdf(update, context)
    if result == PDF_INVALID_FORMAT:
        return WAIT_WMK
    elif result != PDF_OK:
        return ConversationHandler.END

    return add_wmk(update, context)
def check_doc(update: Update, context: CallbackContext) -> int:
    message = update.effective_message
    message.chat.send_action(ChatAction.TYPING)
    result = check_pdf(update, context, send_msg=False)

    if result in [PDF_INVALID_FORMAT, PDF_TOO_LARGE]:
        return process_invalid_pdf(update, context, result)

    user_id = message.from_user.id
    merge_locks[user_id].acquire()
    context.user_data[MERGE_IDS].append(message.document.file_id)
    context.user_data[MERGE_NAMES].append(message.document.file_name)
    result = ask_next_doc(update, context)
    merge_locks[user_id].release()

    return result
Esempio n. 5
0
def check_src_doc(update, context):
    result = check_pdf(update, context)
    if result == PDF_INVALID_FORMAT:
        return WAIT_SRC
    elif result != PDF_OK:
        return ConversationHandler.END

    _ = set_lang(update, context)
    context.user_data[WMK_ID] = update.effective_message.document.file_id

    reply_markup = ReplyKeyboardMarkup([[_(BACK), _(CANCEL)]],
                                       resize_keyboard=True,
                                       one_time_keyboard=True)
    update.effective_message.reply_text(_("Send me the watermark PDF file"),
                                        reply_markup=reply_markup)

    return WAIT_WMK
Esempio n. 6
0
def check_first_doc(update, context):
    result = check_pdf(update, context)
    if result == PDF_INVALID_FORMAT:
        return WAIT_FIRST
    elif result != PDF_OK:
        return ConversationHandler.END

    _ = set_lang(update, context)
    context.user_data[COMPARE_ID] = update.effective_message.document.file_id

    reply_markup = ReplyKeyboardMarkup([[_(BACK), _(CANCEL)]],
                                       resize_keyboard=True,
                                       one_time_keyboard=True)
    update.effective_message.reply_text(
        _("Send me the other PDF file that you'll like to compare"),
        reply_markup=reply_markup,
    )

    return WAIT_SECOND