mirror of
https://github.com/LiteyukiStudio/nonebot-plugin-marshoai.git
synced 2025-08-01 03:59:51 +00:00
✨ 重构函数信息获取逻辑;移除示例测试用例文件
This commit is contained in:
@ -2,7 +2,13 @@ import traceback
|
||||
|
||||
import httpx
|
||||
|
||||
from nonebot_plugin_marshoai.plugin import PluginMetadata, function_call
|
||||
from nonebot_plugin_marshoai.plugin import (
|
||||
Integer,
|
||||
PluginMetadata,
|
||||
String,
|
||||
function_call,
|
||||
on_function_call,
|
||||
)
|
||||
|
||||
__marsho_meta__ = PluginMetadata(
|
||||
name="Bangumi 番剧信息",
|
||||
@ -13,7 +19,9 @@ __marsho_meta__ = PluginMetadata(
|
||||
)
|
||||
|
||||
|
||||
@function_call
|
||||
async def fetch_calendar():
|
||||
"""获取今天日期"""
|
||||
url = "https://api.bgm.tv/calendar"
|
||||
headers = {
|
||||
"User-Agent": "LiteyukiStudio/nonebot-plugin-marshoai (https://github.com/LiteyukiStudio/nonebot-plugin-marshoai)"
|
||||
@ -26,11 +34,7 @@ async def fetch_calendar():
|
||||
|
||||
@function_call
|
||||
async def get_bangumi_news() -> str:
|
||||
"""获取今天的新番(动漫)列表,在调用之前,你需要知道今天星期几。
|
||||
|
||||
Returns:
|
||||
_type_: _description_
|
||||
"""
|
||||
"""获取今天的新番(动漫)列表,在调用之前,你需要知道今天星期几。"""
|
||||
result = await fetch_calendar()
|
||||
info = ""
|
||||
try:
|
||||
|
@ -0,0 +1,57 @@
|
||||
from nonebot_plugin_marshoai.plugin import (
|
||||
Integer,
|
||||
Parameter,
|
||||
PluginMetadata,
|
||||
String,
|
||||
on_function_call,
|
||||
)
|
||||
|
||||
__marsho_meta__ = PluginMetadata(
|
||||
name="SnowyKami 测试插件",
|
||||
description="A test plugin for SnowyKami",
|
||||
usage="SnowyKami Test Plugin",
|
||||
)
|
||||
|
||||
|
||||
@on_function_call(description="使用姓名,年龄,性别进行算命").params(
|
||||
age=Integer(description="年龄"),
|
||||
name=String(description="姓名"),
|
||||
gender=String(enum=["男", "女"], description="性别"),
|
||||
)
|
||||
async def fortune_telling(age: int, name: str, gender: str) -> str:
|
||||
"""使用姓名,年龄,性别进行算命
|
||||
|
||||
Args:
|
||||
age (int): _description_
|
||||
name (str): _description_
|
||||
gender (str): _description_
|
||||
|
||||
Returns:
|
||||
str: _description_
|
||||
"""
|
||||
|
||||
# 进行一系列算命操作...
|
||||
|
||||
return f"{name},你的年龄是{age},你的性别很好"
|
||||
|
||||
|
||||
@on_function_call(description="获取一个地点未来一段时间的天气").params(
|
||||
location=String(description="地点名称,可以是城市名、地区名等"),
|
||||
days=Integer(description="天数", minimum=1, maximum=30),
|
||||
unit=String(enum=["摄氏度", "华氏度"], description="温度单位"),
|
||||
)
|
||||
async def get_weather(location: str, days: int, unit: str) -> str:
|
||||
"""获取一个地点未来一段时间的天气
|
||||
|
||||
Args:
|
||||
location (str): 地点名称,可以是城市名、地区名等
|
||||
days (int): 天数
|
||||
unit (str): 温度单位
|
||||
|
||||
Returns:
|
||||
str: 天气信息
|
||||
"""
|
||||
|
||||
# 进行一系列获取天气操作...
|
||||
|
||||
return f"{location}未来{days}天的天气信息..."
|
Reference in New Issue
Block a user