Fixed RoomEncryptedFilter

This commit is contained in:
2026-09-12 23:01:48 +03:00
parent a90cd66d3e
commit 0b79d78715
2 changed files with 9 additions and 4 deletions

View File

@@ -31,6 +31,9 @@ CTX_CMD_VERB = ContextDataKey[str]("CTX_CMD_VERB")
CTX_CMD_ARGS = ContextDataKey[list[str]]("CTX_CMD_ARGS")
"""Arguments that were passed with the command"""
CTX_ROOM_ENCRYPTED = ContextDataKey[bool]("CTX_ROOM_ENCRYPTED")
"""True if the room is encrypted"""
#
# EventContext implementation

View File

@@ -1,7 +1,6 @@
from .base import BaseEventFilter
from nio import AsyncClient
from nio import MatrixRoom, Event
from ..context import EventContext, CTX_ROOM_ENCRYPTED
class RoomEncryptedFilter(BaseEventFilter):
"""
@@ -10,8 +9,11 @@ class RoomEncryptedFilter(BaseEventFilter):
def __init__(self):
super().__init__()
async def __call__(self, room: MatrixRoom, event: Event, client: AsyncClient) -> bool:
async def __call__(self, context: EventContext) -> bool:
if not await super().__call__(context):
return False
try:
return room.encrypted
context[CTX_ROOM_ENCRYPTED] = context.room.encrypted
return context.room.encrypted
except:
return False