From aa6262fad1820fb2100e8d0d6dbef81e5fd24300 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Tue, 15 Nov 2022 18:37:41 +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`=E5=A4=8D=E8=AF=BB=E9=98=88?= =?UTF-8?q?=E5=80=BC=E4=B8=8D=E7=AC=A6=E5=90=88=E9=A2=84=E6=9C=9F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/database/__init__.py | 24 +++++++++---------- LittlePaimon/plugins/Learning_Chat/handler.py | 7 +++--- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/LittlePaimon/database/__init__.py b/LittlePaimon/database/__init__.py index 565cf8a..6373ebb 100644 --- a/LittlePaimon/database/__init__.py +++ b/LittlePaimon/database/__init__.py @@ -9,42 +9,42 @@ from .models import * DATABASE = { "connections": { - "genshin": { + "paimon_genshin": { "engine": "tortoise.backends.sqlite", "credentials": {"file_path": GENSHIN_DB_PATH}, }, - "subscription": { + "paimon_subscription": { "engine": "tortoise.backends.sqlite", "credentials": {"file_path": SUB_DB_PATH}, }, - 'genshin_voice': { + 'paimon_genshin_voice': { "engine": "tortoise.backends.sqlite", "credentials": {"file_path": GENSHIN_VOICE_DB_PATH}, }, - 'manager': { + 'paimon_manager': { "engine": "tortoise.backends.sqlite", "credentials": {"file_path": MANAGER_DB_PATH}, } }, "apps": { - "genshin": { + "paimon_genshin": { "models": ['LittlePaimon.database.models.player_info', 'LittlePaimon.database.models.abyss_info', 'LittlePaimon.database.models.character', 'LittlePaimon.database.models.cookie'], - "default_connection": "genshin", + "default_connection": "paimon_genshin", }, - "subscription": { + "paimon_subscription": { "models": ['LittlePaimon.database.models.subscription'], - "default_connection": "subscription", + "default_connection": "paimon_subscription", }, - "genshin_voice": { + "paimon_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'], - "default_connection": "manager", + "default_connection": "paimon_manager", } }, } diff --git a/LittlePaimon/plugins/Learning_Chat/handler.py b/LittlePaimon/plugins/Learning_Chat/handler.py index e5a6f8e..bdb76b3 100644 --- a/LittlePaimon/plugins/Learning_Chat/handler.py +++ b/LittlePaimon/plugins/Learning_Chat/handler.py @@ -24,7 +24,8 @@ ENABLE_WORDS = [f'{NICKNAME}会尝试学你们说怪话!', f'好的呢,让{N DISABLE_WORDS = [f'好好好,{NICKNAME}不学说话就是了!', f'果面呐噻,{NICKNAME}以后不学了...'] SORRY_WORDS = [f'{NICKNAME}知道错了...达咩!', f'{NICKNAME}不会再这么说了...', 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): @@ -160,14 +161,14 @@ class LearningChat: return None elif result == Result.Repeat and (messages := await ChatMessage.filter(group_id=self.data.group_id, 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( message.message == self.data.message and message.user_id != self.bot_id for message in messages): if random.random() < self.config.break_probability: logger.debug('群聊学习', f'➤➤是否回复:达到复读阈值,打断复读!') - return [random.choice(['打断复读', '打断!'])] + return [random.choice(BREAK_REPEAT_WORDS)] else: logger.debug('群聊学习', f'➤➤是否回复:达到复读阈值,复读{messages[0].message}') return [self.data.message]