💡 update docstring

This commit is contained in:
yanyongyu
2021-02-24 17:56:43 +08:00
parent eb8e5aa39d
commit 04e11c3b3e
6 changed files with 89 additions and 4 deletions

View File

@ -73,8 +73,6 @@ class Driver(abc.ABC):
* ``name: str``: 适配器名称,用于在连接时进行识别
* ``adapter: Type[Bot]``: 适配器 Class
"""
if name in self._adapters:
print("============", name)
self._adapters[name] = adapter
adapter.register(self, self.config, **kwargs)
logger.opt(

View File

@ -172,7 +172,6 @@ class Driver(BaseDriver):
self_id = await BotClass.check_permission(self, 'websocket',
headers, None)
except RequestDenied as e:
print(e.reason)
raise exceptions.HTTPException(status_code=e.status_code,
description=e.reason,
name='Request Denied')

View File

@ -1071,6 +1071,20 @@ def load_all_plugins(module_path: Set[str],
def load_from_json(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
"""
:说明:
导入指定 json 文件中的 ``plugins`` 以及 ``plugin_dirs`` 下多个插件,以 ``_`` 开头的插件不会被导入!
:参数:
- ``file_path: str``: 指定 json 文件路径
- ``encoding: str``: 指定 json 文件编码
:返回:
- ``Set[Plugin]``
"""
with open(file_path, "r", encoding=encoding) as f:
data = json.load(f)
plugins = data.get("plugins")
@ -1082,6 +1096,21 @@ def load_from_json(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
def load_from_toml(file_path: str, encoding: str = "utf-8") -> Set[Plugin]:
"""
:说明:
导入指定 toml 文件 ``[nonebot.plugins]`` 中的 ``plugins`` 以及 ``plugin_dirs`` 下多个插件,
以 ``_`` 开头的插件不会被导入!
:参数:
- ``file_path: str``: 指定 toml 文件路径
- ``encoding: str``: 指定 toml 文件编码
:返回:
- ``Set[Plugin]``
"""
with open(file_path, "r", encoding=encoding) as f:
data = tomlkit.parse(f.read())