from telethon.sync import TelegramClient
from telethon import functions, types
api_id = 1111
api_hash = '1111111111111111111111'
name = "test"
def runn():
with TelegramClient(name, api_id, api_hash) as client:
result = client(functions.contacts.GetContactsRequest(hash=0))
file2 = open(f"111.txt", "w", encoding="utf8")
for u in result.users:
file2.write(str(u) + '\n')
runn()
client.start('0')
client = TelegramClient(phone=xxxxxxxxxx)
def code_callback():
while True:
#ждем код
return code
await client.start(phone=phone, code_callback=code_callback)