Fixed CTX_MESSAGE_TYPE typing
This commit is contained in:
@@ -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")
|
||||||
|
|||||||
@@ -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):
|
||||||
|
|||||||
Reference in New Issue
Block a user