From e00890033e423ef00d847872671015bff83becfd Mon Sep 17 00:00:00 2001 From: Ju4tCode <42488585+yanyongyu@users.noreply.github.com> Date: Tue, 20 Jun 2023 13:50:05 +0800 Subject: [PATCH] :sparkles: add plugin metadata to builtin plugins (#2113) --- nonebot/plugins/echo.py | 13 ++++++++++++- nonebot/plugins/single_session.py | 11 +++++++++++ packages/nonebot-plugin-docs/README.md | 2 +- .../nonebot_plugin_docs/__init__.py | 13 ++++++++++++- packages/nonebot-plugin-docs/pyproject.toml | 4 ++-- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/nonebot/plugins/echo.py b/nonebot/plugins/echo.py index 65b6c654..2b67c367 100644 --- a/nonebot/plugins/echo.py +++ b/nonebot/plugins/echo.py @@ -1,7 +1,18 @@ +from nonebot import on_command from nonebot.rule import to_me from nonebot.adapters import Message from nonebot.params import CommandArg -from nonebot.plugin import on_command +from nonebot.plugin import PluginMetadata + +__plugin_meta__ = PluginMetadata( + name="echo", + description="重复你说的话", + usage="/echo [text]", + type="application", + homepage="https://github.com/nonebot/nonebot2/blob/master/nonebot/plugins/echo.py", + config=None, + supported_adapters=None, +) echo = on_command("echo", to_me()) diff --git a/nonebot/plugins/single_session.py b/nonebot/plugins/single_session.py index 1afb478e..d5b2578f 100644 --- a/nonebot/plugins/single_session.py +++ b/nonebot/plugins/single_session.py @@ -2,8 +2,19 @@ from typing import Dict, AsyncGenerator from nonebot.adapters import Event from nonebot.params import Depends +from nonebot.plugin import PluginMetadata from nonebot.message import IgnoredException, event_preprocessor +__plugin_meta__ = PluginMetadata( + name="唯一会话", + description="限制同一会话内同时只能运行一个响应器", + usage="加载插件后自动生效", + type="application", + homepage="https://github.com/nonebot/nonebot2/blob/master/nonebot/plugins/single_session.py", + config=None, + supported_adapters=None, +) + _running_matcher: Dict[str, int] = {} diff --git a/packages/nonebot-plugin-docs/README.md b/packages/nonebot-plugin-docs/README.md index c7fb7b3f..32528990 100644 --- a/packages/nonebot-plugin-docs/README.md +++ b/packages/nonebot-plugin-docs/README.md @@ -22,6 +22,6 @@ _✨ NoneBot 本地文档插件 ✨_ ## 使用方式 -加载插件并启动 Bot ,在浏览器内打开 `http://host:port/docs/`。 +加载插件并启动 Bot ,在浏览器内打开 `http://host:port/website/`。 具体网址会在控制台内输出。 diff --git a/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py b/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py index 34578c62..196fdeb0 100644 --- a/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py +++ b/packages/nonebot-plugin-docs/nonebot_plugin_docs/__init__.py @@ -2,6 +2,17 @@ import importlib import nonebot from nonebot.log import logger +from nonebot.plugin import PluginMetadata + +__plugin_meta__ = PluginMetadata( + name="NoneBot 离线文档", + description="在本地查看 NoneBot 文档", + usage="启动机器人后访问 http://localhost:port/website/ 查看文档", + type="application", + homepage="https://github.com/nonebot/nonebot2/blob/master/packages/nonebot-plugin-docs", + config=None, + supported_adapters=None, +) def init(): @@ -17,7 +28,7 @@ def init(): register_route(driver) host = str(driver.config.host) port = driver.config.port - if host in ["0.0.0.0", "127.0.0.1"]: + if host in {"0.0.0.0", "127.0.0.1"}: host = "localhost" logger.opt(colors=True).info( f"Nonebot docs will be running at: " diff --git a/packages/nonebot-plugin-docs/pyproject.toml b/packages/nonebot-plugin-docs/pyproject.toml index 9ba24d40..83fbd377 100644 --- a/packages/nonebot-plugin-docs/pyproject.toml +++ b/packages/nonebot-plugin-docs/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nonebot-plugin-docs" -version = "2.0.0-beta.1" +version = "2.0.0" description = "View NoneBot2 Docs Locally" authors = ["yanyongyu "] license = "MIT" @@ -13,7 +13,7 @@ include = ["nonebot_plugin_docs/dist/**/*"] [tool.poetry.dependencies] python = "^3.8" -nonebot2 = "^2.0.0-beta.1" +nonebot2 = "^2.0.0" [tool.poetry.dev-dependencies]