mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
TcpClient: Combine two identical function calls into one
This commit is contained in:
parent
15e06f9ce2
commit
7ffe2b3130
|
@ -11,6 +11,7 @@ from telethon.utils import BinaryWriter
|
||||||
class TcpClient:
|
class TcpClient:
|
||||||
def __init__(self, proxy=None):
|
def __init__(self, proxy=None):
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
||||||
if proxy:
|
if proxy:
|
||||||
try:
|
try:
|
||||||
import socks
|
import socks
|
||||||
|
@ -20,8 +21,9 @@ class TcpClient:
|
||||||
print("Can't import PySocks, fallback to vanilla socket. "
|
print("Can't import PySocks, fallback to vanilla socket. "
|
||||||
"Proxy settings are ignored. "
|
"Proxy settings are ignored. "
|
||||||
"Try to install PySocks via pip")
|
"Try to install PySocks via pip")
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
proxy = None
|
||||||
else:
|
|
||||||
|
if not proxy:
|
||||||
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
|
||||||
# Support for multi-threading advantages and safety
|
# Support for multi-threading advantages and safety
|
||||||
|
|
Loading…
Reference in New Issue
Block a user