🐛 The `EventMatchResult` object shouldn't be initialized with `args` from the event.

If there's a good use-case for overriding `Event._matches_condition`
with a logic that also parses the event arguments, then those arguments
should be accessed directly from the event object, not from the match
result.

Initializing `EventMatchResult` with the arguments from the event means
that, if `EventMatchResult.parsed_args` are populated with custom
extracted arguments, then the upstream event arguments will also be
modified.

If the event is matched against multiple conditions, this will result in
the extracted tokens getting modified by each `matches_condition`
iteration.
This commit is contained in:
Fabio Manganiello 2024-04-24 00:18:30 +02:00
parent a3972e55b6
commit 6b20c2083b
Signed by: blacklight
GPG Key ID: D90FBA7F76362774
1 changed files with 1 additions and 1 deletions

View File

@ -220,7 +220,7 @@ class Event(Message):
:param condition: The platypush.event.hook.EventCondition object
"""
result = EventMatchResult(is_match=False, parsed_args=self.args)
result = EventMatchResult(is_match=False)
match_scores = []
if not isinstance(self, condition.type):