mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2025-04-12 23:29:37 +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):
|
if any(word in message for word in ban_words):
|
||||||
continue
|
continue
|
||||||
speak_list.append(message)
|
speak_list.append(message)
|
||||||
follow_answers = answer
|
follow_answer = answer
|
||||||
while random.random() < config.speak_continuously_probability and len(
|
while random.random() < config.speak_continuously_probability and len(
|
||||||
speak_list) < config.speak_continuously_max_len:
|
speak_list) < config.speak_continuously_max_len:
|
||||||
if (follow_context := await ChatContext.filter(
|
if (follow_context := await ChatContext.filter(
|
||||||
keywords=follow_answers.keywords).first()) and (
|
keywords=follow_answer.keywords).first()) and (
|
||||||
follow_answers := await ChatAnswer.filter(
|
follow_answers := await ChatAnswer.filter(
|
||||||
group_id=group_id,
|
group_id=group_id,
|
||||||
context=follow_context,
|
context=follow_context,
|
||||||
count__gte=config.answer_threshold)):
|
count__gte=config.answer_threshold)):
|
||||||
answer = random.choices(follow_answers,
|
follow_answer = random.choices(follow_answers,
|
||||||
weights=[a.count + 1 if a.time >= today_time else a.count
|
weights=[
|
||||||
for a in follow_answers])[0]
|
a.count + 1 if a.time >= today_time else a.count
|
||||||
message = random.choice(answer.messages)
|
for a in follow_answers])[0]
|
||||||
|
message = random.choice(follow_answer.messages)
|
||||||
if len(message) < 2:
|
if len(message) < 2:
|
||||||
continue
|
continue
|
||||||
if message.startswith('[') and message.endswith(']'):
|
if message.startswith('[') and message.endswith(']'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user