mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2025-12-29 20:14:51 +00:00
Recursively bind when using Object.bind()
This commit is contained in:
parent
5c0806a8a9
commit
6eadb75086
1 changed files with 7 additions and 1 deletions
|
|
@ -29,7 +29,7 @@ class Object:
|
|||
self._client = 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:
|
||||
client (:obj:`~pyrogram.types.Client`):
|
||||
|
|
@ -38,6 +38,12 @@ class Object:
|
|||
"""
|
||||
self._client = client
|
||||
|
||||
for i in self.__dict__:
|
||||
o = getattr(self, i)
|
||||
|
||||
if isinstance(o, Object):
|
||||
o.bind(client)
|
||||
|
||||
@staticmethod
|
||||
def default(obj: "Object"):
|
||||
if isinstance(obj, bytes):
|
||||
|
|
|
|||
Loading…
Reference in a new issue