From: Thorsten Date: Sun, 25 Oct 2026 13:20:03 +0000 (+0100) Subject: didyouknow: ignore quoted lines instead of checking the msg dict X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=HEAD;p=urlbot-v3.git didyouknow: ignore quoted lines instead of checking the msg dict ">" 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 --- diff --git a/src/distbot/plugins/didyouknow.py b/src/distbot/plugins/didyouknow.py index c9411d0..06eddd0 100644 --- a/src/distbot/plugins/didyouknow.py +++ b/src/distbot/plugins/didyouknow.py @@ -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 -# 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. @@ -41,10 +41,9 @@ class DidYouKnow(Worker): 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() - 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":