Skip to content
This repository was archived by the owner on Dec 23, 2024. It is now read-only.

Commit 6eadb75

Browse files
committed
Recursively bind when using Object.bind()
1 parent 5c0806a commit 6eadb75

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pyrogram/types/object.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, client: "pyrogram.Client" = None):
2929
self._client = client
3030

3131
def bind(self, client: "pyrogram.Client"):
32-
"""Bind a Client instance to this Pyrogram Object
32+
"""Recursively bind a Client instance to this and to all nested Pyrogram objects.
3333
3434
Parameters:
3535
client (:obj:`~pyrogram.types.Client`):
@@ -38,6 +38,12 @@ def bind(self, client: "pyrogram.Client"):
3838
"""
3939
self._client = client
4040

41+
for i in self.__dict__:
42+
o = getattr(self, i)
43+
44+
if isinstance(o, Object):
45+
o.bind(client)
46+
4147
@staticmethod
4248
def default(obj: "Object"):
4349
if isinstance(obj, bytes):

0 commit comments

Comments
 (0)