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,6 +132,7 @@ 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()
|
||||||
|
|
||||||
|
if not self.is_cdn:
|
||||||
terms = self._send(
|
terms = self._send(
|
||||||
functions.InvokeWithLayer(
|
functions.InvokeWithLayer(
|
||||||
layer,
|
layer,
|
||||||
@ -140,7 +145,7 @@ class Session:
|
|||||||
functions.help.GetTermsOfService(),
|
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