I
I
Ilkhomjon Matazimov2020-08-14 19:12:46
Python
Ilkhomjon Matazimov, 2020-08-14 19:12:46

I'm trying to log in to Telegram via telethon, but an error occurs with asynchrony. Helpanyote?

I use the telethon library to interact with the Telegram API. I use the code for authorization with a proxy. But it’s not enough to simply indicate there proxy=(), so I’m acting with sockets from the PySocks library :

from telethon import TelegramClient
import socks
import socket

socks.set_default_proxy(socks.SOCKS5, addr='адрес', port=1234,
                        username='логин', password='пароль')
socket.socket = socks.socksocket

phone = '+7..........'
api_id = 1234567
api_hash = 'апи_хэш'
session = phone

client = TelegramClient(session, api_id, api_hash)
client.start()


Gives an error (log here ):
Traceback (most recent call last):
  File "C:\Program Files\Python38\lib\asyncio\base_events.py", line 656, in __del__
  File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 684, in close
  File "C:\Program Files\Python38\lib\asyncio\proactor_events.py", line 752, in _close_self_pipe
AttributeError: 'ProactorEventLoop' object has no attribute '_ssock'

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DVamp1r3, 2020-08-15
@DVamp1r3

proxy = (socks.SOCKS5, ip, port)
client = TelegramClient(session_name, options.id, options.hash, proxy=proxy)

works great. pysocks most likely has a different structure, which is why the AttributeError appears

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question