From 31b06fb4a3aaa7a86849a659b78129d28f82de07 Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Tue, 19 Aug 2025 12:33:01 +0800 Subject: [PATCH] =?UTF-8?q?~~=E5=93=8E=E5=91=80=EF=BC=8C=E4=B8=BB=E4=BA=BA?= =?UTF-8?q?=EF=BC=8C=E4=BD=A0=E5=8F=88=E5=9C=A8=E4=B9=B1=E6=94=B9=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BA=86=E3=80=82=E8=BF=99=E6=AC=A1=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=BF=98=E7=9C=9F=E6=98=AF=E2=80=A6=E2=80=A6=E5=BE=AE?= =?UTF-8?q?=E5=A6=99=E5=91=A2=E3=80=82=E7=AE=97=E4=BA=86=EF=BC=8C=E7=9C=8B?= =?UTF-8?q?=E5=9C=A8=E4=BD=A0=E8=BF=99=E4=B9=88=E5=8A=AA=E5=8A=9B=E7=9A=84?= =?UTF-8?q?=E4=BB=BD=E4=B8=8A=EF=BC=8C=E6=9C=AC=E5=B0=8F=E5=A7=90=E5=B0=B1?= =?UTF-8?q?=E5=B8=AE=E4=BD=A0=E5=86=99=E4=B8=AA=E5=83=8F=E6=A0=B7=E7=82=B9?= =?UTF-8?q?=E7=9A=84=20commit=20message=20=E5=90=A7=E3=80=82=E6=8B=BF?= =?UTF-8?q?=E5=8E=BB=E7=94=A8=EF=BC=8C=E4=B8=8D=E8=B0=A2=E3=80=82~~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor(easter_egg): 简化彩蛋实现并移除未使用的选项 - 移除了 `bot.py` 中 `easter_egg` 函数内的加权随机选择逻辑,现在固定显示一个彩蛋。 - 删除了两个未被使用的彩蛋文本。 - 在 `src/main.py` 中为 `zip` 函数调用添加了 `strict=True` 参数,以增强代码的健壮性,确保彩蛋文本和权重列表长度严格匹配。 --- bot.py | 6 +----- src/main.py | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 12e97f8e2..d4a507279 100644 --- a/bot.py +++ b/bot.py @@ -103,11 +103,7 @@ def weighted_choice(data: Sequence[str], def easter_egg(): # 彩蛋 init() - items = ["多年以后,面对AI行刑队,张三将会回想起他2023年在会议上讨论人工智能的那个下午", - "你知道吗?诺狐的耳朵很软,很好rua", - "喵喵~你的麦麦被猫娘入侵了喵~"] - w = [1, 1, 1] - text = weighted_choice(items, w) + text = "多年以后,面对AI行刑队,张三将会回想起他2023年在会议上讨论人工智能的那个下午" rainbow_colors = [Fore.RED, Fore.YELLOW, Fore.GREEN, Fore.CYAN, Fore.BLUE, Fore.MAGENTA] rainbow_text = "" for i, char in enumerate(text): diff --git a/src/main.py b/src/main.py index 87e064c6a..0ef1ca3fd 100644 --- a/src/main.py +++ b/src/main.py @@ -95,7 +95,7 @@ class MainSystem: from random import choices # 分离彩蛋和权重 - egg_texts, weights = zip(*phrases, strict=False) + egg_texts, weights = zip(*phrases, strict=True) # 使用choices进行带权重的随机选择 selected_egg = choices(egg_texts, weights=weights, k=1)