feat: 支持天气

This commit is contained in:
远野千束 2024-04-01 11:37:29 +08:00
parent 6a03003d41
commit 19308ffc53
4 changed files with 23 additions and 1 deletions

View File

@ -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(

View File

@ -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()

View File

@ -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 = ""