在api电报python telethon中添加新联系人 [英] Add new contact in api telegram python telethon

查看:626
本文介绍了在api电报python telethon中添加新联系人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Telethon python的联系人中保存电话号码?

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

from telethon import TelegramClient
from telethon.tl.functions.contacts import GetContactsRequest
from telethon.tl.types import InputPeerUser
client = TelegramClient('arta0', api_id, api_hash)
client.connect()
#number=+19133704541
#name='ali karimi'

我需要添加哪个模块?

推荐答案

您可以创建如下联系人:

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))

要创建新联系人,您需要为client_id传递0.

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

这篇关于在api电报python telethon中添加新联系人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆