mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
🐛 修复群聊学习
主动发言有时报错
This commit is contained in:
parent
49eb593483
commit
8023fb289a
@ -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(']'):
|
||||
|
Loading…
Reference in New Issue
Block a user