mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2026-09-04 16:10:39 +00:00
Update proxy docs and warn if python-socks is not installed
As suggested in #4505.
This commit is contained in:
@@ -9,6 +9,7 @@ import time
|
||||
import typing
|
||||
import datetime
|
||||
import pathlib
|
||||
import warnings
|
||||
|
||||
from .. import utils, version, helpers, __name__ as __base_name__
|
||||
from ..crypto import rsa
|
||||
@@ -19,6 +20,11 @@ from ..tl import functions, types
|
||||
from ..tl.alltlobjects import LAYER
|
||||
from .._updates import MessageBox, EntityCache as MbEntityCache, SessionState, ChannelState, Entity, EntityType
|
||||
|
||||
try:
|
||||
import python_socks
|
||||
except ImportError:
|
||||
python_socks = None
|
||||
|
||||
DEFAULT_DC_ID = 2
|
||||
DEFAULT_IPV4_IP = '149.154.167.51'
|
||||
DEFAULT_IPV6_IP = '2001:67c:4e8:f002::a'
|
||||
@@ -104,12 +110,12 @@ class TelegramBaseClient(abc.ABC):
|
||||
By default this is `False` as IPv6 support is not
|
||||
too widespread yet.
|
||||
|
||||
proxy (`tuple` | `list` | `dict`, optional):
|
||||
proxy (`dict`, optional):
|
||||
An iterable consisting of the proxy info. If `connection` is
|
||||
one of `MTProxy`, then it should contain MTProxy credentials:
|
||||
``('hostname', port, 'secret')``. Otherwise, it's meant to store
|
||||
function parameters for PySocks, like ``(type, 'hostname', port)``.
|
||||
See https://github.com/Anorov/PySocks#usage-1 for more.
|
||||
``hostname, port, secret``. Otherwise, it's meant to store
|
||||
function parameters for PySocks, like ``type, hostname, port``.
|
||||
See https://github.com/romis2012/python-socks for more.
|
||||
|
||||
local_addr (`str` | `tuple`, optional):
|
||||
Local host address (and port, optionally) used to bind the socket to locally.
|
||||
@@ -340,6 +346,9 @@ class TelegramBaseClient(abc.ABC):
|
||||
self._timeout = timeout
|
||||
self._auto_reconnect = auto_reconnect
|
||||
|
||||
if proxy and not python_socks:
|
||||
warnings.warn('proxy argument will be ignored because python-socks is not installed')
|
||||
|
||||
assert isinstance(connection, type)
|
||||
self._connection = connection
|
||||
init_proxy = None if not issubclass(connection, TcpMTProxy) else \
|
||||
|
||||
Reference in New Issue
Block a user