mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 15:09:54 -05:00
hmmmm
This commit is contained in:
parent
dbb2700eac
commit
c33fbe7a5b
@ -22,7 +22,6 @@ class SpiceBot_AI_MainSection(StaticSection):
|
|||||||
class SpiceBot_AI():
|
class SpiceBot_AI():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.load_commands = {0: None}
|
|
||||||
self.braindirs = []
|
self.braindirs = []
|
||||||
self.dict = {
|
self.dict = {
|
||||||
"counts": 0,
|
"counts": 0,
|
||||||
@ -63,40 +62,21 @@ class SpiceBot_AI():
|
|||||||
for braindir in braindirs:
|
for braindir in braindirs:
|
||||||
if braindir not in self.braindirs:
|
if braindir not in self.braindirs:
|
||||||
self.braindirs.append(braindir)
|
self.braindirs.append(braindir)
|
||||||
dirnumber = max(self.load_commands.keys()) + 1
|
|
||||||
self.load_commands[dirnumber] = braindir
|
|
||||||
tempbrain = tempfile.mkstemp()[1]
|
tempbrain = tempfile.mkstemp()[1]
|
||||||
# with open(tempbrain, 'w') as fileo:
|
with open(tempbrain, 'w') as fileo:
|
||||||
# fileo.write(
|
fileo.write(
|
||||||
# "<aiml version='1.0.1' encoding='UTF-8'>"
|
"<aiml version='1.0.1' encoding='UTF-8'>"
|
||||||
# " <!-- std-startup.xml -->\n"
|
" <!-- std-startup.xml -->\n"
|
||||||
# " <category>\n"
|
" <category>\n"
|
||||||
# " <pattern>LOAD AIML B</pattern>\n"
|
" <pattern>LOAD AIML B</pattern>\n"
|
||||||
# # " <pattern>LOAD AIML {}</pattern>\n"
|
" <template>\n"
|
||||||
# " <template>\n"
|
" <learn>{}</learn>\n"
|
||||||
# " <learn>{}</learn>\n"
|
" </template>\n"
|
||||||
# " </template>\n"
|
" </category>\n"
|
||||||
# " </category>\n"
|
"</aiml>".format(os.path.join(braindir, "*.aiml"))
|
||||||
# # "</aiml>".format(str(dirnumber), os.path.join(braindir, "*"))
|
)
|
||||||
# "</aiml>".format(os.path.join(braindir, "*.aiml"))
|
|
||||||
# )
|
|
||||||
brainfile = open(tempbrain, 'a')
|
|
||||||
brainfile.write("<aiml version='1.0.1' encoding='UTF-8'>")
|
|
||||||
brainfile.write(" <!-- std-startup.xml -->\n")
|
|
||||||
brainfile.write(" <category>\n")
|
|
||||||
brainfile.write(" <pattern>LOAD AIML {}</pattern>\n".format(str(dirnumber)))
|
|
||||||
brainfile.write(" <template>\n")
|
|
||||||
brainfile.write(" <learn>{}</learn>\n".format(os.path.join(braindir, "*.aiml")))
|
|
||||||
brainfile.write(" </template>\n")
|
|
||||||
brainfile.write(" </category>\n")
|
|
||||||
brainfile.write("</aiml>")
|
|
||||||
brainfile.close()
|
|
||||||
self.aiml_kernel.learn(tempbrain)
|
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):
|
def on_message(self, bot, trigger, message):
|
||||||
nick = Identifier(trigger.nick)
|
nick = Identifier(trigger.nick)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user