From 58278fa73570fa043d80b27119b8483bfb616c8c Mon Sep 17 00:00:00 2001 From: snowyServer Date: Thu, 11 Apr 2024 14:41:46 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=8C=E6=AD=A5=E5=A4=A9=E6=B0=94api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_weather/qw_api.py | 0 liteyuki/plugins/liteyuki_weather/qweather.py | 24 +++++++------------ requirements.txt | 1 + 3 files changed, 10 insertions(+), 15 deletions(-) create mode 100644 liteyuki/plugins/liteyuki_weather/qw_api.py diff --git a/liteyuki/plugins/liteyuki_weather/qw_api.py b/liteyuki/plugins/liteyuki_weather/qw_api.py new file mode 100644 index 0000000..e69de29 diff --git a/liteyuki/plugins/liteyuki_weather/qweather.py b/liteyuki/plugins/liteyuki_weather/qweather.py index 715d129..d029ca7 100644 --- a/liteyuki/plugins/liteyuki_weather/qweather.py +++ b/liteyuki/plugins/liteyuki_weather/qweather.py @@ -1,27 +1,21 @@ -import nonebot from nonebot import require +from jieba import lcut -from liteyuki.utils.config import get_config -from liteyuki.utils.ly_typing import T_Bot +from liteyuki.utils.ly_typing import T_MessageEvent require("nonebot_plugin_alconna") -from nonebot_plugin_alconna import on_alconna, Alconna, Args, Arparma, MultiVar +from nonebot_plugin_alconna import on_alconna, Alconna, Subcommand, Args, MultiVar, Arparma @on_alconna( aliases={"天气"}, command=Alconna( "weather", - Args["keywords", MultiVar(str), []], + Args["keywords", MultiVar(str)], ), ).handle() -async def _(bot: T_Bot, result: Arparma): - """ - 天气查询 - Args: - bot: - - Returns: - - """ - print("AAA", result, result.main_args) +async def _(result: Arparma, event: T_MessageEvent): + """await alconna.send("weather", city)""" + print(result["keywords"]) + if len(result["keywords"]) == 0: + pass diff --git a/requirements.txt b/requirements.txt index 59bcee8..00f6d81 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,6 +3,7 @@ aiofiles==23.2.1 colored==2.2.4 dash==2.16.1 GitPython==3.1.42 +jieba==0.42.1 nonebot2[fastapi,httpx,websockets]==2.2.1 nonebot-plugin-htmlrender==0.3.1 nonebot-adapter-onebot==2.4.3