Skip to content

Commit

Permalink
update config.py
Browse files Browse the repository at this point in the history
  • Loading branch information
eya46 committed Feb 14, 2024
1 parent 69e16f3 commit 3548116
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
11 changes: 3 additions & 8 deletions nonebot_plugin_enatfrp/config.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from typing import Optional, List

from nonebot import get_driver
from pydantic import BaseModel, Field, Extra, __version__, AnyUrl
from pydantic import BaseModel, Field, AnyUrl


class Config(BaseModel, extra=Extra.ignore):
class Config(BaseModel):
natfrp_api: AnyUrl = Field(default="https://api.natfrp.com/v4")
natfrp_token: Optional[str] = Field(default=None)
natfrp_at: bool = Field(default=False)
Expand All @@ -23,11 +23,6 @@ class Config(BaseModel, extra=Extra.ignore):
natfrp_cmd_showPCs: List[str] = Field(default=["计算机列表"])


if __version__[0] == "1":
config: Config = Config.parse_obj(get_driver().config) # type:ignore
elif __version__[0] == "2":
config: Config = Config.model_validate(get_driver().config) # type:ignore
else:
raise Exception(f"不支持的pydantic版本:{__version__}")
config: Config = Config(**get_driver().config.dict())

__all__ = ["Config", "config"]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot-plugin-enatfrp"
version = "0.1.6"
version = "0.1.7"
description = "SakuraFrp管理插件"
authors = ["eya46 <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 3548116

Please sign in to comment.