mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-12-04 02:54:49 +08:00
24 lines
401 B
Python
24 lines
401 B
Python
|
from nonebot import on_message
|
||
|
from nonebot.adapters import Event
|
||
|
from nonebot.params import Depends
|
||
|
|
||
|
test = on_message()
|
||
|
test2 = on_message()
|
||
|
|
||
|
runned = False
|
||
|
|
||
|
|
||
|
def dependency(event: Event):
|
||
|
# test cache
|
||
|
global runned
|
||
|
assert not runned
|
||
|
runned = True
|
||
|
return event
|
||
|
|
||
|
|
||
|
@test.handle()
|
||
|
@test2.handle()
|
||
|
async def handle(x: Event = Depends(dependency)):
|
||
|
# test dependency
|
||
|
return x
|