Recently I tried to add contact in telegram with telethon, according to this tutorial: 1) Add new contact in api telegram python telethon ,I used this codes:
contact = InputPhoneContact(client_id=0, phone='+989122725691', first_name="user",
last_name="test")
result = ImportContactsRequest(contacts=[contact])
print(result)
But I in my output I get this :
ImportContactsRequest(contacts=[InputPhoneContact(client_id=0, phone='+989122725691', first_name='user', last_name='test')])
I can'd find out what is my problem, but when I go to my telegram app, this contact isn't add.
you should call ImportContactsRequest with your client Instance. e.g.
import random
contact = InputPhoneContact(client_id=random.randint(0,9999), phone='+98912******',
first_name="user",
last_name="test")
result = client(ImportContactsRequest(contacts=[contact]))
print(result.__dict__)
Author note
Official applications use random numbers, and we have had issues with it in the past.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With