mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
feat: give title
This commit is contained in:
parent
8a531bf551
commit
9be8b54faf
3 changed files with 62 additions and 10 deletions
47
utils/tools/SetTitleTool.js
Normal file
47
utils/tools/SetTitleTool.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { AbstractTool } from './AbstractTool.js'
|
||||
|
||||
export class SetTitleTool extends AbstractTool {
|
||||
name = 'setTitle'
|
||||
|
||||
parameters = {
|
||||
properties: {
|
||||
qq: {
|
||||
type: 'string',
|
||||
description: '你想给予群头衔的那个人的qq号,默认为聊天对象'
|
||||
},
|
||||
title: {
|
||||
type: 'string',
|
||||
description: '群头衔'
|
||||
},
|
||||
groupId: {
|
||||
type: 'string',
|
||||
description: 'group number'
|
||||
}
|
||||
},
|
||||
required: ['title', 'groupId']
|
||||
}
|
||||
|
||||
description = 'Useful when you want to give someone a title in the group(群头衔)'
|
||||
|
||||
func = async function (opts, e) {
|
||||
let { qq, title, groupId } = opts
|
||||
qq = isNaN(qq) || !qq ? e.sender.user_id : parseInt(qq.trim())
|
||||
groupId = isNaN(groupId) || !groupId ? e.group_id : parseInt(groupId.trim())
|
||||
|
||||
let group = await Bot.pickGroup(groupId)
|
||||
let mm = await group.getMemberMap()
|
||||
if (!mm.has(qq)) {
|
||||
return `failed, the user ${qq} is not in group ${groupId}`
|
||||
}
|
||||
if (mm.get(Bot.uin).role !== 'owner') {
|
||||
return 'on group owner can give title'
|
||||
}
|
||||
logger.info('edit card: ', groupId, qq)
|
||||
let result = await group.setTitle(qq, title)
|
||||
if (result) {
|
||||
return `the user ${qq}'s title has been changed into ${title}`
|
||||
} else {
|
||||
return 'failed'
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue