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