From 4d5af4bc0030246fb409a841017c09979a1a2c01 Mon Sep 17 00:00:00 2001 From: Asankilp Date: Tue, 17 Dec 2024 13:25:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BBmarshoai=5Fbasic=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96marshoai=5Fbangumi=E5=AF=B9=E4=BA=8E=E4=BB=8A?= =?UTF-8?q?=E5=A4=A9=E6=98=9F=E6=9C=9F=E7=9A=84=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/marshoai_bangumi/__init__.py | 14 ++++++++++++++ .../plugins/marshoai_basic/__init__.py | 15 +++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py index 9b6c37b2..19891571 100644 --- a/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py +++ b/nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py @@ -1,8 +1,10 @@ import traceback import httpx +from zhDateTime import DateTime from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call +from nonebot_plugin_marshoai.plugin.func_call.params import String # 定义插件元数据 __marsho_meta__ = PluginMetadata( @@ -27,6 +29,18 @@ async def get_bangumi_news() -> str: try: result = await fetch_calendar() info = "" + current_weekday = DateTime.now().weekday() + weekdays = [ + "星期一", + "星期二", + "星期三", + "星期四", + "星期五", + "星期六", + "星期日", + ] + current_weekday_name = weekdays[current_weekday] + info += f"今天{current_weekday_name}。\n" for i in result: weekday = i["weekday"]["cn"] # print(weekday) diff --git a/nonebot_plugin_marshoai/plugins/marshoai_basic/__init__.py b/nonebot_plugin_marshoai/plugins/marshoai_basic/__init__.py index a76a3333..d0e3e3bb 100755 --- a/nonebot_plugin_marshoai/plugins/marshoai_basic/__init__.py +++ b/nonebot_plugin_marshoai/plugins/marshoai_basic/__init__.py @@ -2,17 +2,12 @@ import os from zhDateTime import DateTime - -async def get_weather(location: str): - return f"{location}的温度是114514℃。" +from nonebot_plugin_marshoai.plugin import String, on_function_call -async def get_current_env(): - ver = os.popen("uname -a").read() - return str(ver) - - -async def get_current_time(): +@on_function_call(description="获取当前时间,日期和星期") +async def get_current_time() -> str: + """获取当前的时间和日期""" current_time = DateTime.now().strftime("%Y.%m.%d %H:%M:%S") current_weekday = DateTime.now().weekday() @@ -20,5 +15,5 @@ async def get_current_time(): current_weekday_name = weekdays[current_weekday] current_lunar_date = DateTime.now().to_lunar().date_hanzify()[5:] - time_prompt = f"现在的时间是{current_time},{current_weekday_name},农历{current_lunar_date}。" + time_prompt = f"现在的时间是 {current_time},{current_weekday_name},农历 {current_lunar_date}。" return time_prompt