mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test
This commit is contained in:
parent
659395b3eb
commit
6b305fdea0
@ -23,6 +23,7 @@ class SpiceBot_AI():
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.load_commands = [0]
|
self.load_commands = [0]
|
||||||
|
self.braindirs = []
|
||||||
self.dict = {
|
self.dict = {
|
||||||
"counts": 0,
|
"counts": 0,
|
||||||
"failcounts": 0,
|
"failcounts": 0,
|
||||||
@ -57,27 +58,27 @@ 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
|
if braindir not in self.braindirs:
|
||||||
# for parsefile in os.listdir(braindir):
|
self.braindirs.append(braindir)
|
||||||
# self.check_file_parse(parsefile)
|
dirnumber = max(self.load_commands) + 1
|
||||||
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 {}</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(str(dirnumber), os.path.join(braindir, "*"))
|
"</aiml>".format(str(dirnumber), os.path.join(braindir, "*"))
|
||||||
)
|
)
|
||||||
self.aiml_kernel.learn(tempbrain)
|
self.aiml_kernel.learn(tempbrain)
|
||||||
for number in self.load_commands:
|
for number in self.load_commands:
|
||||||
if number != 0:
|
if number != 0:
|
||||||
self.aiml_kernel.respond("LOAD AIML {}").format(str(dirnumber))
|
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):
|
||||||
nick = Identifier(trigger.nick)
|
nick = Identifier(trigger.nick)
|
||||||
|
|||||||
@ -5,6 +5,8 @@ This is the SpiceBot AI system.
|
|||||||
"""
|
"""
|
||||||
import sopel
|
import sopel
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
import sopel_modules.SpiceBot as SpiceBot
|
import sopel_modules.SpiceBot as SpiceBot
|
||||||
|
|
||||||
|
|
||||||
@ -12,6 +14,10 @@ import sopel_modules.SpiceBot as SpiceBot
|
|||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_events_complete_ai(bot, trigger):
|
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"]:
|
if SpiceBot.botai.dict["counts"]:
|
||||||
SpiceBot.logs.log('SpiceBot_AI', 'Registered %d %s files,' % (SpiceBot.botai.dict["counts"], 'aiml'))
|
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)
|
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