any one know how to add several users to our Telegram contacts with telethon (telegram API) ? and what’s the Limitation?


This Content is from Stack Overflow. Question asked by nelo amv

Here’s my code :

numbers = []
for x in range(9360521600, 9360522000):

async def contact(client, numbers):
    sleep_time = 0
    for number in numbers:
            print(f'sleep time : {sleep_time}n')
            assert client.connect()
            contact = InputPhoneContact(client_id=0, phone=number, first_name=f"F {number}", last_name=f"L {number}")
            result = await client(ImportContactsRequest([contact]))
            sleep_time = 0
        except errors.FloodWaitError as E :
            sleep_time = E.seconds

with client:
    client.loop.run_until_complete(contact(client, numbers))

**every 50 users i add to my contacts, i should put the code to sleep for avrg 280 secs.
any solution? or other way to add contacts faster? **


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?