From b5a755640e6d7928bbfb1066e1581244c18112da Mon Sep 17 00:00:00 2001 From: xiaolingdang Date: Sat, 7 Jan 2023 19:04:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:bug:=E4=BF=AE=E5=A4=8D=E5=8F=91=E9=80=81?= =?UTF-8?q?=E7=8C=9C=E8=AF=AD=E9=9F=B3=E6=97=B6=E5=87=BA=E7=8E=B0=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LittlePaimon/plugins/Genshin_Voice/handler.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LittlePaimon/plugins/Genshin_Voice/handler.py b/LittlePaimon/plugins/Genshin_Voice/handler.py index 766a71f..aebf30d 100644 --- a/LittlePaimon/plugins/Genshin_Voice/handler.py +++ b/LittlePaimon/plugins/Genshin_Voice/handler.py @@ -8,6 +8,7 @@ from nonebot.rule import Rule from LittlePaimon.database import GenshinVoice, GuessVoiceRank from LittlePaimon.utils import scheduler, logger from LittlePaimon.utils.alias import get_alias_by_name +from LittlePaimon.utils.requests import aiorequests from .draw import draw_voice_list gaming = {} @@ -42,7 +43,7 @@ class GuessVoice: run_date=datetime.datetime.now() + datetime.timedelta(seconds=self.game_time), id=f'Guess_voice_{self.group_id}', misfire_grace_time=10) - return MessageSegment.record(voice.voice_url) + return await get_record(voice.voice_url) async def end(self, exception: bool = False): if not exception and self.is_gaming: @@ -118,3 +119,10 @@ async def get_character_voice(character: str, language: str = '中'): async def get_voice_list(character: str, language: str = '中'): voice_list = await GenshinVoice.filter(character=character, language=language).all() return await draw_voice_list(voice_list) if voice_list else MessageSegment.text(f'暂无{character}的{language}语音资源,让超级用户[更新原神语音资源]吧!') + + +async def get_record(url): + resp = await aiorequests.get(url, timeout=20) + resp.raise_for_status() + voice = resp.content + return MessageSegment.record(voice) From 5d0944f6e557e8da7fa79fa6c9f4ce5e06705530 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=93=83=E9=93=9B?= Date: Sat, 7 Jan 2023 19:11:24 +0800 Subject: [PATCH 2/2] Update handler.py --- LittlePaimon/plugins/Genshin_Voice/handler.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/LittlePaimon/plugins/Genshin_Voice/handler.py b/LittlePaimon/plugins/Genshin_Voice/handler.py index aebf30d..f5e099d 100644 --- a/LittlePaimon/plugins/Genshin_Voice/handler.py +++ b/LittlePaimon/plugins/Genshin_Voice/handler.py @@ -6,9 +6,8 @@ from nonebot.adapters.onebot.v11 import GroupMessageEvent, Message, MessageSegme from nonebot.rule import Rule from LittlePaimon.database import GenshinVoice, GuessVoiceRank -from LittlePaimon.utils import scheduler, logger +from LittlePaimon.utils import scheduler, logger, aiorequests from LittlePaimon.utils.alias import get_alias_by_name -from LittlePaimon.utils.requests import aiorequests from .draw import draw_voice_list gaming = {} @@ -122,7 +121,7 @@ async def get_voice_list(character: str, language: str = '中'): async def get_record(url): - resp = await aiorequests.get(url, timeout=20) + resp = await aiorequests.get(url) resp.raise_for_status() voice = resp.content return MessageSegment.record(voice)