From f8304406c52deafa5a91cbb66dd35077ce1a76cd Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Mon, 25 Jan 2021 18:15:25 +0800 Subject: [PATCH] :alembic: add new builtin plugin --- nonebot/plugin.py | 4 ++-- nonebot/plugin.pyi | 2 +- nonebot/plugins/{base.py => echo.py} | 0 nonebot/plugins/single_session.py | 20 ++++++++++++++++++++ 4 files changed, 23 insertions(+), 3 deletions(-) rename nonebot/plugins/{base.py => echo.py} (100%) create mode 100644 nonebot/plugins/single_session.py diff --git a/nonebot/plugin.py b/nonebot/plugin.py index 560d8009..f496e192 100644 --- a/nonebot/plugin.py +++ b/nonebot/plugin.py @@ -933,7 +933,7 @@ def load_plugins(*plugin_dir: str) -> Set[Plugin]: return loaded_plugins -def load_builtin_plugins() -> Optional[Plugin]: +def load_builtin_plugins(name: str = "echo") -> Optional[Plugin]: """ :说明: @@ -943,7 +943,7 @@ def load_builtin_plugins() -> Optional[Plugin]: - ``Plugin`` """ - return load_plugin("nonebot.plugins.base") + return load_plugin(f"nonebot.plugins.{name}") def get_plugin(name: str) -> Optional[Plugin]: diff --git a/nonebot/plugin.pyi b/nonebot/plugin.pyi index db31ad3d..85d925bf 100644 --- a/nonebot/plugin.pyi +++ b/nonebot/plugin.pyi @@ -168,7 +168,7 @@ def load_plugins(*plugin_dir: str) -> Set[Plugin]: ... -def load_builtin_plugins(): +def load_builtin_plugins(name: str = ...): ... diff --git a/nonebot/plugins/base.py b/nonebot/plugins/echo.py similarity index 100% rename from nonebot/plugins/base.py rename to nonebot/plugins/echo.py diff --git a/nonebot/plugins/single_session.py b/nonebot/plugins/single_session.py new file mode 100644 index 00000000..20eca034 --- /dev/null +++ b/nonebot/plugins/single_session.py @@ -0,0 +1,20 @@ +from typing import Dict, Optional + +from nonebot.typing import T_State +from nonebot.matcher import Matcher +from nonebot.adapters import Bot, Event +from nonebot.message import run_preprocessor, run_postprocessor, IgnoredException + +_running_matcher: Dict[str, bool] = {} + + +@run_preprocessor +async def _(matcher: Matcher, bot: Bot, event: Event, state: T_State): + # TODO + pass + + +@run_postprocessor +async def _(matcher: Matcher, exception: Optional[Exception], bot: Bot, event: Event, state: T_State): + # TODO + pass