from typing import Set

from cogbot.cogs.robo_mod.robo_mod_condition import RoboModCondition
from cogbot.cogs.robo_mod.robo_mod_trigger import RoboModTrigger


class MessageContainsAnyOfCondition(RoboModCondition):
    def __init__(self):
        self.matches: Set[str]
        self.ignore_case: bool

    async def update(self, state: "RoboModServerState", data: dict):
        matches = set(data["matches"])
        ignore_case = data.get("ignore_case", False)
        if ignore_case:
            matches = set(match.lower() for match in matches)
        if len(matches) <= 0:
            raise ValueError("matches cannot be empty")
        self.matches = matches
        self.ignore_case = ignore_case

    async def check(self, trigger: RoboModTrigger) -> bool:
        for match in self.matches:
            msg = str(trigger.message.content)
            # Short-circuit if msg is too short to contain match.
            if len(msg) < len(match):
                continue
            if self.ignore_case:
                msg = msg.lower()
            if match in msg:
                return True
        return False

@@ -1,12 +1,31 @@
+import unicodedata%0A
 from typing 
@@ -281,16 +281,23 @@
 Set%5Bstr%5D
+ = None
 %0A       
@@ -319,16 +319,506 @@
 se: bool
+ = None%0A        self.normalize_unicode: bool = None%0A%0A    def __str__(self) -%3E str:%0A        params = dict(%0A            matches=f%22%7Bself.matches!r%7D%22,%0A            ignore_case=f%22%7Bself.ignore_case!r%7D%22,%0A            normalize_unicode=f%22%7Bself.normalize_unicode!r%7D%22,%0A        )%0A        pairs = (f%22%7Bk%7D=%7Bv%7D%22 for k, v in params.items())%0A        return %22%22.join((f%22%7Bself.__class__.__name__%7D(%22, %22, %22.join(pairs), %22)%22))%0A%0A    def normalize(self, s: str) -%3E str:%0A        return unicodedata.normalize(%22NFKD%22, s)
 %0A%0A    as
@@ -1058,16 +1058,181 @@
 atches)%0A
+        normalize_unicode = data.get(%22normalize_unicode%22, False)%0A        if normalize_unicode:%0A            matches = set(self.normalize(match) for match in matches)%0A
         
@@ -1378,16 +1378,67 @@
 ore_case
+%0A        self.normalize_unicode = normalize_unicode
 %0A%0A    as
@@ -1727,32 +1727,32 @@
 lf.ignore_case:%0A
-
                 
@@ -1769,16 +1769,97 @@
 lower()%0A
+            if self.normalize_unicode:%0A                msg = self.normalize(msg)%0A
         

Add unicode normalization option