Add events.Raw

This commit is contained in:
Lonami Exo 2024-06-04 22:00:49 +02:00
parent 44aed4cadb
commit b8d656efa5
3 changed files with 33 additions and 1 deletions

View File

@ -1,10 +1,11 @@
from .event import Continue, Event from .event import Continue, Event, Raw
from .messages import MessageDeleted, MessageEdited, MessageRead, NewMessage from .messages import MessageDeleted, MessageEdited, MessageRead, NewMessage
from .queries import ButtonCallback, InlineQuery from .queries import ButtonCallback, InlineQuery
__all__ = [ __all__ = [
"Continue", "Continue",
"Event", "Event",
"Raw",
"MessageDeleted", "MessageDeleted",
"MessageEdited", "MessageEdited",
"MessageRead", "MessageRead",

View File

@ -30,6 +30,34 @@ class Event(metaclass=NoPublicConstructor):
pass pass
class Raw(Event):
"""
Raw update type received from Telegram.
This event occurs when *any* update is received.
Like every other event, the raw update type is under the private member ``event._raw``.
Additionally, all peers received along with this update are present under ``self._chat_map``.
"""
def __init__(
self,
client: Client,
update: abcs.Update,
chat_map: dict[int, Peer],
):
self._client = client
self._raw = update
self._chat_map = chat_map
@classmethod
def _try_from_update(
cls, client: Client, update: abcs.Update, chat_map: dict[int, Peer]
) -> Optional[Self]:
return cls._create(client, update, chat_map)
class Continue: class Continue:
""" """
This is **not** an event type you can listen to. This is **not** an event type you can listen to.

View File

@ -5,6 +5,7 @@ Classes related to the different event types that wrap incoming Telegram updates
The :doc:`/concepts/updates` concept to learn how to listen to these events. The :doc:`/concepts/updates` concept to learn how to listen to these events.
""" """
from .._impl.client.events import ( from .._impl.client.events import (
ButtonCallback, ButtonCallback,
Continue, Continue,
@ -14,6 +15,7 @@ from .._impl.client.events import (
MessageEdited, MessageEdited,
MessageRead, MessageRead,
NewMessage, NewMessage,
Raw,
) )
__all__ = [ __all__ = [
@ -25,4 +27,5 @@ __all__ = [
"MessageEdited", "MessageEdited",
"MessageRead", "MessageRead",
"NewMessage", "NewMessage",
"Raw",
] ]