modular-bot-framework-for-t.../modules/qna-basic/index.py

26 lines
708 B
Python
Raw Normal View History

2022-10-31 22:14:53 +02:00
msg = self.MESSAGE["text"].lower()
responce_given = False
for file in os.listdir(self.path + "db/"):
if responce_given:
break
try:
criteria = json.loads( readfile(self.path + "db/" + file) )
for wordset in criteria["trigger_lists"]:
all_words_in = True
for word in wordset:
if not word in msg:
all_words_in = False
break
if all_words_in:
self.RESPONCE = criteria["responce_text"]
responce_given = True
break
except Exception as e:
print("[WARN] module : qna-basic: db file {} raised exception \"{}\"".format(file, e))