mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-09-13 15:36:48 +00:00
adjust on_websocket_connect
This commit is contained in:
@ -113,18 +113,14 @@ def on_startup(func: Callable[[], Awaitable[None]]) \
|
|||||||
return get_bot().server_app.before_serving(func)
|
return get_bot().server_app.before_serving(func)
|
||||||
|
|
||||||
|
|
||||||
def on_websocket_connect(func: Callable[[], Awaitable[None]]) \
|
def on_websocket_connect(func: Callable[[aiocqhttp.Event], Awaitable[None]]) \
|
||||||
-> Callable[[], Awaitable[None]]:
|
-> Callable[[], Awaitable[None]]:
|
||||||
"""
|
"""
|
||||||
Decorator to register a function as websocket connect callback.
|
Decorator to register a function as websocket connect callback.
|
||||||
|
|
||||||
Only work with CQHTTP v4.14+.
|
Only work with CQHTTP v4.14+.
|
||||||
"""
|
"""
|
||||||
|
return get_bot().on_meta_event('lifecycle.connect')(func)
|
||||||
async def _func(event: aiocqhttp.Event):
|
|
||||||
await func()
|
|
||||||
|
|
||||||
return get_bot().on_meta_event('lifecycle.connect')(_func)
|
|
||||||
|
|
||||||
|
|
||||||
from .exceptions import *
|
from .exceptions import *
|
||||||
|
Reference in New Issue
Block a user