mirror of
https://github.com/pyrogram/pyrogram
synced 2025-08-28 12:57:52 +00:00
Merge pull request #332 from pyrogram/add-bind
Add .bind() method to re-enable bound-methods after deserialization
This commit is contained in:
commit
ec15534cdd
@ -32,8 +32,15 @@ class Object(metaclass=Meta):
|
|||||||
def __init__(self, client: "pyrogram.BaseClient" = None):
|
def __init__(self, client: "pyrogram.BaseClient" = None):
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
if self._client is None:
|
def bind(self, client: "pyrogram.BaseClient"):
|
||||||
del self._client
|
"""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
|
@staticmethod
|
||||||
def default(obj: "Object"):
|
def default(obj: "Object"):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user