Add .bind() method to re-enable bound-methods after deserialization

This commit is contained in:
Dan 2019-10-27 09:53:40 +01:00
parent 9afd244eb6
commit 1609efbfbc

View File

@ -32,8 +32,15 @@ class Object(metaclass=Meta):
def __init__(self, client: "pyrogram.BaseClient" = None):
self._client = client
if self._client is None:
del self._client
def bind(self, client: "pyrogram.BaseClient"):
"""Bind a Client instance to this Pyrogram Object
Parameters:
client (:obj:`Client`):
The Client instance to bind this object with. Useful to re-enable bound methods after serializing and
deserializing Pyrogram objects with ``repr`` and ``eval``.
"""
self._client = client
@staticmethod
def default(obj: "Object"):