import{_ as i,c as a,o as t,ae as n}from"./chunks/framework.AELpvxz7.js";const d=JSON.parse('{"title":"chat","description":"","frontmatter":{"title":"chat","order":100},"headers":[],"relativePath":"en/dev/api/plugins/builtin_tools/chat.md","filePath":"en/dev/api/plugins/builtin_tools/chat.md","lastUpdated":null}'),e={name:"en/dev/api/plugins/builtin_tools/chat.md"};function h(l,s,p,k,r,o){return t(),a("div",null,s[0]||(s[0]=[n(`

Module nonebot_plugin_marshoai.plugins.builtin_tools.chat


@on_function_call(description='获取当前会话信息,比如群聊或用户的身份信息').permission(SUPERUSER)

async func get_session_info(bot: Bot, event: MessageEvent) -> str

Description: 获取当前会话信息,比如群聊或用户的身份信息

Arguments:

Return: str: 会话信息

Source code or View on GitHub
python
@on_function_call(description='获取当前会话信息,比如群聊或用户的身份信息').permission(SUPERUSER)
async def get_session_info(bot: Bot, event: MessageEvent) -> str:
    if isinstance(event, PrivateMessageEvent):
        return f'当前会话为私聊,用户ID: {event.user_id}'
    elif isinstance(event, GroupMessageEvent):
        return f'当前会话为群聊,群组ID: {event.group_id}, 用户ID: {event.user_id}'
    else:
        return '未知会话类型'

@on_function_call(description='发送消息到指定用户').params(user=String(description='用户ID'), message=String(description='消息内容')).permission(SUPERUSER)

async func send_message(user: str, message: str, bot: Bot) -> str

Description: 发送消息到指定用户,实验性功能,仅限onebotv11适配器

Arguments:

Return: str: 发送结果

Source code or View on GitHub
python
@on_function_call(description='发送消息到指定用户').params(user=String(description='用户ID'), message=String(description='消息内容')).permission(SUPERUSER)
async def send_message(user: str, message: str, bot: Bot) -> str:
    try:
        await bot.send_private_msg(user_id=int(user), message=message)
        return '发送成功'
    except FinishedException as e:
        return '发送完成'
    except Exception as e:
        return '发送失败: ' + str(e)

@on_function_call(description='发送消息到指定群组').params(group=String(description='群组ID'), message=String(description='消息内容')).permission(SUPERUSER)

async func send_group_message(group: str, message: str, bot: Bot) -> str

Description: 发送消息到指定群组,实验性功能,仅限onebotv11适配器

Arguments:

Return: str: 发送结果

Source code or View on GitHub
python
@on_function_call(description='发送消息到指定群组').params(group=String(description='群组ID'), message=String(description='消息内容')).permission(SUPERUSER)
async def send_group_message(group: str, message: str, bot: Bot) -> str:
    try:
        await bot.send_group_msg(group_id=int(group), message=message)
        return '发送成功'
    except FinishedException as e:
        return '发送完成'
    except Exception as e:
        return '发送失败: ' + str(e)
`,25)]))}const E=i(e,[["render",h]]);export{d as __pageData,E as default};