diff --git a/pyrogram/types/object.py b/pyrogram/types/object.py index caf18373..8b6a5b99 100644 --- a/pyrogram/types/object.py +++ b/pyrogram/types/object.py @@ -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):