mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
🐛 修复群聊学习
复读阈值不符合预期的问题
This commit is contained in:
parent
8f8f21993a
commit
aa6262fad1
@ -9,42 +9,42 @@ from .models import *
|
|||||||
|
|
||||||
DATABASE = {
|
DATABASE = {
|
||||||
"connections": {
|
"connections": {
|
||||||
"genshin": {
|
"paimon_genshin": {
|
||||||
"engine": "tortoise.backends.sqlite",
|
"engine": "tortoise.backends.sqlite",
|
||||||
"credentials": {"file_path": GENSHIN_DB_PATH},
|
"credentials": {"file_path": GENSHIN_DB_PATH},
|
||||||
},
|
},
|
||||||
"subscription": {
|
"paimon_subscription": {
|
||||||
"engine": "tortoise.backends.sqlite",
|
"engine": "tortoise.backends.sqlite",
|
||||||
"credentials": {"file_path": SUB_DB_PATH},
|
"credentials": {"file_path": SUB_DB_PATH},
|
||||||
},
|
},
|
||||||
'genshin_voice': {
|
'paimon_genshin_voice': {
|
||||||
"engine": "tortoise.backends.sqlite",
|
"engine": "tortoise.backends.sqlite",
|
||||||
"credentials": {"file_path": GENSHIN_VOICE_DB_PATH},
|
"credentials": {"file_path": GENSHIN_VOICE_DB_PATH},
|
||||||
},
|
},
|
||||||
'manager': {
|
'paimon_manager': {
|
||||||
"engine": "tortoise.backends.sqlite",
|
"engine": "tortoise.backends.sqlite",
|
||||||
"credentials": {"file_path": MANAGER_DB_PATH},
|
"credentials": {"file_path": MANAGER_DB_PATH},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"apps": {
|
"apps": {
|
||||||
"genshin": {
|
"paimon_genshin": {
|
||||||
"models": ['LittlePaimon.database.models.player_info',
|
"models": ['LittlePaimon.database.models.player_info',
|
||||||
'LittlePaimon.database.models.abyss_info',
|
'LittlePaimon.database.models.abyss_info',
|
||||||
'LittlePaimon.database.models.character',
|
'LittlePaimon.database.models.character',
|
||||||
'LittlePaimon.database.models.cookie'],
|
'LittlePaimon.database.models.cookie'],
|
||||||
"default_connection": "genshin",
|
"default_connection": "paimon_genshin",
|
||||||
},
|
},
|
||||||
"subscription": {
|
"paimon_subscription": {
|
||||||
"models": ['LittlePaimon.database.models.subscription'],
|
"models": ['LittlePaimon.database.models.subscription'],
|
||||||
"default_connection": "subscription",
|
"default_connection": "paimon_subscription",
|
||||||
},
|
},
|
||||||
"genshin_voice": {
|
"paimon_genshin_voice": {
|
||||||
"models": ['LittlePaimon.database.models.genshin_voice'],
|
"models": ['LittlePaimon.database.models.genshin_voice'],
|
||||||
"default_connection": "genshin_voice",
|
"default_connection": "paimon_genshin_voice",
|
||||||
},
|
},
|
||||||
"manager": {
|
"paimon_manager": {
|
||||||
"models": ['LittlePaimon.database.models.manager'],
|
"models": ['LittlePaimon.database.models.manager'],
|
||||||
"default_connection": "manager",
|
"default_connection": "paimon_manager",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,8 @@ ENABLE_WORDS = [f'{NICKNAME}会尝试学你们说怪话!', f'好的呢,让{N
|
|||||||
DISABLE_WORDS = [f'好好好,{NICKNAME}不学说话就是了!', f'果面呐噻,{NICKNAME}以后不学了...']
|
DISABLE_WORDS = [f'好好好,{NICKNAME}不学说话就是了!', f'果面呐噻,{NICKNAME}以后不学了...']
|
||||||
SORRY_WORDS = [f'{NICKNAME}知道错了...达咩!', f'{NICKNAME}不会再这么说了...', f'果面呐噻,{NICKNAME}说错话了...']
|
SORRY_WORDS = [f'{NICKNAME}知道错了...达咩!', f'{NICKNAME}不会再这么说了...', f'果面呐噻,{NICKNAME}说错话了...']
|
||||||
DOUBT_WORDS = [f'{NICKNAME}有说什么奇怪的话吗?']
|
DOUBT_WORDS = [f'{NICKNAME}有说什么奇怪的话吗?']
|
||||||
ALL_WORDS = NO_PERMISSION_WORDS + SORRY_WORDS + DOUBT_WORDS + ENABLE_WORDS + DISABLE_WORDS
|
BREAK_REPEAT_WORDS = ['打断复读', '打断!']
|
||||||
|
ALL_WORDS = NO_PERMISSION_WORDS + SORRY_WORDS + DOUBT_WORDS + ENABLE_WORDS + DISABLE_WORDS + BREAK_REPEAT_WORDS
|
||||||
|
|
||||||
|
|
||||||
class Result(IntEnum):
|
class Result(IntEnum):
|
||||||
@ -160,14 +161,14 @@ class LearningChat:
|
|||||||
return None
|
return None
|
||||||
elif result == Result.Repeat and (messages := await ChatMessage.filter(group_id=self.data.group_id,
|
elif result == Result.Repeat and (messages := await ChatMessage.filter(group_id=self.data.group_id,
|
||||||
time__gte=self.data.time - 3600).limit(
|
time__gte=self.data.time - 3600).limit(
|
||||||
self.config.repeat_threshold + 2)):
|
self.config.repeat_threshold)):
|
||||||
# 如果达到阈值,进行复读
|
# 如果达到阈值,进行复读
|
||||||
if len(messages) >= self.config.repeat_threshold and all(
|
if len(messages) >= self.config.repeat_threshold and all(
|
||||||
message.message == self.data.message and message.user_id != self.bot_id for message in
|
message.message == self.data.message and message.user_id != self.bot_id for message in
|
||||||
messages):
|
messages):
|
||||||
if random.random() < self.config.break_probability:
|
if random.random() < self.config.break_probability:
|
||||||
logger.debug('群聊学习', f'➤➤是否回复:达到复读阈值,打断复读!')
|
logger.debug('群聊学习', f'➤➤是否回复:达到复读阈值,打断复读!')
|
||||||
return [random.choice(['打断复读', '打断!'])]
|
return [random.choice(BREAK_REPEAT_WORDS)]
|
||||||
else:
|
else:
|
||||||
logger.debug('群聊学习', f'➤➤是否回复:达到复读阈值,复读<m>{messages[0].message}</m>')
|
logger.debug('群聊学习', f'➤➤是否回复:达到复读阈值,复读<m>{messages[0].message}</m>')
|
||||||
return [self.data.message]
|
return [self.data.message]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user