Fixed RoomEncryptedFilter
This commit is contained in:
@@ -31,6 +31,9 @@ CTX_CMD_VERB = ContextDataKey[str]("CTX_CMD_VERB")
|
|||||||
CTX_CMD_ARGS = ContextDataKey[list[str]]("CTX_CMD_ARGS")
|
CTX_CMD_ARGS = ContextDataKey[list[str]]("CTX_CMD_ARGS")
|
||||||
"""Arguments that were passed with the command"""
|
"""Arguments that were passed with the command"""
|
||||||
|
|
||||||
|
CTX_ROOM_ENCRYPTED = ContextDataKey[bool]("CTX_ROOM_ENCRYPTED")
|
||||||
|
"""True if the room is encrypted"""
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# EventContext implementation
|
# EventContext implementation
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
from .base import BaseEventFilter
|
from .base import BaseEventFilter
|
||||||
|
|
||||||
from nio import AsyncClient
|
from ..context import EventContext, CTX_ROOM_ENCRYPTED
|
||||||
from nio import MatrixRoom, Event
|
|
||||||
|
|
||||||
class RoomEncryptedFilter(BaseEventFilter):
|
class RoomEncryptedFilter(BaseEventFilter):
|
||||||
"""
|
"""
|
||||||
@@ -10,8 +9,11 @@ class RoomEncryptedFilter(BaseEventFilter):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
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:
|
try:
|
||||||
return room.encrypted
|
context[CTX_ROOM_ENCRYPTED] = context.room.encrypted
|
||||||
|
return context.room.encrypted
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
Reference in New Issue
Block a user