From 996c8c4a00226ea0f3357e3a24e0a9985f4a1d79 Mon Sep 17 00:00:00 2001 From: EillesWan Date: Tue, 13 Aug 2024 15:02:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=BE=E5=AE=8C=E7=BE=8E=E8=A8=80?= =?UTF-8?q?=E8=AE=BA=E5=9C=A8=E7=BA=BF=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 7 ++++--- src/nonebot_plugins/liteyuki_status/status.py | 21 ++++++++++++++++--- .../trimo_plugin_msctconverter/msctexec.py | 5 ++++- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 6fc17df..c0b83fb 100644 --- a/.gitignore +++ b/.gitignore @@ -19,9 +19,10 @@ config.example.yml compile.bat src/resources/templates/latest-debug.html -src/plugins/trimo_plugin_msctconverter/config -src/plugins/trimo_plugin_msctconverter/temp -src/plugins/trimo_plugin_msctconverter/MusicPreview/assets/wav +src/nonebot_plugins/trimo_plugin_msctconverter/config +src/nonebot_plugins/trimo_plugin_msctconverter/temp +src/nonebot_plugins/trimo_plugin_msctconverter/MusicPreview/assets/wav +src/nonebot_plugins/dislink_plugin_ccnd # vuepress .github diff --git a/src/nonebot_plugins/liteyuki_status/status.py b/src/nonebot_plugins/liteyuki_status/status.py index 5e85371..a779914 100644 --- a/src/nonebot_plugins/liteyuki_status/status.py +++ b/src/nonebot_plugins/liteyuki_status/status.py @@ -78,7 +78,7 @@ async def every_day_update(): def update_yanlun(): - global yanlun_texts + global yanlun_texts, yanlun_seqs solar_datetime = zhDateTime.DateTime.now() lunar_datetime = solar_datetime.to_lunar() @@ -109,14 +109,26 @@ def update_yanlun(): nonebot.logger.warning(f"读取言·论信息发生 未知 错误:\n{E}") yanlun_texts = ["灵光焕发 深艺献心"] + yanlun_seqs = yanlun_texts.copy() + random.shuffle(yanlun_seqs) + return len(yanlun_texts) +yanlun_seqs = [] update_yanlun() +def random_yanlun_text() -> str: + global yanlun_texts, yanlun_seqs + if not yanlun_seqs: + yanlun_seqs = yanlun_texts.copy() + random.shuffle(yanlun_seqs) + return yanlun_seqs.pop() + + def random_yanlun() -> tuple: - seq = random.choice(yanlun_texts).replace(" ", "\t").split("\t——", 1) + seq = random_yanlun_text().replace(" ", "\t").split("\t——", 1) return seq[0], "" if len(seq) == 1 else seq[1] @@ -213,6 +225,9 @@ async def _( ) ) yanlun_texts = ["灵光焕发 深艺献心"] + + yanlun_seqs = yanlun_texts.copy() + random.shuffle(yanlun_seqs) if result.options["count"].value: authors = [ ( @@ -269,7 +284,7 @@ async def _( ( await yanlun.finish( UniMessage.text( - "\n".join([random.choice(yanlun_texts) for i in range(iill)]) + "\n".join([random_yanlun_text() for i in range(iill)]) if iill <= 100 else ulang.get("yanlun.length.toolong") ) diff --git a/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py b/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py index 4ac91a9..bf6eccc 100644 --- a/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py +++ b/src/nonebot_plugins/trimo_plugin_msctconverter/msctexec.py @@ -78,6 +78,8 @@ from nonebot_plugin_alconna import ( from nonebot_plugin_apscheduler import scheduler +from ..liteyuki_status.status import random_yanlun_text + (config_dir := Path(__file__).parent / "config").mkdir(exist_ok=True) (database_dir := Path(__file__).parent / "db").mkdir(exist_ok=True) temporary_dir = Path(__file__).parent / "temp" @@ -1032,7 +1034,8 @@ async def _( ) for fn, res in all_files.items() ] - ), + ) + + "\n\n### 言·论 \n\n **{}**".format(random_yanlun_text()), bot, event=event, )