chatgpt-plugin/utils/tools/SendPictureTool.js
2023-06-23 01:09:12 +08:00

33 lines
No EOL
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import {AbstractTool} from "./AbstractTool.js";
export class SendPictureTool extends AbstractTool {
name = 'sendPicture'
parameters = {
picture: {
type: 'string',
description: '图片的url,多个用空格隔开'
},
groupId: {
type: 'string',
description: '群号或qq号发送目标'
},
required: ['picture', 'groupId']
}
func = async function (picture, groupId) {
let pictures = picture.trim().split(' ')
pictures = pictures.map(img => segment.image(img))
let groupList = await Bot.getGroupList()
if (groupList.get(groupId)) {
let group = await Bot.pickGroup(groupId)
await group.sendMsg(pictures)
} else {
let user = await Bot.pickFriend(groupId)
await user.sendMsg(pictures)
}
}
description = 'Useful when you want to send some pictures. The input to this tool should be the url of the pictures and the group number or the user\'s qq number, each url and the group number or qq number should be concated with a space, and the group number or qq number should be the last. 如果是在群聊中,优先选择群号发送。'
}