小编net*_*vil的帖子

在api telegram python telethon中添加新联系人

如何在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'
Run Code Online (Sandbox Code Playgroud)

添加联系人需要什么模块?

python api telegram telethon

5
推荐指数
2
解决办法
3448
查看次数

我如何使用 Telethon API python 在我的频道中添加我的联系人

这是我的频道的信息:

dialogs, entities = client.get_dialogs(1)
entity = entities[0]
print(entity)
(channel (ID: 0xa14dca52) = (creator=True, kicked=None, left=None, editor=None, moderator=None, broadcast=True, verified=None, megagroup=None, restricted=None, democracy=None, signatures=None, min=None, id=1135498252, access_hash=-6282984409346664480, title=channel_test, username=None, photo=(chatPhotoEmpty (ID: 0x37c1011c) = ()), date=2017-07-04 06:11:05, version=0, restriction_reason=None))
Run Code Online (Sandbox Code Playgroud)

我有 3 个联系人:

contacts = client.invoke(GetContactsRequest(""))
for u in contacts.contacts:
     print (u)
(contact (ID: 0xf911c994) = (user_id=231735496, mutual=False))
(contact (ID: 0xf911c994) = (user_id=408708469, mutual=False))
(contact (ID: 0xf911c994) = (user_id=442246143, mutual=False))
Run Code Online (Sandbox Code Playgroud)

我不知道如何使用此代码:

from telethon.tl.functions.messages import AddChatUserRequest

client.invoke(AddChatUserRequest(
   chat_id,
   user_to_add,
   fwd_limit=10  # allow the …
Run Code Online (Sandbox Code Playgroud)

python api telegram telethon

5
推荐指数
1
解决办法
2220
查看次数

在telethon python电报中向联系人发送消息

如何查看我的所有联系人并向他们发送消息?我使用 Telethon(API 电报 python)。

from telethon.tl.functions.contacts import ResolveUsernameRequest
from telethon.tl.types import InputChannelEmpty
from telethon import TelegramClient
from telethon.tl.types.messages import Messages
from telethon.tl.types.contacts import Contacts
api_id = 1****
api_hash = '5fbd2d************************'
client = TelegramClient('arta0', api_id, api_hash)
client.connect()
Run Code Online (Sandbox Code Playgroud)

python api telegram telethon

3
推荐指数
1
解决办法
6520
查看次数

我如何恢复 telethon telegram 中旧的会话并再次连接(无需再次发送代码))

我使用这个脚本在电视马拉松中连接和创建会话

from telethon import TelegramClient
from telethon.tl.functions.messages import GetHistoryRequest
from telethon.utils import get_input_peer
api_id = 7****
api_hash = 'ef584d*****************'
client = TelegramClient('+15159947451', api_id, api_hash)
client.connect()
if not client.is_user_authorized():
    client.send_code_request('+15159947451')
client.sign_in('+15159947451', cod)
Run Code Online (Sandbox Code Playgroud)

有了这个代码,我可以在这个号码电报中登录并创建文件:+15159947451.session。

现在我关闭并断开连接,我如何使用此文件+15159947451.session再次登录此号码。

我使用这段代码,但这段代码有错误:

from telethon import TelegramClient
from telethon.tl.functions.messages import GetHistoryRequest
from telethon.utils import get_input_peer
api_id = 7****
api_hash = 'ef584d180eee*******************'
number='+15152934803'
client = TelegramClient('00', api_id, api_hash)
client.session.try_load_or_create_new(session_user_id='+15159947451')
client.connect()
Run Code Online (Sandbox Code Playgroud)

但我有这个错误

raise error
telethon.errors.RPCError: (RPCError(...), 'AUTH_KEY_UNREGISTERED (401):       The key is not registered in the system.')
Run Code Online (Sandbox Code Playgroud)

python api telegram telethon

2
推荐指数
1
解决办法
9462
查看次数

标签 统计

api ×4

python ×4

telegram ×4

telethon ×4