# -*- 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 = [
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":