mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-08-01 03:59:51 +00:00
🎨 Apply black formatting
This commit is contained in:
54
nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py
Executable file
54
nonebot_plugin_marshoai/plugins/marshoai_bangumi/__init__.py
Executable file
@ -0,0 +1,54 @@
|
||||
import traceback
|
||||
|
||||
import httpx
|
||||
|
||||
from nonebot_plugin_marshoai.plugin import PluginMetadata, function_call
|
||||
|
||||
__marsho_meta__ = PluginMetadata(
|
||||
name="Bangumi 番剧信息",
|
||||
description="Bangumi 番剧信息",
|
||||
usage="Bangumi 番剧信息",
|
||||
author="Liteyuki",
|
||||
homepage="",
|
||||
)
|
||||
|
||||
|
||||
async def fetch_calendar():
|
||||
url = "https://api.bgm.tv/calendar"
|
||||
headers = {
|
||||
"User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)"
|
||||
}
|
||||
async with httpx.AsyncClient() as client:
|
||||
response = await client.get(url, headers=headers)
|
||||
# print(response.text)
|
||||
return response.json()
|
||||
|
||||
|
||||
@function_call
|
||||
async def get_bangumi_news() -> str:
|
||||
"""获取今天的新番(动漫)列表,在调用之前,你需要知道今天星期几。
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
result = await fetch_calendar()
|
||||
info = ""
|
||||
try:
|
||||
for i in result:
|
||||
weekday = i["weekday"]["cn"]
|
||||
# print(weekday)
|
||||
info += f"{weekday}:"
|
||||
items = i["items"]
|
||||
for item in items:
|
||||
name = item["name_cn"]
|
||||
info += f"《{name}》"
|
||||
info += "\n"
|
||||
return info
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
return ""
|
||||
|
||||
|
||||
@function_call
|
||||
def test_sync() -> str:
|
||||
return "sync"
|
9
nonebot_plugin_marshoai/plugins/marshoai_bangumi/tools.json
Executable file
9
nonebot_plugin_marshoai/plugins/marshoai_bangumi/tools.json
Executable file
@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "marshoai-bangumi__get_bangumi_news",
|
||||
"description": "获取今天的新番(动漫)列表,在调用之前,你需要知道今天星期几。"
|
||||
}
|
||||
}
|
||||
]
|
24
nonebot_plugin_marshoai/plugins/marshoai_basic/__init__.py
Executable file
24
nonebot_plugin_marshoai/plugins/marshoai_basic/__init__.py
Executable file
@ -0,0 +1,24 @@
|
||||
import os
|
||||
|
||||
from zhDateTime import DateTime
|
||||
|
||||
|
||||
async def get_weather(location: str):
|
||||
return f"{location}的温度是114514℃。"
|
||||
|
||||
|
||||
async def get_current_env():
|
||||
ver = os.popen("uname -a").read()
|
||||
return str(ver)
|
||||
|
||||
|
||||
async def get_current_time():
|
||||
current_time = DateTime.now().strftime("%Y.%m.%d %H:%M:%S")
|
||||
current_weekday = DateTime.now().weekday()
|
||||
|
||||
weekdays = ["星期一", "星期二", "星期三", "星期四", "星期五", "星期六", "星期日"]
|
||||
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}。"
|
||||
return time_prompt
|
9
nonebot_plugin_marshoai/plugins/marshoai_basic/tools.json
Executable file
9
nonebot_plugin_marshoai/plugins/marshoai_basic/tools.json
Executable file
@ -0,0 +1,9 @@
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "marshoai-basic__get_current_time",
|
||||
"description": "获取现在的日期,时间和星期。"
|
||||
}
|
||||
}
|
||||
]
|
39
nonebot_plugin_marshoai/plugins/marshoai_basic/tools_test.json
Executable file
39
nonebot_plugin_marshoai/plugins/marshoai_basic/tools_test.json
Executable file
@ -0,0 +1,39 @@
|
||||
[
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "marshoai-basic__get_weather",
|
||||
"description": "当你想查询指定城市的天气时非常有用。",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {
|
||||
"type": "string",
|
||||
"description": "城市或县区,比如北京市、杭州市、余杭区等。"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"location"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "marshoai-basic__get_current_env",
|
||||
"description": "获取当前的运行环境。",
|
||||
"parameters": {
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "marshoai-basic__get_current_time",
|
||||
"description": "获取现在的时间。",
|
||||
"parameters": {
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user