]> git.aero2k.de Git - urlbot-v3.git/commitdiff
didyouknow: ignore quoted lines instead of checking the msg dict master
authorThorsten <mail@aero2k.de>
Sun, 25 Oct 2026 13:20:03 +0000 (14:20 +0100)
committerThorsten <mail@aero2k.de>
Sun, 25 Oct 2026 13:20:03 +0000 (14:20 +0100)
">" not in msg tested the dict keys, so the quote filter never
matched. Check for a ">" at the start of any line of the body.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
src/distbot/plugins/didyouknow.py

index c9411d057e427d3b2f8c7d94d1e62c2175c6155d..06eddd075aaa4dfecaffcb7852561f3a46f04047 100644 (file)
@@ -7,8 +7,8 @@ from distbot.common.message import get_nick_from_message, get_words
 from distbot.bot.worker import Worker
 from distbot.common.action import Action
 
 from distbot.bot.worker import Worker
 from distbot.common.action import Action
 
-# A "wusstet" directly behind an opening quotation mark is a quote, not a new fact.
-QUOTED = re.compile(r"[\"'„“”‚‘’»«›‹]\s*wusstet\b", re.IGNORECASE)
+# Chat-client style quote ("> wusstet ihr ...") at the start of any line.
+QUOTED_LINE = re.compile(r"^\s*>", re.MULTILINE)
 
 # DB timestamp: 03.01.2019 <-- 2023-01-29/leolein: Einträge wurden raus getan.
 # 2023-01-28/leolein: Von nun an soll der Bot mit brauchbaren Ontopic-Tipps reagieren können.
 
 # DB timestamp: 03.01.2019 <-- 2023-01-29/leolein: Einträge wurden raus getan.
 # 2023-01-28/leolein: Von nun an soll der Bot mit brauchbaren Ontopic-Tipps reagieren können.
@@ -41,10 +41,9 @@ class DidYouKnow(Worker):
     def parse_body(self, msg):
         sender = get_nick_from_message(msg)
         words = get_words(msg)
     def parse_body(self, msg):
         sender = get_nick_from_message(msg)
         words = get_words(msg)
-        if "wusstet" in map(lambda w: w.lower(), words) and ">" not in msg:
+        if "wusstet" in map(lambda w: w.lower(), words) and not QUOTED_LINE.search(msg["body"]):
             fact = self.get_random_fact()
             fact = self.get_random_fact()
-            if not QUOTED.search(msg["body"]):
-                self.insert_fact(msg)
+            self.insert_fact(msg)
             answer = random.choice(self.answers)
             return Action(msg="{} {}".format(answer, (fact[0].upper() + fact[1:]) if answer.endswith(".") else fact))
         elif words[0] == "Hi" and sender == "Q":
             answer = random.choice(self.answers)
             return Action(msg="{} {}".format(answer, (fact[0].upper() + fact[1:]) if answer.endswith(".") else fact))
         elif words[0] == "Hi" and sender == "Q":