This commit is contained in:
deathbybandaid 2019-05-31 19:55:23 -04:00
parent a9bbfa936f
commit 32c75dabc8
3 changed files with 29 additions and 7 deletions

View File

@ -23,13 +23,13 @@ class SpiceBot_AI():
for plugin_dir in set(sopel_modules.__path__):
configsdir = os.path.join(plugin_dir, "SpiceBot_Configs")
aimldir = os.path.join(configsdir, "aiml")
for aimlfile in os.listdir(aimldir):
aiml_filename = os.path.join(aimldir, aimlfile)
try:
self.aiml_kernel.learn(aiml_filename)
self.dict['counts'] += 1
except Exception as e:
logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aiml_filename))
aimlstarter = os.path.join(aimldir, "std-startup.xml")
try:
self.aiml_kernel.learn(aimlstarter)
self.aiml_kernel.respond("LOAD AIML B")
self.dict['counts'] += 1
except Exception as e:
logs.log('SpiceBot_AI', "Error loading %s: %s (%s)" % ('aiml', e, aimlstarter))
logs.log('SpiceBot_AI', "Found " + str(self.dict['counts']) + " " + 'aiml' + " commands.", True)
def on_message(self, message):

View File

@ -0,0 +1,22 @@
<aiml version="1.0.1" encoding="UTF-8">
<!-- std-startup.xml -->
<!-- Category is an atomic AIML unit -->
<category>
<!-- Pattern to match in user input -->
<!-- If user enters "LOAD AIML B" -->
<pattern>LOAD AIML B</pattern>
<!-- Template is the response to the pattern -->
<!-- This learn an aiml file -->
<template>
<learn>aiml/*</learn>
<!-- All aiml files are relative to the run dir and must be subdirs,
E.g. ./aiml/alice/one.aiml, ./aiml/custom/mine.aiml -->
</template>
</category>
</aiml>