From 5db20061eb1fd7b7a880eba28258878187ea385d Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Sun, 24 May 2026 17:59:32 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=20command=5Fguard=20?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=BE=A4=E6=88=90=E5=91=98=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=EF=BC=8C=E6=9B=B4=E6=96=B0=E5=AF=B9=E5=BA=94=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot/command_guard.py | 2 -- tests/test_bot_command_guard.py | 17 +---------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/src/bot/command_guard.py b/src/bot/command_guard.py index b22531f2..7702eaaf 100644 --- a/src/bot/command_guard.py +++ b/src/bot/command_guard.py @@ -98,6 +98,4 @@ class CommandGuard: return True def ensure_access_and_points(self, message: Any, cost: int, command_label: str) -> bool: - if not self.ensure_group_member(message, command_label): - return False return self.io_layer.ensure_query_points(message, cost, command_label) diff --git a/tests/test_bot_command_guard.py b/tests/test_bot_command_guard.py index 55ffa53c..1461c6d1 100644 --- a/tests/test_bot_command_guard.py +++ b/tests/test_bot_command_guard.py @@ -11,22 +11,7 @@ def _message(): ) -def test_guard_blocks_non_member_before_points_charge(): - fake_bot = SimpleNamespace( - reply_to=Mock(), - get_chat_member=Mock(return_value=SimpleNamespace(status="left")), - ) - io_layer = SimpleNamespace(bot=fake_bot, ensure_query_points=Mock(return_value=True)) - guard = CommandGuard(io_layer=io_layer, group_chat_id="-100123") - - ok = guard.ensure_access_and_points(_message(), 1, "/city") - - assert ok is False - assert io_layer.ensure_query_points.call_count == 0 - assert fake_bot.reply_to.call_count == 1 - - -def test_guard_allows_member_then_charges_points(): +def test_guard_charges_points(): fake_bot = SimpleNamespace( reply_to=Mock(), get_chat_member=Mock(return_value=SimpleNamespace(status="member")),