mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-12 06:29:54 -05:00
test
This commit is contained in:
parent
6920c7db1b
commit
00ef7f9607
@ -26,7 +26,7 @@ class SpiceBot_AI():
|
|||||||
self.setup_ai()
|
self.setup_ai()
|
||||||
self.braindirs = []
|
self.braindirs = []
|
||||||
self.dict = {
|
self.dict = {
|
||||||
"patterncount": 0,
|
"patterncounts": 0,
|
||||||
"filecounts": 0,
|
"filecounts": 0,
|
||||||
"sessioncache": {},
|
"sessioncache": {},
|
||||||
"files": {}
|
"files": {}
|
||||||
@ -102,7 +102,7 @@ class SpiceBot_AI():
|
|||||||
data = open(aimlfile).read()
|
data = open(aimlfile).read()
|
||||||
count = data.count('pattern')
|
count = data.count('pattern')
|
||||||
count = count / 2
|
count = count / 2
|
||||||
self.dict["patterncount"] += count
|
self.dict["patterncounts"] += count
|
||||||
|
|
||||||
tempbrain = tempfile.mkstemp()[1]
|
tempbrain = tempfile.mkstemp()[1]
|
||||||
with open(tempbrain, 'w') as fileo:
|
with open(tempbrain, 'w') as fileo:
|
||||||
|
|||||||
@ -80,7 +80,8 @@ def setup_startupmonologue(bot):
|
|||||||
events.startup_add([
|
events.startup_add([
|
||||||
events.BOT_STARTUPMONOLOGUE_CONNECTED,
|
events.BOT_STARTUPMONOLOGUE_CONNECTED,
|
||||||
events.BOT_STARTUPMONOLOGUE_CHANNELS,
|
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")
|
logs.log('SpiceBot_AI', "Setting Up Configuration")
|
||||||
bot.config.define_section("SpiceBot_AI", SpiceBot_AI_MainSection, validate=False)
|
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')
|
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):
|
def setup_osd(bot):
|
||||||
|
|||||||
@ -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'))
|
|
||||||
17
sopel_modules/SpiceBot_Core_Processing/AI.py
Normal file
17
sopel_modules/SpiceBot_Core_Processing/AI.py
Normal 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")
|
||||||
@ -43,6 +43,17 @@ def bot_startup_monologue_commands(bot, trigger):
|
|||||||
SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE_COMMANDS, "SpiceBot_StartupMonologue")
|
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.event(SpiceBot.events.BOT_LOADED)
|
||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_startup_monologue_display(bot, trigger):
|
def bot_startup_monologue_display(bot, trigger):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user