2024-12-15 17:08:02 +08:00
|
|
|
from nonebot.adapters.onebot.v11 import MessageEvent
|
|
|
|
|
2024-12-15 02:51:37 +08:00
|
|
|
from nonebot_plugin_marshoai.plugin import (
|
|
|
|
Integer,
|
|
|
|
Parameter,
|
|
|
|
PluginMetadata,
|
|
|
|
String,
|
|
|
|
on_function_call,
|
|
|
|
)
|
2024-12-15 17:08:02 +08:00
|
|
|
from nonebot_plugin_marshoai.plugin.func_call.caller import Caller
|
2024-12-15 02:51:37 +08:00
|
|
|
|
|
|
|
__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:
|
2024-12-15 17:08:02 +08:00
|
|
|
"""使用姓名,年龄,性别进行算命"""
|
2024-12-15 02:51:37 +08:00
|
|
|
|
|
|
|
# 进行一系列算命操作...
|
|
|
|
|
|
|
|
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:
|
2024-12-15 17:08:02 +08:00
|
|
|
"""获取一个地点未来一段时间的天气"""
|
2024-12-15 02:51:37 +08:00
|
|
|
|
|
|
|
# 进行一系列获取天气操作...
|
|
|
|
|
|
|
|
return f"{location}未来{days}天的天气信息..."
|
2024-12-15 17:08:02 +08:00
|
|
|
|
|
|
|
|
|
|
|
@on_function_call(description="获取设备物理地理位置")
|
|
|
|
async def get_location() -> str:
|
|
|
|
"""获取设备物理地理位置"""
|
|
|
|
|
|
|
|
# 进行一系列获取地理位置操作...
|
|
|
|
|
|
|
|
return "日本 东京都 世田谷区"
|
|
|
|
|
|
|
|
|
|
|
|
@on_function_call(description="获取聊天者个人信息")
|
|
|
|
async def get_user_info(e: MessageEvent, c: Caller) -> str:
|
|
|
|
return f"用户信息:{e.user_id} {e.sender.nickname}, {c._parameters}"
|