">" 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>
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.
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)
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":