AttributeError: 'coroutine' object has no attribute 'users'
AttributeError: 'coroutine' object has no attribute 'users'
当我运行这段代码时:
from telethon import TelegramClient
from telethon.tl.functions.messages import AddChatUserRequest
from telethon.tl.types import InputPhoneContact
from telethon.tl.functions.contacts import ImportContactsRequest
client = TelegramClient('session_name',
api_id,
api_hash)
client.start()
contact = InputPhoneContact(client_id=0, phone=guest_phone_number, first_name="custom_first_name", last_name="custom_last_name")
result = client(ImportContactsRequest([contact]))
client(AddChatUserRequest(user_id=result.users[0], fwd_limit=0, chat_id=group_id))
它给我这个错误:
AttributeError: 'coroutine' object has no attribute 'users'
求助(
从您的代码看来,问题是 client() 调用返回了结果,而您希望结果变量有一个用户项,该项是您试图获取其第一个元素的数组。您需要检查结果对象以查看它返回到您的程序时的样子。
当我运行这段代码时:
from telethon import TelegramClient
from telethon.tl.functions.messages import AddChatUserRequest
from telethon.tl.types import InputPhoneContact
from telethon.tl.functions.contacts import ImportContactsRequest
client = TelegramClient('session_name',
api_id,
api_hash)
client.start()
contact = InputPhoneContact(client_id=0, phone=guest_phone_number, first_name="custom_first_name", last_name="custom_last_name")
result = client(ImportContactsRequest([contact]))
client(AddChatUserRequest(user_id=result.users[0], fwd_limit=0, chat_id=group_id))
它给我这个错误:
AttributeError: 'coroutine' object has no attribute 'users'
求助(
从您的代码看来,问题是 client() 调用返回了结果,而您希望结果变量有一个用户项,该项是您试图获取其第一个元素的数组。您需要检查结果对象以查看它返回到您的程序时的样子。