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 word not in msg:
2022-10-31 22:14:53 +02:00
all_words_in = False
break
if all_words_in:
2023-05-08 10:14:28 +03:00
self.RESPONSE = criteria["responce_text"]
2022-10-31 22:14:53 +02:00
responce_given = True
break
except Exception as e:
print("[WARN] module : qna-basic: db file {} raised exception \"{}\"".format(file, e))