Skip to content

Commit

Permalink
update 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
JHue58 committed Jul 30, 2022
1 parent 7010292 commit c2b2820
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
15 changes: 12 additions & 3 deletions ChatFilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ def getnode(data, Filterconfig, filterlist, sender,Accuratedict = None):
if node == 'all':
filterlist.clear()
if Accuratedict!= None:
Accuratedict.clear()
try:
Accuratedict.clear()
except:
pass
file = open('Filter.clc', 'w', encoding='utf-8-sig')
json_dump(Filterconfig, file, indent=3, ensure_ascii=False)
file.close()
Expand Down Expand Up @@ -179,7 +182,10 @@ def getnode(data, Filterconfig, filterlist, sender,Accuratedict = None):
#print(i)
filterlist.remove(i)
if Accuratedict!= None:
Accuratedict.pop(i)
try:
Accuratedict.pop(i)
except:
pass
#print(filterlist)
file = open('Filter.clc', 'w', encoding='utf-8-sig')
json_dump(Filterconfig, file, indent=3, ensure_ascii=False)
Expand Down Expand Up @@ -561,7 +567,10 @@ def filtercontrol(data, sender):
break
if node == str(1):
filterlist = Filterconfig['filter']
Accuratedict = Filterconfig['Accuratedict']
try:
Accuratedict = Filterconfig['Accuratedict']
except:
Accuratedict = {}
replyanswer(data, sender, filterlist,Accuratedict)
getnode(data, Filterconfig, filterlist, sender,Accuratedict)
elif node == str(2):
Expand Down
1 change: 1 addition & 0 deletions ChatLearning.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def creatquestion(question, group): # 记录问题
questiondict["freq"] = 1
questiondict["time"] = questiontime
questiondict["answer"] = answerlist
questiondict['regular'] = False
tempdict[question] = questiondict
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), "\n问题已记录",
filename)
Expand Down
15 changes: 10 additions & 5 deletions ChatReply.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def getanswer(group, question): # 从词库中获取答案
answerlist=DelType(tempdict, questiondict['answer'])
else:
return -1

else:
return -1

except Exception as e:
print(e)
Expand Down Expand Up @@ -586,10 +587,14 @@ def regular_mate(cldict,question_text):
question = None
regular_flag = False

for i in cldict:
question_dict = cldict[i]
if question_dict['regular'] == True:
regular_dict[i] = copy.deepcopy(question_dict)
try:
for i in cldict:
question_dict = cldict[i]
if question_dict['regular'] == True:
regular_dict[i] = copy.deepcopy(question_dict)
except KeyError:
print('词库版本不匹配')
return question

if regular_dict == {}:
return question
Expand Down

0 comments on commit c2b2820

Please sign in to comment.