]> git.aero2k.de Git - urlbot-v3.git/commitdiff
fix didyouknow
authorThorsten <mail@aero2k.de>
Sun, 25 Oct 2026 12:56:54 +0000 (13:56 +0100)
committerThorsten <mail@aero2k.de>
Sun, 25 Oct 2026 13:05:53 +0000 (14:05 +0100)
src/distbot/plugins/didyouknow.py

index 7f1a8423905efffbc33a2c6a7b485064de61e2c7..c9411d057e427d3b2f8c7d94d1e62c2175c6155d 100644 (file)
@@ -1,11 +1,15 @@
 # -*- coding: utf-8 -*-
 import json
 import random
+import re
 
 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)
+
 # 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 = [
@@ -39,7 +43,8 @@ class DidYouKnow(Worker):
         words = get_words(msg)
         if "wusstet" in map(lambda w: w.lower(), words) and ">" not in msg:
             fact = self.get_random_fact()
-            self.insert_fact(msg)
+            if not QUOTED.search(msg["body"]):
+                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":