nonebot2/tests/plugins/depends.py

24 lines
417 B
Python
Raw Normal View History

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()
2021-12-16 16:20:33 +08:00
async def handle(x: Event = Depends(dependency, use_cache=True)):
# test dependency
return x