mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-22 02:25:56 +08:00
📝 Update creating-a-matcher.md
This commit is contained in:
parent
db7e10cb4d
commit
8f69b2449d
@ -115,16 +115,17 @@ rule 的出现使得 nonebot 对事件的响应可以非常自由,nonebot 内
|
|||||||
|
|
||||||
```python
|
```python
|
||||||
from nonebot.rule import Rule
|
from nonebot.rule import Rule
|
||||||
|
from nonebot.typing import T_State
|
||||||
|
|
||||||
async def async_checker(bot: Bot, event: Event, state: State) -> bool:
|
async def async_checker(bot: Bot, event: Event, state: T_State) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def sync_checker(bot: Bot, event: Event, state: State) -> bool:
|
def sync_checker(bot: Bot, event: Event, state: T_State) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check(arg1, args2):
|
def check(arg1, args2):
|
||||||
|
|
||||||
async def _checker(bot: Bot, event: Event, state: State) -> bool:
|
async def _checker(bot: Bot, event: Event, state: T_State) -> bool:
|
||||||
return bool(arg1 + arg2)
|
return bool(arg1 + arg2)
|
||||||
|
|
||||||
return Rule(_check)
|
return Rule(_check)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user