From 3f454714ec13cd210edde968a07b18027697e40f Mon Sep 17 00:00:00 2001 From: student_2333 Date: Tue, 5 Sep 2023 14:41:42 +0800 Subject: [PATCH] chore --- nonebot_plugin_pjsk/config.py | 8 ++++++-- nonebot_plugin_pjsk/draw.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/nonebot_plugin_pjsk/config.py b/nonebot_plugin_pjsk/config.py index 139f36e..c2288aa 100644 --- a/nonebot_plugin_pjsk/config.py +++ b/nonebot_plugin_pjsk/config.py @@ -21,7 +21,7 @@ class ConfigModel(BaseModel): "https://raw.githubusercontent.com/Agnes4m/nonebot_plugin_pjsk/main/", ] - pjsk_emoji_source: EmojiSource = EmojiSource.Apple + pjsk_emoji_source: str = "Apple" pjsk_help_as_image: bool = True pjsk_reply: bool = True pjsk_sticker_format: str = "PNG" @@ -44,9 +44,13 @@ def check(url: str) -> str: @validator("pjsk_emoji_source", pre=True) def check_emoji_source(cls, v): # noqa: N805 try: - return getattr(EmojiSource, v) + getattr(EmojiSource, v) except AttributeError as e: raise ValueError("Invalid emoji source") from e + return v + + def get_emoji_source(self) -> EmojiSource: + return getattr(EmojiSource, self.pjsk_emoji_source) config: ConfigModel = ConfigModel.parse_obj(get_driver().config.dict()) diff --git a/nonebot_plugin_pjsk/draw.py b/nonebot_plugin_pjsk/draw.py index 5c90516..471e5d9 100644 --- a/nonebot_plugin_pjsk/draw.py +++ b/nonebot_plugin_pjsk/draw.py @@ -71,7 +71,7 @@ def ensure_font() -> Font: if not FONT: FONT = Font( str(FONT_PATH), - emoji_options=EmojiOptions(source=config.pjsk_emoji_source), + emoji_options=EmojiOptions(source=config.get_emoji_source()), ) return FONT