From 670f72631cfc875a98f060916ddb965e39c8d651 Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Tue, 24 Jun 2025 15:04:34 +0200 Subject: [PATCH] Conditions - Fixing "Does NOT contain" condition --- changedetectionio/conditions/__init__.py | 1 - changedetectionio/conditions/default_plugin.py | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changedetectionio/conditions/__init__.py b/changedetectionio/conditions/__init__.py index c09e526d..88bc46fa 100644 --- a/changedetectionio/conditions/__init__.py +++ b/changedetectionio/conditions/__init__.py @@ -16,7 +16,6 @@ operator_choices = [ ("==", "Equals"), ("!=", "Not Equals"), ("in", "Contains"), - ("!in", "Does Not Contain"), ] # Fields available in the rules diff --git a/changedetectionio/conditions/default_plugin.py b/changedetectionio/conditions/default_plugin.py index ea714ada..a8008828 100644 --- a/changedetectionio/conditions/default_plugin.py +++ b/changedetectionio/conditions/default_plugin.py @@ -21,17 +21,21 @@ def register_operators(): def length_max(_, text, strlen): return len(text) <= int(strlen) - # ✅ Custom function for case-insensitive regex matching + # Custom function for case-insensitive regex matching def contains_regex(_, text, pattern): """Returns True if `text` contains `pattern` (case-insensitive regex match).""" return bool(re.search(pattern, str(text), re.IGNORECASE)) - # ✅ Custom function for NOT matching case-insensitive regex + # Custom function for NOT matching case-insensitive regex def not_contains_regex(_, text, pattern): """Returns True if `text` does NOT contain `pattern` (case-insensitive regex match).""" return not bool(re.search(pattern, str(text), re.IGNORECASE)) + def not_contains(_, text, pattern): + return not pattern in text + return { + "!in": not_contains, "!contains_regex": not_contains_regex, "contains_regex": contains_regex, "ends_with": ends_with, @@ -43,6 +47,7 @@ def register_operators(): @hookimpl def register_operator_choices(): return [ + ("!in", "Does NOT Contain"), ("starts_with", "Text Starts With"), ("ends_with", "Text Ends With"), ("length_min", "Length minimum"),