File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change 2222from hashlib import sha1
2323from io import BytesIO
2424from os import urandom
25+ from typing import Optional
2526
2627import pyrogram
2728from pyrogram import raw
3738class Auth :
3839 MAX_RETRIES = 5
3940
40- def __init__ (self , client : "pyrogram.Client" , dc_id : int , test_mode : bool ):
41+ def __init__ (
42+ self ,
43+ client : "pyrogram.Client" ,
44+ dc_id : int ,
45+ test_mode : bool
46+ ):
4147 self .dc_id = dc_id
4248 self .test_mode = test_mode
4349 self .ipv6 = client .ipv6
50+ self .alt_port = client .alt_port
4451 self .proxy = client .proxy
52+ self .connection_factory = client .connection_factory
53+ self .protocol_factory = client .protocol_factory
4554
46- self .connection = None
55+ self .connection : Optional [ Connection ] = None
4756
4857 @staticmethod
4958 def pack (data : TLObject ) -> bytes :
@@ -76,7 +85,15 @@ async def create(self):
7685 # The server may close the connection at any time, causing the auth key creation to fail.
7786 # If that happens, just try again up to MAX_RETRIES times.
7887 while True :
79- self .connection = Connection (self .dc_id , self .test_mode , self .ipv6 , self .proxy )
88+ self .connection = self .connection_factory (
89+ dc_id = self .dc_id ,
90+ test_mode = self .test_mode ,
91+ ipv6 = self .ipv6 ,
92+ alt_port = self .alt_port ,
93+ proxy = self .proxy ,
94+ media = False ,
95+ protocol_factory = self .protocol_factory
96+ )
8097
8198 try :
8299 log .info ("Start creating a new auth key on DC%s" , self .dc_id )
You can’t perform that action at this time.
0 commit comments