mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-11 14:10:58 -05:00
better load logic
This commit is contained in:
parent
86fb1b984f
commit
3eaa2ad207
@ -22,6 +22,7 @@ class SpiceBot_AI_MainSection(StaticSection):
|
|||||||
class SpiceBot_AI():
|
class SpiceBot_AI():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.load_commands = [0]
|
||||||
self.dict = {
|
self.dict = {
|
||||||
"counts": 0,
|
"counts": 0,
|
||||||
"failcounts": 0,
|
"failcounts": 0,
|
||||||
@ -56,6 +57,7 @@ class SpiceBot_AI():
|
|||||||
|
|
||||||
def learn(self, braindirs):
|
def learn(self, braindirs):
|
||||||
for braindir in braindirs:
|
for braindir in braindirs:
|
||||||
|
dirnumber = max(self.load_commands) + 1
|
||||||
for parsefile in os.listdir(braindir):
|
for parsefile in os.listdir(braindir):
|
||||||
self.check_file_parse(parsefile)
|
self.check_file_parse(parsefile)
|
||||||
tempbrain = tempfile.mkstemp()[1]
|
tempbrain = tempfile.mkstemp()[1]
|
||||||
@ -64,15 +66,17 @@ class SpiceBot_AI():
|
|||||||
"<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 {}</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>".format(str(dirnumber), os.path.join(braindir, "*"))
|
||||||
)
|
)
|
||||||
self.aiml_kernel.learn(tempbrain)
|
self.aiml_kernel.learn(tempbrain)
|
||||||
self.aiml_kernel.respond("LOAD AIML B")
|
for number in self.load_commands:
|
||||||
|
if number != 0:
|
||||||
|
self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber))
|
||||||
os.remove(tempbrain)
|
os.remove(tempbrain)
|
||||||
|
|
||||||
def on_message(self, bot, trigger, message):
|
def on_message(self, bot, trigger, message):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user