Merge 8180815b38
into 7fd6dd1a3c
This commit is contained in:
commit
76c25b1f03
4 changed files with 48 additions and 1 deletions
|
@ -106,4 +106,5 @@ class ReactBot(Plugin):
|
||||||
await rule.execute(evt, match)
|
await rule.execute(evt, match)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.log.exception(f"Failed to execute {name} in {evt.room_id}")
|
self.log.exception(f"Failed to execute {name} in {evt.room_id}")
|
||||||
|
if not rule.continue_after_match:
|
||||||
return
|
return
|
||||||
|
|
|
@ -64,6 +64,7 @@ class Config(BaseProxyConfig):
|
||||||
type=EventType.find(rule["type"]) if "type" in rule else None,
|
type=EventType.find(rule["type"]) if "type" in rule else None,
|
||||||
template=self.templates[rule["template"]],
|
template=self.templates[rule["template"]],
|
||||||
variables=self._parse_variables(rule),
|
variables=self._parse_variables(rule),
|
||||||
|
continue_after_match=rule.get("continue_after_match", True),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ConfigError(f"Failed to load {name}") from e
|
raise ConfigError(f"Failed to load {name}") from e
|
||||||
|
|
|
@ -35,6 +35,7 @@ class Rule:
|
||||||
template: Template
|
template: Template
|
||||||
type: Optional[EventType]
|
type: Optional[EventType]
|
||||||
variables: Dict[str, Any]
|
variables: Dict[str, Any]
|
||||||
|
continue_after_match: bool
|
||||||
|
|
||||||
def _check_not_match(self, body: str) -> bool:
|
def _check_not_match(self, body: str) -> bool:
|
||||||
for pattern in self.not_matches:
|
for pattern in self.not_matches:
|
||||||
|
|
44
samples/your-opinion.yaml
Normal file
44
samples/your-opinion.yaml
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
templates:
|
||||||
|
reaction:
|
||||||
|
type: m.reaction
|
||||||
|
variables:
|
||||||
|
react_to_event: '{{event.content.get_reply_to() or event.event_id}}'
|
||||||
|
content:
|
||||||
|
m.relates_to:
|
||||||
|
rel_type: m.annotation
|
||||||
|
event_id: $${react_to_event}
|
||||||
|
key: $${reaction}
|
||||||
|
|
||||||
|
|
||||||
|
default_flags:
|
||||||
|
- ignorecase
|
||||||
|
antispam:
|
||||||
|
room:
|
||||||
|
max: 60
|
||||||
|
delay: 60
|
||||||
|
user:
|
||||||
|
max: 60
|
||||||
|
delay: 60
|
||||||
|
|
||||||
|
rules:
|
||||||
|
opinon_up:
|
||||||
|
raw: false
|
||||||
|
matches: '#youropinion\b(?!`)'
|
||||||
|
template: reaction
|
||||||
|
continue_after_match: true
|
||||||
|
variables:
|
||||||
|
reaction: 👍
|
||||||
|
opinion_down:
|
||||||
|
raw: false
|
||||||
|
matches: '#youropinion\b(?!`)'
|
||||||
|
template: reaction
|
||||||
|
continue_after_match: true
|
||||||
|
variables:
|
||||||
|
reaction: 👎
|
||||||
|
opinon_shrug:
|
||||||
|
raw: false
|
||||||
|
matches: '#youropinion\b(?!`)'
|
||||||
|
template: reaction
|
||||||
|
variables:
|
||||||
|
reaction: 🤷
|
||||||
|
|
Loading…
Add table
Reference in a new issue