Match exact words to trigger calculator widget

The calculator was previously triggered for partial matches with words
like "calc", which meant searches containing the word "calcium" would
cause the calculator widget to appear.
This commit is contained in:
Ben Busby 2023-09-08 16:19:39 -06:00
parent abbe29d9d3
commit a623210244
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1

View File

@ -109,7 +109,9 @@ class Search:
self.widget = "ip" if re.search("([^a-z0-9]|^)my *[^a-z0-9] *(ip|internet protocol)" +
"($|( *[^a-z0-9] *(((addres|address|adres|" +
"adress)|a)? *$)))", self.query.lower()) else self.widget
self.widget = 'calculator' if re.search("calculator|calc|calclator|math", self.query.lower()) else self.widget
self.widget = 'calculator' if re.search(
r"\bcalculator\b|\bcalc\b|\bcalclator\b|\bmath\b",
self.query.lower()) else self.widget
return self.query
def generate_response(self) -> str: