From 19308ffc532f63ce586154c77727b76d7945bcac Mon Sep 17 00:00:00 2001 From: snowyServer Date: Mon, 1 Apr 2024 11:37:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E5=A4=A9=E6=B0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/liteyuki_main/__init__.py | 2 +- liteyuki/liteyuki_main/core.py | 16 ++++++++++++++++ .../liteyuki_main/{webdash.py => runtime.py} | 0 .../{data_model.py => models.py} | 6 ++++++ 4 files changed, 23 insertions(+), 1 deletion(-) rename liteyuki/liteyuki_main/{webdash.py => runtime.py} (100%) rename liteyuki/plugins/liteyuki_weather/{data_model.py => models.py} (56%) diff --git a/liteyuki/liteyuki_main/__init__.py b/liteyuki/liteyuki_main/__init__.py index 6d147c6..1b20d38 100644 --- a/liteyuki/liteyuki_main/__init__.py +++ b/liteyuki/liteyuki_main/__init__.py @@ -3,7 +3,7 @@ from nonebot.plugin import PluginMetadata from liteyuki.utils.language import get_default_lang from .core import * from .loader import * -from .webdash import * +from .runtime import * __author__ = "snowykami" __plugin_meta__ = PluginMetadata( diff --git a/liteyuki/liteyuki_main/core.py b/liteyuki/liteyuki_main/core.py index 3817226..1cb9986 100644 --- a/liteyuki/liteyuki_main/core.py +++ b/liteyuki/liteyuki_main/core.py @@ -61,6 +61,14 @@ cmd_config = on_alconna( permission=SUPERUSER ) +switch_image_mode = on_alconna( + aliases={"切换图片模式"}, + command=Alconna( + "switch-image-mode" + ), + permission=SUPERUSER +) + @cmd_liteyuki.handle() async def _(bot: T_Bot): @@ -127,6 +135,14 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): await md.send_md(reply, bot, event=event) +@switch_image_mode.handle() +async def _(bot: T_Bot, event: T_MessageEvent): + ulang = get_user_lang(str(event.user_id)) + stored_config: StoredConfig = common_db.first(StoredConfig(), default=StoredConfig()) + stored_config.config["markdown_image"] = not stored_config.config.get("markdownimage", False) + common_db.upsert(stored_config) + await switch_image_mode.finish(f"{ulang.get('liteyuki.image_mode_switched', MODE=ulang.get('liteyuki.image_mode_on') if stored_config.config.get('image_mode') else ulang.get('liteyuki.image_mode_off'))}") + @driver.on_startup async def on_startup(): htmlrender.browser = await htmlrender.get_browser() diff --git a/liteyuki/liteyuki_main/webdash.py b/liteyuki/liteyuki_main/runtime.py similarity index 100% rename from liteyuki/liteyuki_main/webdash.py rename to liteyuki/liteyuki_main/runtime.py diff --git a/liteyuki/plugins/liteyuki_weather/data_model.py b/liteyuki/plugins/liteyuki_weather/models.py similarity index 56% rename from liteyuki/plugins/liteyuki_weather/data_model.py rename to liteyuki/plugins/liteyuki_weather/models.py index 2558b96..3937f98 100644 --- a/liteyuki/plugins/liteyuki_weather/data_model.py +++ b/liteyuki/plugins/liteyuki_weather/models.py @@ -1,6 +1,12 @@ from liteyuki.utils.data import LiteModel + +class Location(LiteModel): + name: str = "" + id: str = "" + country: str = "" + class WeatherNow(LiteModel): time: str = "" city: str = ""