From 8023fb289a03b49d50150ee451adafb59107c9a3 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Tue, 17 Jan 2023 22:00:04 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D`=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E5=AD=A6=E4=B9=A0`=E4=B8=BB=E5=8A=A8=E5=8F=91?= =?UTF-8?q?=E8=A8=80=E6=9C=89=E6=97=B6=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/plugins/Learning_Chat/handler.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/LittlePaimon/plugins/Learning_Chat/handler.py b/LittlePaimon/plugins/Learning_Chat/handler.py index b8c57a2..676f59b 100644 --- a/LittlePaimon/plugins/Learning_Chat/handler.py +++ b/LittlePaimon/plugins/Learning_Chat/handler.py @@ -429,19 +429,20 @@ class LearningChat: if any(word in message for word in ban_words): continue speak_list.append(message) - follow_answers = answer + follow_answer = answer while random.random() < config.speak_continuously_probability and len( speak_list) < config.speak_continuously_max_len: if (follow_context := await ChatContext.filter( - keywords=follow_answers.keywords).first()) and ( + keywords=follow_answer.keywords).first()) and ( follow_answers := await ChatAnswer.filter( group_id=group_id, context=follow_context, count__gte=config.answer_threshold)): - answer = random.choices(follow_answers, - weights=[a.count + 1 if a.time >= today_time else a.count - for a in follow_answers])[0] - message = random.choice(answer.messages) + follow_answer = random.choices(follow_answers, + weights=[ + a.count + 1 if a.time >= today_time else a.count + for a in follow_answers])[0] + message = random.choice(follow_answer.messages) if len(message) < 2: continue if message.startswith('[') and message.endswith(']'):