From 8667706377e8271e2ac9e96b86a164629e87ade4 Mon Sep 17 00:00:00 2001 From: Expliyh Date: Mon, 20 May 2024 08:20:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20alc=20=E5=8F=91?= =?UTF-8?q?=E9=80=81=E4=BE=8B=E5=A6=82=20=E5=A4=A9=E6=B0=94=E6=AD=A6?= =?UTF-8?q?=E6=B1=89=20=E7=9A=84=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_weather/qweather.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/liteyuki/plugins/liteyuki_weather/qweather.py b/liteyuki/plugins/liteyuki_weather/qweather.py index 77490635..6f13f6d3 100644 --- a/liteyuki/plugins/liteyuki_weather/qweather.py +++ b/liteyuki/plugins/liteyuki_weather/qweather.py @@ -14,30 +14,30 @@ from liteyuki.utils.message.html_tool import template2image from liteyuki.utils import event as event_utils require("nonebot_plugin_alconna") -from nonebot_plugin_alconna import on_alconna, Alconna, Args, MultiVar, Arparma +from nonebot_plugin_alconna import on_alconna, Alconna, Args, MultiVar, Arparma, UniMessage - -@on_alconna( +wrx_alc = on_alconna( aliases={"天气"}, command=Alconna( "weather", Args["keywords", MultiVar(str), []], ), -).handle() +) + + +@wrx_alc.handle() async def _(result: Arparma, event: T_MessageEvent, matcher: Matcher): """await alconna.send("weather", city)""" kws = result.main_args.get("keywords") image = await get_weather_now_card(matcher, event, kws) - if isinstance(event, satori.event.Event): - await matcher.finish(satori.MessageSegment.image(raw=image, mime="image/png")) - else: - await matcher.finish(MessageSegment.image(image)) + await wrx_alc.finish(UniMessage.image(raw=image)) @on_endswith(("天气", "weather")).handle() async def _(event: T_MessageEvent, matcher: Matcher): """await alconna.send("weather", city)""" - kws = event.message.extract_plain_text() + # kws = event.message.extract_plain_text() + kws = event.get_plaintext() image = await get_weather_now_card(matcher, event, [kws.replace("天气", "").replace("weather", "")], False) await matcher.finish(MessageSegment.image(image)) From c5f8fbe86db0fd9488aa46c90e9c4f641d946d56 Mon Sep 17 00:00:00 2001 From: Expliyh Date: Mon, 20 May 2024 08:22:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?:bug:=20=E5=9C=A8=E4=BD=BF=E7=94=A8=20sator?= =?UTF-8?q?i=20=E9=80=82=E9=85=8D=E5=99=A8=E6=97=B6=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E4=BE=8B=E5=A6=82=20=E6=AD=A6=E6=B1=89?= =?UTF-8?q?=E5=A4=A9=E6=B0=94=20=E7=9A=84=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_weather/qweather.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/liteyuki/plugins/liteyuki_weather/qweather.py b/liteyuki/plugins/liteyuki_weather/qweather.py index 6f13f6d3..08e6df6c 100644 --- a/liteyuki/plugins/liteyuki_weather/qweather.py +++ b/liteyuki/plugins/liteyuki_weather/qweather.py @@ -39,7 +39,10 @@ async def _(event: T_MessageEvent, matcher: Matcher): # kws = event.message.extract_plain_text() kws = event.get_plaintext() image = await get_weather_now_card(matcher, event, [kws.replace("天气", "").replace("weather", "")], False) - await matcher.finish(MessageSegment.image(image)) + if isinstance(event, satori.event.Event): + await matcher.finish(satori.MessageSegment.image(raw=image, mime="image/png")) + else: + await matcher.finish(MessageSegment.image(image)) async def get_weather_now_card(matcher: Matcher, event: T_MessageEvent, keyword: list[str], tip: bool = True): From e13464cb7c369d3c45374a11e13854894c70e632 Mon Sep 17 00:00:00 2001 From: Expliyh Date: Mon, 20 May 2024 08:51:21 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8B=BC=E5=86=99=E9=94=99=E4=BA=86(?= =?UTF-8?q?=E5=B0=B4=E5=B0=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_weather/qweather.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/liteyuki/plugins/liteyuki_weather/qweather.py b/liteyuki/plugins/liteyuki_weather/qweather.py index 08e6df6c..9b158b9e 100644 --- a/liteyuki/plugins/liteyuki_weather/qweather.py +++ b/liteyuki/plugins/liteyuki_weather/qweather.py @@ -16,7 +16,7 @@ from liteyuki.utils import event as event_utils require("nonebot_plugin_alconna") from nonebot_plugin_alconna import on_alconna, Alconna, Args, MultiVar, Arparma, UniMessage -wrx_alc = on_alconna( +wx_alc = on_alconna( aliases={"天气"}, command=Alconna( "weather", @@ -25,12 +25,12 @@ wrx_alc = on_alconna( ) -@wrx_alc.handle() +@wx_alc.handle() async def _(result: Arparma, event: T_MessageEvent, matcher: Matcher): """await alconna.send("weather", city)""" kws = result.main_args.get("keywords") image = await get_weather_now_card(matcher, event, kws) - await wrx_alc.finish(UniMessage.image(raw=image)) + await wx_alc.finish(UniMessage.image(raw=image)) @on_endswith(("天气", "weather")).handle()