mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-04 14:24: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
|
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 a new issue