diff --git a/CHANGELOG.md b/CHANGELOG.md index f637b66..8ccc777 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ semantic versioning. ## [Unreleased] +### Fixed + +- `help ` now resolves help for the base command while + preserving the full message for context-aware help text (#285). Exact + multi-word aliases such as `dad joke` and `ps aux` still take precedence + over the base-command fallback. + ## [1.1.0] - 2026-09-13 ### Added diff --git a/tests/test_command_manager.py b/tests/test_command_manager.py index b27d20a..2a691f3 100644 --- a/tests/test_command_manager.py +++ b/tests/test_command_manager.py @@ -238,6 +238,37 @@ class TestCheckKeywords: matches = manager.check_keywords(msg) assert any(trigger == "help" for trigger, _ in matches) + def test_help_subcommand_routes_to_base_command_with_full_message(self, cm_bot): + net_cmd = MagicMock() + net_cmd.keywords = ["net"] + net_cmd.get_help_text = Mock(return_value="Network help") + manager = make_manager(cm_bot, commands={"net": net_cmd}) + message = mock_message(content="help net create", is_dm=True) + + matches = manager.check_keywords(message) + + assert any(trigger == "help" and "Network help" in response for trigger, response in matches) + net_cmd.get_help_text.assert_called_once_with(message) + assert message.content == "help net create" + + def test_help_routing_preserves_exact_multiword_alias(self, cm_bot): + dadjoke_cmd = MagicMock() + dadjoke_cmd.keywords = ["dadjoke", "dad joke"] + dadjoke_cmd.get_help_text = Mock(return_value="Dad joke help") + unrelated_cmd = MagicMock() + unrelated_cmd.keywords = ["dad"] + unrelated_cmd.get_help_text = Mock(return_value="Wrong help") + manager = make_manager( + cm_bot, + commands={"dadjoke": dadjoke_cmd, "dad": unrelated_cmd}, + ) + + matches = manager.check_keywords(mock_message(content="help dad joke", is_dm=True)) + + assert any(trigger == "help" and "Dad joke help" in response for trigger, response in matches) + dadjoke_cmd.get_help_text.assert_called_once() + unrelated_cmd.get_help_text.assert_not_called() + def test_help_disabled_no_response(self, cm_bot): """[Help_Command] enabled=false must suppress the help response.