diff --git a/README.md b/README.md index 2c20589..84e1e44 100644 --- a/README.md +++ b/README.md @@ -48,15 +48,14 @@ _✨ NoneBot Plugin Blocker ✨_ ## ⚙️ 配置 -### 请注意,使用<0.3.1版本的更新之后请重新在WebUI里进行配置 -### >0.3.1,<0.3.3的请更新到0.3.3来自动更新配置项或者更新之后手动重新在WebUI里配置 - ### 常规配置项,位于.env文件里 ```ini #WebUI的登录凭证,不设置即不进行验证 BLOCKER_WEBUI_USERNAME="" BLOCKER_WEBUI_PASSWORD="" +#Blocker插件的配置存放位置,留空则为默认./data/blocker +blocker_data_path="" ``` ### 其他配置项 diff --git a/nonebot_plugin_blocker/__init__.py b/nonebot_plugin_blocker/__init__.py index 0fc265d..e7dfd7f 100644 --- a/nonebot_plugin_blocker/__init__.py +++ b/nonebot_plugin_blocker/__init__.py @@ -2,7 +2,7 @@ from .__main__ import * -__version__ = "0.4.1" +__version__ = "0.4.2" __plugin_meta__ = PluginMetadata( name="Blocker", description="分群配置关闭Bot插件", diff --git a/nonebot_plugin_blocker/config.py b/nonebot_plugin_blocker/config.py index b9e25e3..bad3137 100644 --- a/nonebot_plugin_blocker/config.py +++ b/nonebot_plugin_blocker/config.py @@ -4,7 +4,21 @@ from nonebot import logger, get_plugin_config import asyncio -DATA_PATH = Path.cwd() / "data" / "blocker" + +class PluginConfigModel(BaseModel): + WEBUI_USERNAME: Optional[str] = Field(None, alias="blocker_webui_username") + WEBUI_PASSWORD: Optional[str] = Field(None, alias="blocker_webui_password") + data_path: Optional[str] = Field(None, alias="blocker_data_path") + + +config = get_plugin_config(PluginConfigModel) + + +DATA_PATH = ( + Path.cwd() / "data" / "blocker" + if config.data_path is None + else Path(config.data_path) +) if not DATA_PATH.exists(): DATA_PATH.mkdir(parents=True) @@ -27,14 +41,6 @@ } -class PluginConfigModel(BaseModel): - WEBUI_USERNAME: Optional[str] = Field(None, alias="blocker_webui_username") - WEBUI_PASSWORD: Optional[str] = Field(None, alias="blocker_webui_password") - - -config = get_plugin_config(PluginConfigModel) - - class ReplyModel(BaseModel): type: Literal["text", "image", "record"] data: Optional[str] diff --git a/pdm.lock b/pdm.lock index 0516b6e..e4fde02 100644 --- a/pdm.lock +++ b/pdm.lock @@ -5,7 +5,7 @@ groups = ["default"] strategy = ["cross_platform"] lock_version = "4.4.1" -content_hash = "sha256:9dfb3018190eff2c8137dbfb412fb8a0ab3fab14c91ca9c49888800a9f333bb5" +content_hash = "sha256:e7275d39b97c9a9b905cc7ae0da3f4d2e53c6634f25c4f70052e9ff917c0d792" [[package]] name = "annotated-types" diff --git a/pyproject.toml b/pyproject.toml index d5f3bbc..7c25e0f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,13 @@ [project] name = "nonebot-plugin-blocker" -version = "0.4.1" +version = "0.4.2" description = "Message Blocker" authors = [{ name = "MerCuJerry", email = "mercujerry@gmail.com" }] keywords = ["nonebot", "nonebot2", "qqbot", "bot"] dependencies = [ "nonebot2[fastapi] >= 2.2.0", - "nonebot-adapter-onebot>=2.4.0", + "nonebot-adapter-onebot >= 2.4.0", + "pydantic >= 2.6.1" ] requires-python = ">=3.8,<4.0" readme = "README.md"