File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 1515#
1616# You should have received a copy of the GNU Lesser General Public License
1717# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+ from importlib import import_module
20+
21+ from .all import objects
22+ from .core .object import Object
23+
24+ for k , v in objects .items ():
25+ path , name = v .rsplit ("." , 1 )
26+ Object .all [k ] = getattr (import_module ("pyrogram.api." + path ), name )
Original file line number Diff line number Diff line change 1818
1919from collections import OrderedDict
2020from datetime import datetime
21- from importlib import import_module
2221from io import BytesIO
2322from json import JSONEncoder , dumps
2423
2524from ..all import objects
2625
2726
2827class Object :
28+ all = {}
29+
2930 @staticmethod
3031 def read (b : BytesIO , * args ):
31- id = int .from_bytes (b .read (4 ), "little" )
32- name = objects .get (id )
33- path , name = name .rsplit ("." , 1 )
34-
35- return getattr (
36- import_module ("pyrogram.api." + path ),
37- name
38- ).read (b , * args )
32+ return Object .all [int .from_bytes (b .read (4 ), "little" )].read (b , * args )
3933
4034 def write (self , * args ) -> bytes :
4135 pass
You can’t perform that action at this time.
0 commit comments