Reputation: 13
When I run this code:
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))
it gives me this error:
AttributeError: 'coroutine' object has no attribute 'users'
Help, please(
Upvotes: 0
Views: 3518
Reputation: 2133
From your code it appears the issue is that the client() call returned result and you expected the result variable to have a users item that is an array that you were trying to get the first element of. You need to check the result object to see what it looks like when its returned to your program.
Upvotes: 1