diff --git a/sopel_modules/SpiceBot/AI.py b/sopel_modules/SpiceBot/AI.py
index 8c8afb2..d1507d6 100644
--- a/sopel_modules/SpiceBot/AI.py
+++ b/sopel_modules/SpiceBot/AI.py
@@ -22,8 +22,8 @@ class SpiceBot_AI_MainSection(StaticSection):
class SpiceBot_AI():
def __init__(self):
- self.load_commands = [0]
- self.braindirs = {}
+ self.load_commands = {0: None}
+ self.braindirs = []
self.dict = {
"counts": 0,
"failcounts": 0,
@@ -63,21 +63,40 @@ class SpiceBot_AI():
for braindir in braindirs:
if braindir not in self.braindirs:
self.braindirs.append(braindir)
+ dirnumber = max(self.load_commands.keys()) + 1
+ self.load_commands[dirnumber] = braindir
tempbrain = tempfile.mkstemp()[1]
- with open(tempbrain, 'w') as fileo:
- fileo.write(
- ""
- " \n"
- " \n"
- " LOAD AIML B\n"
- " \n"
- " {}\n"
- " \n"
- " \n"
- "".format(os.path.join(braindir, "*.aiml"))
- )
+ # with open(tempbrain, 'w') as fileo:
+ # fileo.write(
+ # ""
+ # " \n"
+ # " \n"
+ # " LOAD AIML B\n"
+ # # " LOAD AIML {}\n"
+ # " \n"
+ # " {}\n"
+ # " \n"
+ # " \n"
+ # # "".format(str(dirnumber), os.path.join(braindir, "*"))
+ # "".format(os.path.join(braindir, "*.aiml"))
+ # )
+ brainfile = open(tempbrain, 'a')
+ brainfile.write("")
+ brainfile.write(" \n")
+ brainfile.write(" \n")
+ brainfile.write(" LOAD AIML {}\n".format(str(dirnumber)))
+ brainfile.write(" \n")
+ brainfile.write(" {}\n".format(os.path.join(braindir, "*.aiml")))
+ brainfile.write(" \n")
+ brainfile.write(" \n")
+ brainfile.write("")
+ brainfile.close()
self.aiml_kernel.learn(tempbrain)
- self.aiml_kernel.respond("LOAD AIML B")
+ # self.aiml_kernel.respond("LOAD AIML B")
+ for number in self.load_commands.keys():
+ if number != 0:
+ self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber))
+ os.remove(tempbrain)
def on_message(self, bot, trigger, message):
nick = Identifier(trigger.nick)