无法通过Telethon连接到电报

时间:2019-06-08 16:39:12

标签: python telegram telethon

我正在尝试通过Telethon从Python应用程序连接到电报

proxy_ip = str('188.166.86.173')
proxy_port = str(1080)
with TelegramClient('anon',
                api_id='123456',
                api_hash='1234567890abcdf',
                proxy=(socks.SOCKS5, str(proxy_ip), proxy_port,True),
                connection=connection.tcpmtproxy.TcpMTProxy
                ) as client:

我知道

  

getaddrinfo()参数1必须为字符串或无

我不明白我在哪里使用了错误的参数

1 个答案:

答案 0 :(得分:0)

首先对您的代理执行ping操作,以检查其是否正常运行, 然后更改此内容:

proxy_port = str(1080)

对此:

proxy_port = 1080

您应该将proxy_port传递为int而非字符串。 而且您不需要这个connection=connection.tcpmtproxy.TcpMTProxy) as client: 因此将其从您的代码中删除。 现在应该可以了。 查看文档以获取有关您问题的更多信息: Creating a Client in telethonn