mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-28 00:31:14 +00:00
add startup shutdown deco
This commit is contained in:
@ -5,7 +5,7 @@ import abc
|
||||
from ipaddress import IPv4Address
|
||||
|
||||
from nonebot.config import Env, Config
|
||||
from nonebot.typing import Bot, Dict, Optional
|
||||
from nonebot.typing import Bot, Dict, Optional, Callable
|
||||
|
||||
|
||||
class BaseDriver(abc.ABC):
|
||||
@ -35,6 +35,14 @@ class BaseDriver(abc.ABC):
|
||||
def bots(self) -> Dict[int, Bot]:
|
||||
return self._clients
|
||||
|
||||
@abc.abstractmethod
|
||||
def on_startup(self, func: Callable) -> Callable:
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def on_shutdown(self, func: Callable) -> Callable:
|
||||
raise NotImplementedError
|
||||
|
||||
@abc.abstractmethod
|
||||
def run(self,
|
||||
host: Optional[IPv4Address] = None,
|
||||
|
Reference in New Issue
Block a user