Feature: 命令匹配支持强制指定空白符 (#1748)

This commit is contained in:
Ju4tCode
2023-02-27 00:11:24 +08:00
committed by GitHub
parent f8c67ebdf6
commit 433c672130
8 changed files with 154 additions and 19 deletions

View File

@ -30,6 +30,7 @@ from nonebot.consts import (
FULLMATCH_KEY,
REGEX_MATCHED,
STARTSWITH_KEY,
CMD_WHITESPACE_KEY,
)
@ -202,6 +203,7 @@ async def test_state(app: App):
command_start,
regex_matched,
not_legacy_state,
command_whitespace,
shell_command_args,
shell_command_argv,
)
@ -213,6 +215,7 @@ async def test_state(app: App):
RAW_CMD_KEY: "/cmd",
CMD_START_KEY: "/",
CMD_ARG_KEY: fake_message,
CMD_WHITESPACE_KEY: " ",
},
SHELL_ARGV: ["-h"],
SHELL_ARGS: {"help": True},
@ -264,6 +267,12 @@ async def test_state(app: App):
ctx.pass_params(state=fake_state)
ctx.should_return(fake_state[PREFIX_KEY][CMD_START_KEY])
async with app.test_dependent(
command_whitespace, allow_types=[StateParam, DependParam]
) as ctx:
ctx.pass_params(state=fake_state)
ctx.should_return(fake_state[PREFIX_KEY][CMD_WHITESPACE_KEY])
async with app.test_dependent(
shell_command_argv, allow_types=[StateParam, DependParam]
) as ctx: