-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
7 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,15 @@ | ||
from typing import Set | ||
|
||
from nonebot import get_driver | ||
from pydantic import BaseModel, Field, Extra, __version__ | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class Config(BaseModel, extra=Extra.ignore): | ||
class Config(BaseModel): | ||
b23_default_command: str = Field(default='B站热搜') | ||
b23_commands: Set[str] = Field(default={'b23', }) | ||
b23_commands: Set[str] = Field(default_factory=lambda: {'b23', }) | ||
b23_block: bool = Field(default=False) | ||
b23_priority: int = Field(default=99) | ||
b23_max_length: int = Field(default=20, gt=0, lt=101) | ||
|
||
|
||
if __version__[0] == "1": | ||
config = Config.parse_obj(get_driver().config) | ||
elif __version__[0] == "2": | ||
config = Config.model_validate(get_driver().config) | ||
else: | ||
raise Exception(f"不支持的pydantic版本:{__version__}") | ||
config = Config(**get_driver().config.dict()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters