feat: TelegramObject readable representation (#796)

This commit is contained in:
Oleg A 2021-12-29 04:38:37 +03:00 committed by GitHub
parent 763efb7763
commit 583f00ce31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -211,6 +211,15 @@ class TelegramObject(ContextInstanceMixin, metaclass=MetaTelegramObject):
"""
return self.as_json()
def __repr__(self) -> str:
"""
Return object readable representation.
Example: <ObjectName {"id": 123456}>
:return: object class name and object data as a string
"""
return f"<{type(self).__name__} {self}>"
def __getitem__(self, item: typing.Union[str, int]) -> typing.Any:
"""
Item getter (by key)