Fixed CTX_MESSAGE_TYPE typing

This commit is contained in:
2026-09-12 22:56:45 +03:00
parent cb520814d8
commit a90cd66d3e
2 changed files with 3 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any, TYPE_CHECKING from typing import Any, TYPE_CHECKING
from .types import ContextDataKey from .types import ContextDataKey, MessageType
from nio import MatrixRoom, Event from nio import MatrixRoom, Event
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
CTX_BODY = ContextDataKey[str]("CTX_BODY") CTX_BODY = ContextDataKey[str]("CTX_BODY")
"""Value of `event.body`""" """Value of `event.body`"""
CTX_MESSAGE_TYPE = ContextDataKey[str]("CTX_MESSAGE_TYPE") CTX_MESSAGE_TYPE = ContextDataKey[MessageType]("CTX_MESSAGE_TYPE")
"""Value of `msgtype` for the event""" """Value of `msgtype` for the event"""
CTX_SENDER = ContextDataKey[str]("CTX_SENDER") CTX_SENDER = ContextDataKey[str]("CTX_SENDER")

View File

@@ -33,7 +33,7 @@ class MessageTypeFilter(BaseEventFilter):
msgtype = context.event.source["content"]["msgtype"] msgtype = context.event.source["content"]["msgtype"]
if not msgtype in [t.value for t in self._types]: if not msgtype in [t.value for t in self._types]:
return False return False
context[CTX_MESSAGE_TYPE] = msgtype context[CTX_MESSAGE_TYPE] = MessageType(msgtype)
return True return True
class NewMessageFilter(BaseEventFilter): class NewMessageFilter(BaseEventFilter):