y2kbug icon

telegram passport code 2

y2kbug | PRO | 05/30/19 03:06:17 AM UTC | 0 ⭐ | 741 👁️ | Never ⏰ | []
text |

2.77 KB

|

None

|

0 👍

/

0 👎

def passport_handler(bot, update):
    # If we received any passport data
    passport_data = update.message.passport_data
    if passport_data:
        # If our nonce doesn't match what we think, this Update did not originate from us
        # Ideally you would randomize the nonce on the server
        if passport_data.decrypted_credentials.nonce != '123456':
            return
         # Print the decrypted credential data
        # For all elements
        # Print their decrypted data
        # Files will be downloaded to current directory
        for data in passport_data.decrypted_data:  # This is where the data gets decrypted
            if data.type == 'phone_number':
                print('Phone: ', data.phone_number)
            elif data.type == 'email':
                print('Email: ', data.email)
            if data.type in ('personal_details', 'passport', 'driver_license', 'identity_card',
                             'internal_passport', 'address'):
                print(data.type, data.data)
            if data.type in ('utility_bill', 'bank_statement', 'rental_agreement',
                             'passport_registration', 'temporary_registration'):
                print(data.type, len(data.files), 'files')
                for file in data.files:
                    actual_file = file.get_file()
                    print(actual_file)
                    actual_file.download()
            if data.type in ('passport', 'driver_license', 'identity_card',
                             'internal_passport'):
                if data.front_side:
                    file = data.front_side.get_file()
                    print(data.type, file)
                    file.download()
            if data.type in ('driver_license' and 'identity_card'):
                if data.reverse_side:
                    file = data.reverse_side.get_file()
                    print(data.type, file)
                    file.download()
            if data.type in ('passport', 'driver_license', 'identity_card',
                             'internal_passport'):
                if data.selfie:
                    file = data.selfie.get_file()
                    print(data.type, file)
                    file.download()
            if data.type in ('passport', 'driver_license', 'identity_card',
                             'internal_passport', 'utility_bill', 'bank_statement',
                             'rental_agreement', 'passport_registration',
                             'temporary_registration'):
                print(data.type, len(data.translation), 'translation')
                for file in data.translation:
                    actual_file = file.get_file()
                    print(actual_file)
                    actual_file.download()

Comments