diff --git a/nonebot/__init__.py b/nonebot/__init__.py index 35485f4b..7522f270 100644 --- a/nonebot/__init__.py +++ b/nonebot/__init__.py @@ -138,7 +138,6 @@ def get_bots() -> Union[NoReturn, Dict[str, Bot]]: from nonebot.utils import escape_tag from nonebot.config import Env, Config from nonebot.log import logger, default_filter -from nonebot.adapters.cqhttp import Bot as CQBot def init(*, _env_file: Optional[str] = None, **kwargs): @@ -184,9 +183,6 @@ def init(*, _env_file: Optional[str] = None, **kwargs): importlib.import_module(config.driver), "Driver") _driver = DriverClass(env, config) - # register build-in adapters - _driver.register_adapter("cqhttp", CQBot) - def run(host: Optional[str] = None, port: Optional[int] = None, diff --git a/nonebot/drivers/__init__.py b/nonebot/drivers/__init__.py index 8e309b64..8227690f 100644 --- a/nonebot/drivers/__init__.py +++ b/nonebot/drivers/__init__.py @@ -123,7 +123,8 @@ class BaseDriver(abc.ABC): * ``*args`` * ``**kwargs`` """ - raise NotImplementedError + logger.opt(colors=True).debug( + f"Loaded adapters: {', '.join(self._adapters)}") @abc.abstractmethod async def _handle_http(self): diff --git a/nonebot/drivers/fastapi.py b/nonebot/drivers/fastapi.py index 0828e344..973cf052 100644 --- a/nonebot/drivers/fastapi.py +++ b/nonebot/drivers/fastapi.py @@ -98,6 +98,7 @@ class Driver(BaseDriver): app: Optional[str] = None, **kwargs): """使用 ``uvicorn`` 启动 FastAPI""" + super().run(host, port, app, **kwargs) LOGGING_CONFIG = { "version": 1, "disable_existing_loggers": False, diff --git a/tests/bot.py b/tests/bot.py index 68a4e399..45f99b95 100644 --- a/tests/bot.py +++ b/tests/bot.py @@ -4,6 +4,7 @@ import sys sys.path.insert(0, os.path.abspath("..")) import nonebot +from nonebot.adapters.cqhttp import Bot from nonebot.log import logger, default_format # test custom log @@ -15,6 +16,8 @@ logger.add("error.log", nonebot.init(custom_config2="config on init") app = nonebot.get_asgi() +driver = nonebot.get_driver() +driver.register_adapter("cqhttp", Bot) # load builtin plugin nonebot.load_builtin_plugins() @@ -25,7 +28,7 @@ nonebot.load_plugins("test_plugins") print(nonebot.require("test_export")) # modify some config / config depends on loaded configs -config = nonebot.get_driver().config +config = driver.config config.custom_config3 = config.custom_config1 config.custom_config4 = "New custom config"