Telethon (TelegramClient) — как подставить значение переменной в (Please enter your phone (or bot token): )?
При создании новой сессии в консоль выводится "Please enter your phone (or bot token): " Можно ли как-то подставлять переменную в этот инпут в консоли автоматом?
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()
Ответы (1 шт):
Автор решения: Robot
→ Ссылка
from telethon.sync import TelegramClient
from telethon import functions, types
api_id = 'id'
api_hash = 'hash'
name = 'test'
phone = '+phone'
def runn():
with TelegramClient(name, api_id, api_hash).start(phone) 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()