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")
|
||||
"""Arguments that were passed with the command"""
|
||||
|
||||
CTX_ROOM_ENCRYPTED = ContextDataKey[bool]("CTX_ROOM_ENCRYPTED")
|
||||
"""True if the room is encrypted"""
|
||||
|
||||
|
||||
#
|
||||
# EventContext implementation
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user