Add new contact in api telegram python telethon

前端 未结 4 1845
萌比男神i
萌比男神i 2020-12-20 19:21

How do I save a number in my contacts in telethon python?

from telethon import TelegramClient
from telethon.tl.functions.contacts import GetContactsRequest
         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-20 20:13

    You can create a contact like this:

    contact = InputPhoneContact(client_id = 0, phone = "+12345678", first_name="ABC", last_name="abc")
    
    result = client.invoke(ImportContactsRequest([contact], replace=True))
    

    To create a new contact you need to pass 0 for the client_id.

提交回复
热议问题