From 1300fd95d9b8eff51b15ac413e82001bc23021c7 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Thu, 22 Aug 2024 02:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=8D=E4=BF=AE=E5=A4=8D=E6=88=91?= =?UTF-8?q?=E4=B8=8D=E5=B0=8F=E5=BF=83=E7=BB=99aiohttp=E9=98=BB=E5=A1=9E?= =?UTF-8?q?=E4=BA=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/nonebot_plugins/liteyuki_status/status.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/nonebot_plugins/liteyuki_status/status.py b/src/nonebot_plugins/liteyuki_status/status.py index bcf0b89..2d73f34 100644 --- a/src/nonebot_plugins/liteyuki_status/status.py +++ b/src/nonebot_plugins/liteyuki_status/status.py @@ -80,22 +80,25 @@ async def update_yanlun(): global yanlun_texts, yanlun_seqs + nonebot.logger.info("正在获取言·论信息") try: async with aiohttp.ClientSession() as client: resp = await client.get(yanlun_path) - yanlun_texts = (await resp.text()).strip("\n").split("\n") - except (ConnectionError, aiohttp.ClientError, aiohttp.WebSocketError) as E: - nonebot.logger.warning(f"读取言·论信息发生 客户端或通道 错误:\n{E}") + yanlun_texts = (await resp.text()).strip("\n").split("\n") + except (ConnectionError, aiohttp.ClientError, aiohttp.WebSocketError) as err: + nonebot.logger.warning("读取言·论信息发生 客户端或通道 错误:\n{}".format(err)) yanlun_texts = ["以梦想为驱使 创造属于自己的未来"] # noinspection PyBroadException - except BaseException as E: - nonebot.logger.warning(f"读取言·论信息发生 未知 错误:\n{E}") + except BaseException as err: + nonebot.logger.warning("读取言·论信息发生 未知 错误:\n{}".format(err)) yanlun_texts = ["灵光焕发 深艺献心"] yanlun_seqs = yanlun_texts.copy() random.shuffle(yanlun_seqs) - return len(yanlun_texts) + nonebot.logger.success("成功取得 言·论 {} 条".format(res := len(yanlun_texts))) + + return res @nonebot.get_driver().on_startup @@ -121,9 +124,7 @@ async def _(): "Happy Birthday, ElapsingDreams~!", ] else: - - nonebot.logger.info("正在获取言·论信息") - nonebot.logger.success("成功取得 言·论 {} 条".format(await update_yanlun())) + await update_yanlun() def random_yanlun_text() -> str: