Skip to content

Commit

Permalink
Support users to change configuration storage location
Browse files Browse the repository at this point in the history
  • Loading branch information
MerCuJerry committed Feb 16, 2024
1 parent 1e7e266 commit 7486651
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
```

### 其他配置项
Expand Down
2 changes: 1 addition & 1 deletion nonebot_plugin_blocker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .__main__ import *

__version__ = "0.4.1"
__version__ = "0.4.2"
__plugin_meta__ = PluginMetadata(
name="Blocker",
description="分群配置关闭Bot插件",
Expand Down
24 changes: 15 additions & 9 deletions nonebot_plugin_blocker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[project]
name = "nonebot-plugin-blocker"
version = "0.4.1"
version = "0.4.2"
description = "Message Blocker"
authors = [{ name = "MerCuJerry", email = "[email protected]" }]
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"
Expand Down

0 comments on commit 7486651

Please sign in to comment.