mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-11 22:20:58 -05:00
test
This commit is contained in:
parent
659395b3eb
commit
6b305fdea0
@ -23,6 +23,7 @@ class SpiceBot_AI():
|
||||
|
||||
def __init__(self):
|
||||
self.load_commands = [0]
|
||||
self.braindirs = []
|
||||
self.dict = {
|
||||
"counts": 0,
|
||||
"failcounts": 0,
|
||||
@ -57,27 +58,27 @@ class SpiceBot_AI():
|
||||
|
||||
def learn(self, braindirs):
|
||||
for braindir in braindirs:
|
||||
dirnumber = max(self.load_commands) + 1
|
||||
# for parsefile in os.listdir(braindir):
|
||||
# self.check_file_parse(parsefile)
|
||||
tempbrain = tempfile.mkstemp()[1]
|
||||
with open(tempbrain, 'w') as fileo:
|
||||
fileo.write(
|
||||
"<aiml version='1.0.1' encoding='UTF-8'>"
|
||||
" <!-- std-startup.xml -->\n"
|
||||
" <category>\n"
|
||||
" <pattern>LOAD AIML {}</pattern>\n"
|
||||
" <template>\n"
|
||||
" <learn>{}</learn>\n"
|
||||
" </template>\n"
|
||||
" </category>\n"
|
||||
"</aiml>".format(str(dirnumber), os.path.join(braindir, "*"))
|
||||
)
|
||||
self.aiml_kernel.learn(tempbrain)
|
||||
for number in self.load_commands:
|
||||
if number != 0:
|
||||
self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber))
|
||||
os.remove(tempbrain)
|
||||
if braindir not in self.braindirs:
|
||||
self.braindirs.append(braindir)
|
||||
dirnumber = max(self.load_commands) + 1
|
||||
tempbrain = tempfile.mkstemp()[1]
|
||||
with open(tempbrain, 'w') as fileo:
|
||||
fileo.write(
|
||||
"<aiml version='1.0.1' encoding='UTF-8'>"
|
||||
" <!-- std-startup.xml -->\n"
|
||||
" <category>\n"
|
||||
" <pattern>LOAD AIML {}</pattern>\n"
|
||||
" <template>\n"
|
||||
" <learn>{}</learn>\n"
|
||||
" </template>\n"
|
||||
" </category>\n"
|
||||
"</aiml>".format(str(dirnumber), os.path.join(braindir, "*"))
|
||||
)
|
||||
self.aiml_kernel.learn(tempbrain)
|
||||
for number in self.load_commands:
|
||||
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)
|
||||
|
||||
@ -5,6 +5,8 @@ This is the SpiceBot AI system.
|
||||
"""
|
||||
import sopel
|
||||
|
||||
import os
|
||||
|
||||
import sopel_modules.SpiceBot as SpiceBot
|
||||
|
||||
|
||||
@ -12,6 +14,10 @@ import sopel_modules.SpiceBot as SpiceBot
|
||||
@sopel.module.rule('.*')
|
||||
def bot_events_complete_ai(bot, trigger):
|
||||
|
||||
for braindir in SpiceBot.botai.braindirs:
|
||||
for parsefile in os.listdir(braindir):
|
||||
SpiceBot.botai.check_file_parse(parsefile)
|
||||
|
||||
if SpiceBot.botai.dict["counts"]:
|
||||
SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml'))
|
||||
SpiceBot.logs.log('SpiceBot_AI', '%d %s files failed to load' % (SpiceBot.botai.dict["failcounts"], 'aiml'), True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user