mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-03-13 16:05:49 +03:00
Fix documentation for events
Changing the .__name__ of a class will make it not show in the generated documentation, so instead we need to use a different variable.
This commit is contained in:
parent
89ae0cb164
commit
3550974b71
|
@ -70,6 +70,7 @@ class _EventBuilder(abc.ABC):
|
||||||
|
|
||||||
class _EventCommon(abc.ABC):
|
class _EventCommon(abc.ABC):
|
||||||
"""Intermediate class with common things to all events"""
|
"""Intermediate class with common things to all events"""
|
||||||
|
_event_name = 'Event'
|
||||||
|
|
||||||
def __init__(self, chat_peer=None, msg_id=None, broadcast=False):
|
def __init__(self, chat_peer=None, msg_id=None, broadcast=False):
|
||||||
self._entities = {}
|
self._entities = {}
|
||||||
|
@ -179,7 +180,7 @@ class _EventCommon(abc.ABC):
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
d = {k: v for k, v in self.__dict__.items() if k[0] != '_'}
|
d = {k: v for k, v in self.__dict__.items() if k[0] != '_'}
|
||||||
d['_'] = self.__class__.__name__
|
d['_'] = self._event_name
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,7 +198,7 @@ class Raw(_EventBuilder):
|
||||||
def _name_inner_event(cls):
|
def _name_inner_event(cls):
|
||||||
"""Decorator to rename cls.Event 'Event' as 'cls.Event'"""
|
"""Decorator to rename cls.Event 'Event' as 'cls.Event'"""
|
||||||
if hasattr(cls, 'Event'):
|
if hasattr(cls, 'Event'):
|
||||||
cls.Event.__name__ = '{}.Event'.format(cls.__name__)
|
cls.Event._event_name = '{}.Event'.format(cls.__name__)
|
||||||
else:
|
else:
|
||||||
warnings.warn('Class {} does not have a inner Event'.format(cls))
|
warnings.warn('Class {} does not have a inner Event'.format(cls))
|
||||||
return cls
|
return cls
|
||||||
|
@ -1061,6 +1062,9 @@ class MessageEdited(NewMessage):
|
||||||
event._entities = update.entities
|
event._entities = update.entities
|
||||||
return self._message_filter_event(event)
|
return self._message_filter_event(event)
|
||||||
|
|
||||||
|
class Event(NewMessage.Event):
|
||||||
|
pass # Required if we want a different name for it
|
||||||
|
|
||||||
|
|
||||||
@_name_inner_event
|
@_name_inner_event
|
||||||
class MessageDeleted(_EventBuilder):
|
class MessageDeleted(_EventBuilder):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user