Search code examples
pythonlambdatelegramjobstelethon

Telegram API - TelethonClient Python - ImportContactsRequest stop working


with python I'm using telethon client to invoke telegram api

My target is to verify if a phone number has a telegram.

I'm using this method:

contact = InputPhoneContact(client_id=55555555, phone='+39XXXXXXXXX', first_name='', last_name='')
contacts = await client(ImportContactsRequest(contacts=[contact]))

After deploying on production, this works but now is not working.. all requests that I try to send returns empty.

ImportedContacts(imported=[], popular_invites=[], retry_contacts=[55555555], users=[])

Here, I found this: https://core.telegram.org/constructor/contacts.importedContacts

when retry_contacts is returned with the clientID sent means that:

List of contact ids that could not be imported due to system limitations and will need to be imported at a later date.

what kind of issue is this? how to solve it?

I have a job scheduled every 15mins that sends 35 phone_number (not in contact list) to check in order to verify if provided phone_number has a telegram account.

Someone can help me?

I'm using this method:

contact = InputPhoneContact(client_id=55555555, phone='+39XXXXXXXXX', first_name='', last_name='')
contacts = await client(ImportContactsRequest(contacts=[contact]))

response is:

ImportedContacts(imported=[], popular_invites=[], retry_contacts=[55555555], users=[])

Solution

  • You are using raw API, which means the results you are getting come directly from Telegram, and Telethon is not changing them in any way (other than adapting some input parameters where needed, all while respecting the intended values).

    This is likely a measure to prevent or reduce spam. You can't "solve" this, because it's how the Telegram API works.