mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 20:59:29 +00:00
Recursively bind when using Object.bind()
This commit is contained in:
parent
5c0806a8a9
commit
6eadb75086
@ -29,7 +29,7 @@ class Object:
|
|||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
def bind(self, client: "pyrogram.Client"):
|
def bind(self, client: "pyrogram.Client"):
|
||||||
"""Bind a Client instance to this Pyrogram Object
|
"""Recursively bind a Client instance to this and to all nested Pyrogram objects.
|
||||||
|
|
||||||
Parameters:
|
Parameters:
|
||||||
client (:obj:`~pyrogram.types.Client`):
|
client (:obj:`~pyrogram.types.Client`):
|
||||||
@ -38,6 +38,12 @@ class Object:
|
|||||||
"""
|
"""
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
|
for i in self.__dict__:
|
||||||
|
o = getattr(self, i)
|
||||||
|
|
||||||
|
if isinstance(o, Object):
|
||||||
|
o.bind(client)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def default(obj: "Object"):
|
def default(obj: "Object"):
|
||||||
if isinstance(obj, bytes):
|
if isinstance(obj, bytes):
|
||||||
|
Loading…
Reference in New Issue
Block a user