add startup shutdown deco

This commit is contained in:
yanyongyu
2020-08-11 10:44:05 +08:00
parent 2d90c35df6
commit b32d4a24d1
5 changed files with 36 additions and 10 deletions

View File

@ -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,