This commit is contained in:
deathbybandaid 2019-06-05 15:51:03 -04:00
parent 6920c7db1b
commit 00ef7f9607
5 changed files with 33 additions and 28 deletions

View File

@ -26,7 +26,7 @@ class SpiceBot_AI():
self.setup_ai()
self.braindirs = []
self.dict = {
"patterncount": 0,
"patterncounts": 0,
"filecounts": 0,
"sessioncache": {},
"files": {}
@ -102,7 +102,7 @@ class SpiceBot_AI():
data = open(aimlfile).read()
count = data.count('pattern')
count = count / 2
self.dict["patterncount"] += count
self.dict["patterncounts"] += count
tempbrain = tempfile.mkstemp()[1]
with open(tempbrain, 'w') as fileo:

View File

@ -80,7 +80,8 @@ def setup_startupmonologue(bot):
events.startup_add([
events.BOT_STARTUPMONOLOGUE_CONNECTED,
events.BOT_STARTUPMONOLOGUE_CHANNELS,
events.BOT_STARTUPMONOLOGUE_COMMANDS
events.BOT_STARTUPMONOLOGUE_COMMANDS,
events.BOT_STARTUPMONOLOGUE_AI,
])
@ -100,6 +101,7 @@ def setup_ai(bot):
logs.log('SpiceBot_AI', "Setting Up Configuration")
bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False)
bot.config.aibrain = os.path.join(bot.config.homedir, bot.config.core.basename + '.aibrain.brn')
events.startup_add([events.BOT_AI])
def setup_osd(bot):

View File

@ -1,25 +0,0 @@
# coding=utf8
from __future__ import unicode_literals, absolute_import, division, print_function
"""
This is the SpiceBot AI system.
"""
import sopel
import os
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.events.BOT_READY)
@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)
else:
SpiceBot.logs.log('SpiceBot_AI', "Warning: Couldn't load any %s files" % ('aiml'))

View File

@ -0,0 +1,17 @@
# coding=utf8
from __future__ import unicode_literals, absolute_import, division, print_function
"""
This is the SpiceBot AI system.
"""
import sopel
import sopel_modules.SpiceBot as SpiceBot
@sopel.module.event(SpiceBot.events.BOT_READY)
@sopel.module.rule('.*')
def bot_events_complete_ai(bot, trigger):
SpiceBot.logs.log('SpiceBot_Commands', "Found " + str(SpiceBot.botai.dict['patterncounts']) + " AI pattern Matches.", True)
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_AI, "SpiceBot_AI")

View File

@ -43,6 +43,17 @@ def bot_startup_monologue_commands(bot, trigger):
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDS, "SpiceBot_StartupMonologue")
@sopel.module.event(SpiceBot.events.BOT_AI)
@sopel.module.rule('.*')
def bot_startup_monologue_ai(bot, trigger):
availablecomsnum = SpiceBot.botai.dict['patterncounts']
availablecomsfiles = SpiceBot.botai.dict['filecounts']
displayval = "There are " + str(availablecomsnum) + " AI matches available in " + str(availablecomsfiles) + " files."
SpiceBot.startupmonologue.dict["ai"] = displayval
SpiceBot.logs.log('SpiceBot_StartupMonologue', displayval)
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_AI, "SpiceBot_StartupMonologue")
@sopel.module.event(SpiceBot.events.BOT_LOADED)
@sopel.module.rule('.*')
def bot_startup_monologue_display(bot, trigger):