mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-28 00:56:19 +00:00
Don't call InitConnection on CDN DCs
This commit is contained in:
parent
a9087a2a8c
commit
14632c9bb1
@ -68,12 +68,14 @@ class Session:
|
|||||||
|
|
||||||
notice_displayed = False
|
notice_displayed = False
|
||||||
|
|
||||||
def __init__(self, dc_id: int, test_mode: bool, auth_key: bytes, api_id: str):
|
def __init__(self, dc_id: int, test_mode: bool, auth_key: bytes, api_id: str, is_cdn: bool = False):
|
||||||
if not Session.notice_displayed:
|
if not Session.notice_displayed:
|
||||||
print("Pyrogram v{}, {}".format(__version__, __copyright__))
|
print("Pyrogram v{}, {}".format(__version__, __copyright__))
|
||||||
print("Licensed under the terms of the " + __license__, end="\n\n")
|
print("Licensed under the terms of the " + __license__, end="\n\n")
|
||||||
Session.notice_displayed = True
|
Session.notice_displayed = True
|
||||||
|
|
||||||
|
self.is_cdn = is_cdn
|
||||||
|
|
||||||
self.connection = Connection(DataCenter(dc_id, test_mode))
|
self.connection = Connection(DataCenter(dc_id, test_mode))
|
||||||
|
|
||||||
self.api_id = api_id
|
self.api_id = api_id
|
||||||
@ -107,6 +109,8 @@ class Session:
|
|||||||
self.total_bytes = 0
|
self.total_bytes = 0
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
terms = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
self.connection.connect()
|
self.connection.connect()
|
||||||
@ -128,19 +132,20 @@ class Session:
|
|||||||
self.next_salt_thread = Thread(target=self.next_salt, name="NextSaltThread")
|
self.next_salt_thread = Thread(target=self.next_salt, name="NextSaltThread")
|
||||||
self.next_salt_thread.start()
|
self.next_salt_thread.start()
|
||||||
|
|
||||||
terms = self._send(
|
if not self.is_cdn:
|
||||||
functions.InvokeWithLayer(
|
terms = self._send(
|
||||||
layer,
|
functions.InvokeWithLayer(
|
||||||
functions.InitConnection(
|
layer,
|
||||||
self.api_id,
|
functions.InitConnection(
|
||||||
self.DEVICE_MODEL,
|
self.api_id,
|
||||||
self.SYSTEM_VERSION,
|
self.DEVICE_MODEL,
|
||||||
self.APP_VERSION,
|
self.SYSTEM_VERSION,
|
||||||
"en", "", "en",
|
self.APP_VERSION,
|
||||||
functions.help.GetTermsOfService(),
|
"en", "", "en",
|
||||||
|
functions.help.GetTermsOfService(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
).text
|
||||||
)
|
|
||||||
|
|
||||||
if self.ping_thread is not None:
|
if self.ping_thread is not None:
|
||||||
self.ping_thread.join()
|
self.ping_thread.join()
|
||||||
@ -161,7 +166,7 @@ class Session:
|
|||||||
|
|
||||||
log.debug("Session started")
|
log.debug("Session started")
|
||||||
|
|
||||||
return terms.text
|
return terms
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.is_connected.clear()
|
self.is_connected.clear()
|
||||||
|
Loading…
Reference in New Issue
Block a user