mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
test
This commit is contained in:
parent
9508f3b18b
commit
54916bdae7
@ -11,12 +11,10 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
import aiml
|
import aiml
|
||||||
import xmltodict
|
import xmltodict
|
||||||
import json
|
|
||||||
|
|
||||||
from .Database import db as botdb
|
from .Database import db as botdb
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SpiceBot_AI_MainSection(StaticSection):
|
class SpiceBot_AI_MainSection(StaticSection):
|
||||||
extra = ListAttribute('extra')
|
extra = ListAttribute('extra')
|
||||||
|
|
||||||
@ -95,33 +93,30 @@ class SpiceBot_AI():
|
|||||||
|
|
||||||
for aimlfile in filepathlist:
|
for aimlfile in filepathlist:
|
||||||
filereadgood = True
|
filereadgood = True
|
||||||
|
aiml_file_lines = []
|
||||||
|
aiml_file = open(aimlfile, 'r')
|
||||||
|
lines = aiml_file.readlines()
|
||||||
|
for line in lines:
|
||||||
|
aiml_file_lines.append(str(line))
|
||||||
|
aiml_file.close()
|
||||||
|
|
||||||
try:
|
detected_lines = []
|
||||||
with open(aimlfile) as fd:
|
for line in aiml_file_lines:
|
||||||
dict_from_file = xmltodict.parse(fd.read())
|
if line.startswith("<pattern>"):
|
||||||
except Exception as e:
|
line = line.replace("<pattern>", '')
|
||||||
filereadgood = e
|
line = line.replace("</pattern>", '')
|
||||||
|
detected_lines.append(line)
|
||||||
|
|
||||||
|
if not len(detected_lines):
|
||||||
filereadgood = False
|
filereadgood = False
|
||||||
|
|
||||||
if filereadgood:
|
if filereadgood:
|
||||||
self.dict["counts"] += 1
|
self.dict["counts"] += 1
|
||||||
if aimlfile not in self.dict["files"]:
|
if aimlfile not in self.dict["files"]:
|
||||||
self.dict["files"][aimlfile] = dict_from_file
|
self.dict["files"][aimlfile] = detected_lines
|
||||||
else:
|
else:
|
||||||
self.dict["failcounts"] += 1
|
self.dict["failcounts"] += 1
|
||||||
|
|
||||||
"""def donothing():
|
|
||||||
aiml_file_lines = []
|
|
||||||
aiml_file = open(aimlfile, 'r')
|
|
||||||
lines = aiml_file.readlines()
|
|
||||||
for line in lines:
|
|
||||||
aiml_file_lines.append(line)
|
|
||||||
aiml_file.close()
|
|
||||||
|
|
||||||
detected_lines = []
|
|
||||||
for line in aiml_file_lines:
|
|
||||||
dothing = True"""
|
|
||||||
|
|
||||||
def on_message(self, bot, trigger, message):
|
def on_message(self, bot, trigger, message):
|
||||||
nick = Identifier(trigger.nick)
|
nick = Identifier(trigger.nick)
|
||||||
nick_id = botdb.get_nick_id(nick, create=True)
|
nick_id = botdb.get_nick_id(nick, create=True)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user