mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-07-27 16:21:28 +00:00
fix config and import nonebot-test
This commit is contained in:
@ -11,6 +11,11 @@ from nonebot.drivers import BaseDriver
|
||||
from nonebot.adapters.cqhttp import Bot as CQBot
|
||||
from nonebot.typing import Union, Optional, NoReturn
|
||||
|
||||
try:
|
||||
import nonebot_test
|
||||
except ImportError:
|
||||
nonebot_test = None
|
||||
|
||||
_driver: Optional[BaseDriver] = None
|
||||
|
||||
|
||||
@ -41,8 +46,13 @@ def init(*, _env_file: Optional[str] = None, **kwargs):
|
||||
Driver = getattr(importlib.import_module(config.driver), "Driver")
|
||||
_driver = Driver(env, config)
|
||||
|
||||
# register build-in adapters
|
||||
_driver.register_adapter("cqhttp", CQBot)
|
||||
|
||||
# load nonebot test frontend if debug
|
||||
if config.debug and nonebot_test:
|
||||
nonebot_test.init()
|
||||
|
||||
|
||||
def run(host: Optional[IPv4Address] = None,
|
||||
port: Optional[int] = None,
|
||||
|
Reference in New Issue
Block a user