为 Watchfiles 添加更可配置的过滤器
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -68,7 +68,7 @@ code .
|
|||||||
使用命令行手动启动 Bot:
|
使用命令行手动启动 Bot:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
poetry run watchfiles bot.main konabot
|
poetry run watchfiles bot.main . --filter scripts.watch_filter.filter
|
||||||
```
|
```
|
||||||
|
|
||||||
如果你不希望自动重载,只是想运行 Bot,可以直接运行:
|
如果你不希望自动重载,只是想运行 Bot,可以直接运行:
|
||||||
|
|||||||
13
scripts/watch_filter.py
Normal file
13
scripts/watch_filter.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
from pathlib import Path
|
||||||
|
from watchfiles import Change
|
||||||
|
|
||||||
|
|
||||||
|
base = Path(__file__).parent.parent.absolute()
|
||||||
|
|
||||||
|
|
||||||
|
def filter(change: Change, path: str) -> bool:
|
||||||
|
if "__pycache__" in path:
|
||||||
|
return False
|
||||||
|
if Path(path).absolute().is_relative_to(base / "data"):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
Reference in New Issue
Block a user