mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-06 12:06:45 +00:00
✨ Feature: 存储 matcher 发送 prompt 的结果 (#3155)
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
from typing import Annotated
|
||||
from typing import Annotated, Any
|
||||
|
||||
from nonebot.adapters import Message
|
||||
from nonebot.params import Arg, ArgPlainText, ArgStr
|
||||
from nonebot.params import Arg, ArgPlainText, ArgPromptResult, ArgStr
|
||||
|
||||
|
||||
async def arg(key: Message = Arg()) -> Message:
|
||||
@ -28,6 +28,10 @@ async def annotated_arg_plain_text(key: Annotated[str, ArgPlainText()]) -> str:
|
||||
return key
|
||||
|
||||
|
||||
async def annotated_arg_prompt_result(key: Annotated[Any, ArgPromptResult()]) -> Any:
|
||||
return key
|
||||
|
||||
|
||||
# test dependency priority
|
||||
async def annotated_prior_arg(key: Annotated[str, ArgStr("foo")] = ArgPlainText()):
|
||||
return key
|
||||
|
@ -1,8 +1,13 @@
|
||||
from typing import TypeVar, Union
|
||||
from typing import Any, TypeVar, Union
|
||||
|
||||
from nonebot.adapters import Event
|
||||
from nonebot.matcher import Matcher
|
||||
from nonebot.params import LastReceived, Received
|
||||
from nonebot.params import (
|
||||
LastReceived,
|
||||
PausePromptResult,
|
||||
Received,
|
||||
ReceivePromptResult,
|
||||
)
|
||||
|
||||
|
||||
async def matcher(m: Matcher) -> Matcher:
|
||||
@ -59,3 +64,11 @@ async def receive(e: Event = Received("test")) -> Event:
|
||||
|
||||
async def last_receive(e: Event = LastReceived()) -> Event:
|
||||
return e
|
||||
|
||||
|
||||
async def receive_prompt_result(result: Any = ReceivePromptResult("test")) -> Any:
|
||||
return result
|
||||
|
||||
|
||||
async def pause_prompt_result(result: Any = PausePromptResult()) -> Any:
|
||||
return result
|
||||
|
Reference in New Issue
Block a user