Skip to content

Commit

Permalink
feat: 支持天气
Browse files Browse the repository at this point in the history
  • Loading branch information
snowykami committed Apr 1, 2024
1 parent 6a03003 commit 19308ff
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion liteyuki/liteyuki_main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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(
Expand Down
16 changes: 16 additions & 0 deletions liteyuki/liteyuki_main/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
permission=SUPERUSER
)

switch_image_mode = on_alconna(
aliases={"切换图片模式"},
command=Alconna(
"switch-image-mode"
),
permission=SUPERUSER
)


@cmd_liteyuki.handle()
async def _(bot: T_Bot):
Expand Down Expand Up @@ -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()
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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 = ""
Expand Down

0 comments on commit 19308ff

Please sign in to comment.