From b40535e45f087d71b5bba22fe14d786ac50580e8 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Sun, 2 Oct 2022 15:20:49 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=E5=88=A0=E9=99=A4`=E7=BE=A4?= =?UTF-8?q?=E8=81=8A=E5=AD=A6=E4=B9=A0`=E4=B8=AD=E5=92=8C=E8=AF=AD?= =?UTF-8?q?=E9=9F=B3=E5=90=88=E6=88=90=E6=9C=89=E5=85=B3=E7=9A=84=E5=86=85?= =?UTF-8?q?=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/Learning_Chat/__init__.py | 1 + LittlePaimon/plugins/Learning_Chat/config.py | 1 - LittlePaimon/plugins/Learning_Chat/models.py | 5 +- .../plugins/Paimon_Info/abyss_statistics.py | 47 ++++++++++--------- LittlePaimon/utils/logger.py | 4 ++ 5 files changed, 31 insertions(+), 27 deletions(-) diff --git a/LittlePaimon/plugins/Learning_Chat/__init__.py b/LittlePaimon/plugins/Learning_Chat/__init__.py index 10a12fd..3ff2e56 100644 --- a/LittlePaimon/plugins/Learning_Chat/__init__.py +++ b/LittlePaimon/plugins/Learning_Chat/__init__.py @@ -166,6 +166,7 @@ async def _(event: MessageEvent): msg = f'{NICKNAME}明明没有在学你们说话!' else: msg = random.choice([f'你管得着{NICKNAME}吗!', f'你可没有权限要求{NICKNAME}!']) + config_manager.save() await set_enable.finish(msg) diff --git a/LittlePaimon/plugins/Learning_Chat/config.py b/LittlePaimon/plugins/Learning_Chat/config.py index a127ebb..855a08f 100644 --- a/LittlePaimon/plugins/Learning_Chat/config.py +++ b/LittlePaimon/plugins/Learning_Chat/config.py @@ -18,7 +18,6 @@ class ChatConfig(BaseModel): repeat_threshold: int = Field(3, alias='复读阈值') speak_threshold: int = Field(5, alias='主动发言阈值') split_probability: float = Field(0.5, alias='按逗号分割回复概率') - voice_probability: float = Field(0.1, alias='以语音回复概率') speak_continuously_probability: float = Field(0.5, alias='连续主动发言概率') speak_poke_probability: float = Field(0.5, alias='主动发言附带戳一戳概率') speak_continuously_max_len: int = Field(3, alias='最大连续说话句数') diff --git a/LittlePaimon/plugins/Learning_Chat/models.py b/LittlePaimon/plugins/Learning_Chat/models.py index ec93ab5..dec9fb4 100644 --- a/LittlePaimon/plugins/Learning_Chat/models.py +++ b/LittlePaimon/plugins/Learning_Chat/models.py @@ -166,10 +166,7 @@ class LearningChat: 'reply': item, 'reply_keywords': answer_keywords, }) - if '[CQ:' not in item and len(item) > 1 and random.random() < config.voice_probability: - yield MessageSegment.record(f'http://233366.proxy.nscc-gz.cn:8888/?text={item}&speaker=派蒙') - else: - yield item + yield item with LearningChat._reply_lock: LearningChat.reply_cache[self.message.group_id][self.message.bot_id] = \ diff --git a/LittlePaimon/plugins/Paimon_Info/abyss_statistics.py b/LittlePaimon/plugins/Paimon_Info/abyss_statistics.py index 56457ab..1751724 100644 --- a/LittlePaimon/plugins/Paimon_Info/abyss_statistics.py +++ b/LittlePaimon/plugins/Paimon_Info/abyss_statistics.py @@ -136,7 +136,7 @@ async def draw_statistics_img(data: Dict[str, Any]): } avatar = await get_group_avatar(data['群号']) await img.paste(avatar, (38, 47)) - await img.text(data['群名称'], 162, 63, fm.get('hywh', 48), '#040404') + await img.text(data['群名称'], 162, 58, fm.get('hywh', 48), '#040404') await img.text(data['群号'], 165, 116, fm.get('hywh', 36), '#040404') await img.text(f'CREATED BY LITTLEPAIMON AT {datetime.datetime.now().strftime("%m-%d %H:%M")}', 1033, 195, fm.get('bahnschrift_regular.ttf', 30), '#8c4c2e', 'right') @@ -202,30 +202,33 @@ async def draw_statistics_img(data: Dict[str, Any]): tag = await load_image(RESOURCE_BASE_PATH / 'general' / 'tag.png') # 角色出场率 for i in range(4): - icon, rarity, count = data['11层上半'][i][0].split('-')[0], data['11层上半'][i][0].split('-')[1], data['11层上半'][i][1] - await img.paste(box[f'{rarity}bg'], (182 + i * 101, 867)) - await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (182 + i * 101, 867)) - await img.paste(tag, (236 + i * 101, 942)) - await img.text(str(count), (236 + i * 101, 277 + i * 101), 943, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') + try: + icon, rarity, count = data['11层上半'][i][0].split('-')[0], data['11层上半'][i][0].split('-')[1], data['11层上半'][i][1] + await img.paste(box[f'{rarity}bg'], (182 + i * 101, 867)) + await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (182 + i * 101, 867)) + await img.paste(tag, (236 + i * 101, 942)) + await img.text(str(count), (236 + i * 101, 277 + i * 101), 943, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') - icon, rarity, count = data['11层下半'][i][0].split('-')[0], data['11层下半'][i][0].split('-')[1], data['11层下半'][i][1] - await img.paste(box[f'{rarity}bg'], (642 + i * 101, 867)) - await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (642 + i * 101, 867)) - await img.paste(tag, (696 + i * 101, 942)) - await img.text(str(count), (696 + i * 101, 737 + i * 101), 943, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') + icon, rarity, count = data['11层下半'][i][0].split('-')[0], data['11层下半'][i][0].split('-')[1], data['11层下半'][i][1] + await img.paste(box[f'{rarity}bg'], (642 + i * 101, 867)) + await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (642 + i * 101, 867)) + await img.paste(tag, (696 + i * 101, 942)) + await img.text(str(count), (696 + i * 101, 737 + i * 101), 943, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') - icon, rarity, count = data['12层上半'][i][0].split('-')[0], data['12层上半'][i][0].split('-')[1], data['12层上半'][i][1] - await img.paste(box[f'{rarity}bg'], (182 + i * 101, 983)) - await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (182 + i * 101, 983)) - await img.paste(tag, (236 + i * 101, 1058)) - await img.text(str(count), (236 + i * 101, 278 + i * 101), 1059, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') + icon, rarity, count = data['12层上半'][i][0].split('-')[0], data['12层上半'][i][0].split('-')[1], data['12层上半'][i][1] + await img.paste(box[f'{rarity}bg'], (182 + i * 101, 983)) + await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (182 + i * 101, 983)) + await img.paste(tag, (236 + i * 101, 1058)) + await img.text(str(count), (236 + i * 101, 278 + i * 101), 1059, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') - icon, rarity, count = data['12层下半'][i][0].split('-')[0], data['12层下半'][i][0].split('-')[1], data['12层下半'][i][1] - await img.paste(box[f'{rarity}bg'], (642 + i * 101, 983)) - await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (642 + i * 101, 983)) - await img.paste(tag, (696 + i * 101, 1058)) - await img.text(str(count), (696 + i * 101, 737 + i * 101), 1059, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') - i += 1 + icon, rarity, count = data['12层下半'][i][0].split('-')[0], data['12层下半'][i][0].split('-')[1], data['12层下半'][i][1] + await img.paste(box[f'{rarity}bg'], (642 + i * 101, 983)) + await img.paste(await load_image(RESOURCE_BASE_PATH / 'avatar' / f'{icon}.png', size=(95, 95)), (642 + i * 101, 983)) + await img.paste(tag, (696 + i * 101, 1058)) + await img.text(str(count), (696 + i * 101, 737 + i * 101), 1059, fm.get('bahnschrift_regular.ttf', 19), 'white', 'center') + i += 1 + except IndexError: + pass return MessageBuild.Image(img, mode='RGB', quality=80) diff --git a/LittlePaimon/utils/logger.py b/LittlePaimon/utils/logger.py index 61d91fe..870e6fb 100644 --- a/LittlePaimon/utils/logger.py +++ b/LittlePaimon/utils/logger.py @@ -22,3 +22,7 @@ class logger: @staticmethod def warning(command: str, info: str = '', action: str = ''): nb_logger.opt(colors=True).warning(f'[{command}]{info}{action}') + + @staticmethod + def debug(command: str, info: str): + nb_logger.opt(colors=True).debug(f'[{command}]{info}')