diff --git a/reactbot/config.py b/reactbot/config.py index 379dead..1f37570 100644 --- a/reactbot/config.py +++ b/reactbot/config.py @@ -53,6 +53,7 @@ class Config(BaseProxyConfig): def _make_rule(self, name: str, rule: Dict[str, Any]) -> Rule: try: return Rule(rooms=set(rule.get("rooms", [])), + not_rooms=set(rule.get("not_rooms", [])), matches=self._compile_all(rule["matches"]), not_matches=self._compile_all(rule.get("not_matches", [])), type=EventType.find(rule["type"]) if "type" in rule else None, diff --git a/reactbot/rule.py b/reactbot/rule.py index 49220c1..441ffb7 100644 --- a/reactbot/rule.py +++ b/reactbot/rule.py @@ -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: