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

Viewed 23

Here's my code :


numbers = []
for x in range(9360521600, 9360522000):
    numbers.append(f'+98{x}')

async def contact(client, numbers):
    sleep_time = 0
    for number in numbers:
        try:
            print(f'sleep time : {sleep_time}\n')
            time.sleep(sleep_time)
            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]))
            print(result)
            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? **

0 Answers
Related