Files
konabot/konabot/plugins/weather/__init__.py
2025-09-28 00:15:16 +08:00

17 lines
609 B
Python

from nonebot_plugin_alconna import Alconna, Args, Field, UniMessage, on_alconna
from konabot.plugins.weather.fetcher import fetch_radar
evt = on_alconna(Alconna(
"!雷达回波",
Args["region", str, Field(missing_tips=lambda: "请输入需要获取的地区,例如 !雷达回波 华南")],
), use_cmd_start=False, use_cmd_sep=False, skip_for_unmatch=False)
@evt.handle()
async def _(region: str):
img, err = await fetch_radar(region)
if err != None:
await evt.send(await UniMessage().text(err).export())
return
await evt.send(await UniMessage.image(raw=img).export())