diff --git a/archive/2.0.0a9.post1/api/adapters/cqhttp.md b/archive/2.0.0a9.post1/api/adapters/cqhttp.md index ca5d91cb..5982e72e 100644 --- a/archive/2.0.0a9.post1/api/adapters/cqhttp.md +++ b/archive/2.0.0a9.post1/api/adapters/cqhttp.md @@ -9,6 +9,23 @@ sidebarDepth: 0 协议详情请看: [CQHTTP](https://github.com/howmanybots/onebot/blob/master/README.md) | [OneBot](https://github.com/howmanybots/onebot/blob/master/README.md) +# NoneBot.adapters.cqhttp.config 模块 + + +## _class_ `Config` + +CQHTTP 配置类 + + +* **配置项** + + + * `access_token` / `cqhttp_access_token`: CQHTTP 协议授权令牌 + + + * `secret` / `cqhttp_secret`: CQHTTP HTTP 上报数据签名口令 + + # NoneBot.adapters.cqhttp.utils 模块 diff --git a/archive/2.0.0a9.post1/api/adapters/ding.md b/archive/2.0.0a9.post1/api/adapters/ding.md index c64125ac..ed2a2d38 100644 --- a/archive/2.0.0a9.post1/api/adapters/ding.md +++ b/archive/2.0.0a9.post1/api/adapters/ding.md @@ -9,6 +9,23 @@ sidebarDepth: 0 协议详情请看: [钉钉文档](https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p) +# NoneBot.adapters.ding.config 模块 + + +## _class_ `Config` + +钉钉配置类 + + +* **配置项** + + + * `access_token` / `ding_access_token`: 钉钉令牌 + + + * `secret` / `ding_secret`: 钉钉 HTTP 上报数据签名口令 + + # NoneBot.adapters.ding.exception 模块 diff --git a/archive/2.0.0a9.post1/api/adapters/mirai.md b/archive/2.0.0a9.post1/api/adapters/mirai.md index 4b568152..b627f72d 100644 --- a/archive/2.0.0a9.post1/api/adapters/mirai.md +++ b/archive/2.0.0a9.post1/api/adapters/mirai.md @@ -21,6 +21,26 @@ Mirai-API-HTTP 的适配器以 [AGPLv3许可](https://opensource.org/licenses/AG 这意味着在使用该适配器时需要 **以该许可开源您的完整程序代码** ::: +# NoneBot.adapters.mirai.config 模块 + + +## _class_ `Config` + +Mirai 配置类 + + +* **必填** + + + * `auth_key` / `mirai_auth_key`: mirai-api-http 的 auth_key + + + * `mirai_host`: mirai-api-http 的地址 + + + * `mirai_port`: mirai-api-http 的端口 + + # NoneBot.adapters.mirai.bot 模块 @@ -690,28 +710,6 @@ mirai-api-http 正向 Websocket 协议 Bot 适配。 * `qq: int`: 要使用的Bot的QQ号 **注意: 在使用正向Websocket时必须指定该值!** -# NoneBot.adapters.mirai.config 模块 - - -## _class_ `Config` - -基类:`pydantic.main.BaseModel` - -Mirai 配置类 - - -* **必填** - - - * `mirai_auth_key`: mirai-api-http的auth_key - - - * `mirai_host`: mirai-api-http的地址 - - - * `mirai_port`: mirai-api-http的端口 - - # NoneBot.adapters.mirai.message 模块 diff --git a/archive/2.0.0a9.post1/api/drivers/fastapi.md b/archive/2.0.0a9.post1/api/drivers/fastapi.md index edd8e474..fba15c68 100644 --- a/archive/2.0.0a9.post1/api/drivers/fastapi.md +++ b/archive/2.0.0a9.post1/api/drivers/fastapi.md @@ -10,6 +10,58 @@ sidebarDepth: 0 后端使用方法请参考: [FastAPI 文档](https://fastapi.tiangolo.com/) +## _class_ `Config` + +基类:`pydantic.env_settings.BaseSettings` + +FastAPI 驱动框架设置,详情参考 FastAPI 文档 + + +### `fastapi_openapi_url` + + +* **类型** + + `Optional[str]` + + + +* **说明** + + openapi.json 地址,默认为 None 即关闭 + + + +### `fastapi_docs_url` + + +* **类型** + + `Optional[str]` + + + +* **说明** + + swagger 地址,默认为 None 即关闭 + + + +### `fastapi_redoc_url` + + +* **类型** + + `Optional[str]` + + + +* **说明** + + redoc 地址,默认为 None 即关闭 + + + ## _class_ `Driver` 基类:[`nonebot.drivers.Driver`](README.md#nonebot.drivers.Driver) diff --git a/docs/api/adapters/cqhttp.md b/docs/api/adapters/cqhttp.md index ca5d91cb..5982e72e 100644 --- a/docs/api/adapters/cqhttp.md +++ b/docs/api/adapters/cqhttp.md @@ -9,6 +9,23 @@ sidebarDepth: 0 协议详情请看: [CQHTTP](https://github.com/howmanybots/onebot/blob/master/README.md) | [OneBot](https://github.com/howmanybots/onebot/blob/master/README.md) +# NoneBot.adapters.cqhttp.config 模块 + + +## _class_ `Config` + +CQHTTP 配置类 + + +* **配置项** + + + * `access_token` / `cqhttp_access_token`: CQHTTP 协议授权令牌 + + + * `secret` / `cqhttp_secret`: CQHTTP HTTP 上报数据签名口令 + + # NoneBot.adapters.cqhttp.utils 模块 diff --git a/docs/api/adapters/ding.md b/docs/api/adapters/ding.md index c64125ac..ed2a2d38 100644 --- a/docs/api/adapters/ding.md +++ b/docs/api/adapters/ding.md @@ -9,6 +9,23 @@ sidebarDepth: 0 协议详情请看: [钉钉文档](https://ding-doc.dingtalk.com/document#/org-dev-guide/elzz1p) +# NoneBot.adapters.ding.config 模块 + + +## _class_ `Config` + +钉钉配置类 + + +* **配置项** + + + * `access_token` / `ding_access_token`: 钉钉令牌 + + + * `secret` / `ding_secret`: 钉钉 HTTP 上报数据签名口令 + + # NoneBot.adapters.ding.exception 模块 diff --git a/docs/api/adapters/mirai.md b/docs/api/adapters/mirai.md index 4b568152..b627f72d 100644 --- a/docs/api/adapters/mirai.md +++ b/docs/api/adapters/mirai.md @@ -21,6 +21,26 @@ Mirai-API-HTTP 的适配器以 [AGPLv3许可](https://opensource.org/licenses/AG 这意味着在使用该适配器时需要 **以该许可开源您的完整程序代码** ::: +# NoneBot.adapters.mirai.config 模块 + + +## _class_ `Config` + +Mirai 配置类 + + +* **必填** + + + * `auth_key` / `mirai_auth_key`: mirai-api-http 的 auth_key + + + * `mirai_host`: mirai-api-http 的地址 + + + * `mirai_port`: mirai-api-http 的端口 + + # NoneBot.adapters.mirai.bot 模块 @@ -690,28 +710,6 @@ mirai-api-http 正向 Websocket 协议 Bot 适配。 * `qq: int`: 要使用的Bot的QQ号 **注意: 在使用正向Websocket时必须指定该值!** -# NoneBot.adapters.mirai.config 模块 - - -## _class_ `Config` - -基类:`pydantic.main.BaseModel` - -Mirai 配置类 - - -* **必填** - - - * `mirai_auth_key`: mirai-api-http的auth_key - - - * `mirai_host`: mirai-api-http的地址 - - - * `mirai_port`: mirai-api-http的端口 - - # NoneBot.adapters.mirai.message 模块 diff --git a/docs/api/drivers/fastapi.md b/docs/api/drivers/fastapi.md index edd8e474..fba15c68 100644 --- a/docs/api/drivers/fastapi.md +++ b/docs/api/drivers/fastapi.md @@ -10,6 +10,58 @@ sidebarDepth: 0 后端使用方法请参考: [FastAPI 文档](https://fastapi.tiangolo.com/) +## _class_ `Config` + +基类:`pydantic.env_settings.BaseSettings` + +FastAPI 驱动框架设置,详情参考 FastAPI 文档 + + +### `fastapi_openapi_url` + + +* **类型** + + `Optional[str]` + + + +* **说明** + + openapi.json 地址,默认为 None 即关闭 + + + +### `fastapi_docs_url` + + +* **类型** + + `Optional[str]` + + + +* **说明** + + swagger 地址,默认为 None 即关闭 + + + +### `fastapi_redoc_url` + + +* **类型** + + `Optional[str]` + + + +* **说明** + + redoc 地址,默认为 None 即关闭 + + + ## _class_ `Driver` 基类:[`nonebot.drivers.Driver`](README.md#nonebot.drivers.Driver) diff --git a/docs_build/adapters/cqhttp.rst b/docs_build/adapters/cqhttp.rst index 17d5816a..184c65fc 100644 --- a/docs_build/adapters/cqhttp.rst +++ b/docs_build/adapters/cqhttp.rst @@ -8,6 +8,12 @@ NoneBot.adapters.cqhttp 模块 .. automodule:: nonebot.adapters.cqhttp +NoneBot.adapters.cqhttp.config 模块 +=================================== + +.. automodule:: nonebot.adapters.cqhttp.config + :members: + NoneBot.adapters.cqhttp.utils 模块 =================================== diff --git a/docs_build/adapters/ding.rst b/docs_build/adapters/ding.rst index 3b12564b..21cbed1f 100644 --- a/docs_build/adapters/ding.rst +++ b/docs_build/adapters/ding.rst @@ -8,6 +8,12 @@ NoneBot.adapters.ding 模块 .. automodule:: nonebot.adapters.ding +NoneBot.adapters.ding.config 模块 +=================================== + +.. automodule:: nonebot.adapters.ding.config + :members: + NoneBot.adapters.ding.exception 模块 ===================================== diff --git a/docs_build/adapters/mirai.rst b/docs_build/adapters/mirai.rst index a2f6a9c6..4a991217 100644 --- a/docs_build/adapters/mirai.rst +++ b/docs_build/adapters/mirai.rst @@ -8,6 +8,12 @@ NoneBot.adapters.mirai 模块 .. automodule:: nonebot.adapters.mirai +NoneBot.adapters.mirai.config 模块 +================================== + +.. automodule:: nonebot.adapters.mirai.config + :members: + NoneBot.adapters.mirai.bot 模块 =============================== @@ -22,13 +28,6 @@ NoneBot.adapters.mirai.bot_ws 模块 :members: :show-inheritance: -NoneBot.adapters.mirai.config 模块 -================================== - -.. automodule:: nonebot.adapters.mirai.config - :members: - :show-inheritance: - NoneBot.adapters.mirai.message 模块 =================================== @@ -83,4 +82,4 @@ NoneBot.adapters.mirai.event.request 模块 .. automodule:: nonebot.adapters.mirai.event.request :members: - :show-inheritance: \ No newline at end of file + :show-inheritance: diff --git a/nonebot/adapters/cqhttp/config.py b/nonebot/adapters/cqhttp/config.py index c537170a..8879705a 100644 --- a/nonebot/adapters/cqhttp/config.py +++ b/nonebot/adapters/cqhttp/config.py @@ -5,6 +5,14 @@ from pydantic import Field, BaseModel # priority: alias > origin class Config(BaseModel): + """ + CQHTTP 配置类 + + :配置项: + + - ``access_token`` / ``cqhttp_access_token``: CQHTTP 协议授权令牌 + - ``secret`` / ``cqhttp_secret``: CQHTTP HTTP 上报数据签名口令 + """ access_token: Optional[str] = Field(default=None, alias="cqhttp_access_token") secret: Optional[str] = Field(default=None, alias="cqhttp_secret") diff --git a/nonebot/adapters/ding/config.py b/nonebot/adapters/ding/config.py index 5b334a94..08e84ee2 100644 --- a/nonebot/adapters/ding/config.py +++ b/nonebot/adapters/ding/config.py @@ -4,6 +4,14 @@ from pydantic import Field, BaseModel class Config(BaseModel): + """ + 钉钉配置类 + + :配置项: + + - ``access_token`` / ``ding_access_token``: 钉钉令牌 + - ``secret`` / ``ding_secret``: 钉钉 HTTP 上报数据签名口令 + """ secret: Optional[str] = Field(default=None, alias="ding_secret") access_token: Optional[str] = Field(default=None, alias="ding_access_token") diff --git a/nonebot/adapters/mirai/config.py b/nonebot/adapters/mirai/config.py index a907dd17..e1983f45 100644 --- a/nonebot/adapters/mirai/config.py +++ b/nonebot/adapters/mirai/config.py @@ -10,9 +10,9 @@ class Config(BaseModel): :必填: - - ``mirai_auth_key``: mirai-api-http的auth_key - - ``mirai_host``: mirai-api-http的地址 - - ``mirai_port``: mirai-api-http的端口 + - ``auth_key`` / ``mirai_auth_key``: mirai-api-http 的 auth_key + - ``mirai_host``: mirai-api-http 的地址 + - ``mirai_port``: mirai-api-http 的端口 """ auth_key: Optional[str] = Field(None, alias='mirai_auth_key') host: Optional[IPv4Address] = Field(None, alias='mirai_host') diff --git a/nonebot/drivers/__init__.py b/nonebot/drivers/__init__.py index 986d59a3..134b2078 100644 --- a/nonebot/drivers/__init__.py +++ b/nonebot/drivers/__init__.py @@ -62,7 +62,7 @@ class Driver(abc.ABC): :说明: 已连接的 Bot """ - def register_adapter(self, name: str, adapter: Type["Bot"]): + def register_adapter(self, name: str, adapter: Type["Bot"], **kwargs): """ :说明: @@ -74,7 +74,7 @@ class Driver(abc.ABC): * ``adapter: Type[Bot]``: 适配器 Class """ self._adapters[name] = adapter - adapter.register(self, self.config) + adapter.register(self, self.config, **kwargs) logger.opt( colors=True).debug(f'Succeeded to load adapter "{name}"') diff --git a/nonebot/drivers/fastapi.py b/nonebot/drivers/fastapi.py index 284b738b..f78681c7 100644 --- a/nonebot/drivers/fastapi.py +++ b/nonebot/drivers/fastapi.py @@ -28,9 +28,39 @@ from nonebot.drivers import Driver as BaseDriver, WebSocket as BaseWebSocket class Config(BaseSettings): + """ + FastAPI 驱动框架设置,详情参考 FastAPI 文档 + """ fastapi_openapi_url: Optional[str] = None + """ + :类型: + + ``Optional[str]`` + + :说明: + + `openapi.json` 地址,默认为 `None` 即关闭 + """ fastapi_docs_url: Optional[str] = None + """ + :类型: + + ``Optional[str]`` + + :说明: + + `swagger` 地址,默认为 `None` 即关闭 + """ fastapi_redoc_url: Optional[str] = None + """ + :类型: + + ``Optional[str]`` + + :说明: + + `redoc` 地址,默认为 `None` 即关闭 + """ class Config: extra = "ignore"