💥 remove builtin adapter auto register

This commit is contained in:
yanyongyu 2020-12-02 13:17:27 +08:00
parent 6a25e42571
commit 0738b275a5
4 changed files with 7 additions and 6 deletions

View File

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

View File

@ -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):

View File

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

View File

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