Add option to exclude specific rooms from a rule

This commit is contained in:
Tulir Asokan 2019-07-31 19:28:15 +03:00
parent 50141c8a92
commit 217351d141
2 changed files with 4 additions and 0 deletions

View file

@ -31,6 +31,7 @@ RPattern = Union[Pattern, SimplePattern]
@dataclass
class Rule:
rooms: Set[RoomID]
not_rooms: Set[RoomID]
matches: List[RPattern]
not_matches: List[RPattern]
template: Template
@ -46,6 +47,8 @@ class Rule:
def match(self, evt: MessageEvent) -> Optional[Match]:
if len(self.rooms) > 0 and evt.room_id not in self.rooms:
return None
elif evt.room_id in self.not_rooms:
return None
for pattern in self.matches:
match = pattern.search(evt.content.body)
if match: