🐛修复添加插件返回403的问题 (#1595)

* 完善测试方法
* vscode测试配置
* 重构插件安装过程
This commit is contained in:
AkashiCoin
2024-09-02 01:50:39 +08:00
committed by GitHub
parent 8fe061738a
commit 29c48765ae
18 changed files with 1090 additions and 452 deletions
+6 -4
View File
@@ -5,18 +5,20 @@ from nonebot.adapters.onebot.v11.event import Sender
from nonebot.adapters.onebot.v11 import Message, MessageSegment, GroupMessageEvent
def get_response_json(path: str) -> dict:
def get_response_json(base_path: Path, file: str) -> dict:
try:
return json.loads(
(Path(__file__).parent / "response" / path).read_text(encoding="utf8")
(Path(__file__).parent / "response" / base_path / file).read_text(
encoding="utf8"
)
)
except (FileNotFoundError, json.JSONDecodeError) as e:
raise ValueError(f"Error reading or parsing JSON file: {e}") from e
def get_content_bytes(path: str) -> bytes:
def get_content_bytes(base_path: Path, path: str) -> bytes:
try:
return (Path(__file__).parent / "content" / path).read_bytes()
return (Path(__file__).parent / "content" / base_path / path).read_bytes()
except FileNotFoundError as e:
raise ValueError(f"Error reading file: {e}") from e