mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-01-26 18:12:47 +08:00
迁移marshoai_basic,优化marshoai_bangumi对于今天星期的获取
This commit is contained in:
parent
738eec9198
commit
4d5af4bc00
@ -1,8 +1,10 @@
|
|||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
|
from zhDateTime import DateTime
|
||||||
|
|
||||||
from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call
|
from nonebot_plugin_marshoai.plugin import PluginMetadata, on_function_call
|
||||||
|
from nonebot_plugin_marshoai.plugin.func_call.params import String
|
||||||
|
|
||||||
# 定义插件元数据
|
# 定义插件元数据
|
||||||
__marsho_meta__ = PluginMetadata(
|
__marsho_meta__ = PluginMetadata(
|
||||||
@ -27,6 +29,18 @@ async def get_bangumi_news() -> str:
|
|||||||
try:
|
try:
|
||||||
result = await fetch_calendar()
|
result = await fetch_calendar()
|
||||||
info = ""
|
info = ""
|
||||||
|
current_weekday = DateTime.now().weekday()
|
||||||
|
weekdays = [
|
||||||
|
"星期一",
|
||||||
|
"星期二",
|
||||||
|
"星期三",
|
||||||
|
"星期四",
|
||||||
|
"星期五",
|
||||||
|
"星期六",
|
||||||
|
"星期日",
|
||||||
|
]
|
||||||
|
current_weekday_name = weekdays[current_weekday]
|
||||||
|
info += f"今天{current_weekday_name}。\n"
|
||||||
for i in result:
|
for i in result:
|
||||||
weekday = i["weekday"]["cn"]
|
weekday = i["weekday"]["cn"]
|
||||||
# print(weekday)
|
# print(weekday)
|
||||||
|
@ -2,17 +2,12 @@ import os
|
|||||||
|
|
||||||
from zhDateTime import DateTime
|
from zhDateTime import DateTime
|
||||||
|
|
||||||
|
from nonebot_plugin_marshoai.plugin import String, on_function_call
|
||||||
async def get_weather(location: str):
|
|
||||||
return f"{location}的温度是114514℃。"
|
|
||||||
|
|
||||||
|
|
||||||
async def get_current_env():
|
@on_function_call(description="获取当前时间,日期和星期")
|
||||||
ver = os.popen("uname -a").read()
|
async def get_current_time() -> str:
|
||||||
return str(ver)
|
"""获取当前的时间和日期"""
|
||||||
|
|
||||||
|
|
||||||
async def get_current_time():
|
|
||||||
current_time = DateTime.now().strftime("%Y.%m.%d %H:%M:%S")
|
current_time = DateTime.now().strftime("%Y.%m.%d %H:%M:%S")
|
||||||
current_weekday = DateTime.now().weekday()
|
current_weekday = DateTime.now().weekday()
|
||||||
|
|
||||||
@ -20,5 +15,5 @@ async def get_current_time():
|
|||||||
current_weekday_name = weekdays[current_weekday]
|
current_weekday_name = weekdays[current_weekday]
|
||||||
|
|
||||||
current_lunar_date = DateTime.now().to_lunar().date_hanzify()[5:]
|
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
|
return time_prompt
|
||||||
|
Loading…
x
Reference in New Issue
Block a user