hotwords via $HOTWORDS actually less broken

master
bel 2023-03-25 21:38:53 -06:00
parent 6282972374
commit 8d608c7470
1 changed files with 14 additions and 5 deletions

View File

@ -104,13 +104,15 @@ class Reactor(threading.Thread):
threading.Thread.__init__(self)
self.inq = inq
self.outq = outq
self.load_hotwords = Reactor.new_load_hotwords
self.load_hotwords()
self.load_hotwords = Reactor.new_load_hotwords()
[i for i in self.load_hotwords()]
def new_load_hotwords():
p = environ.get("REACTOR_HOTWORDS", None)
p = environ.get("HOTWORDS", None)
if not p:
return lambda: []
def load_nothing():
return []
return load_nothing
try:
def load_hotwords_in_file():
@ -136,7 +138,14 @@ class Reactor(threading.Thread):
def handle(self, text):
hotwords = self.load_hotwords()
print(text)
if not hotwords:
self.outq.put(text)
return
cleantext = "".join([i for i in "".join(text.lower().split()) if i.isalpha()])
for i in hotwords:
if i in cleantext:
log("hotword", i, "in", text, "as", cleantext)
self.outq.put(i)
class Actor(threading.Thread):
def __init__(self, inq):