mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 权限和角色问题导致的工具调用失败
This commit is contained in:
parent
0ac70a325f
commit
4dc5d6fe77
3 changed files with 13 additions and 4 deletions
|
|
@ -2055,6 +2055,9 @@ export class chatgpt extends plugin {
|
||||||
debug: Config.debug
|
debug: Config.debug
|
||||||
})
|
})
|
||||||
if (Config.smartMode) {
|
if (Config.smartMode) {
|
||||||
|
/**
|
||||||
|
* @type {AbstractTool[]}
|
||||||
|
*/
|
||||||
let tools = [
|
let tools = [
|
||||||
new QueryStarRailTool(),
|
new QueryStarRailTool(),
|
||||||
new WebsiteTool(),
|
new WebsiteTool(),
|
||||||
|
|
@ -2081,12 +2084,13 @@ export class chatgpt extends plugin {
|
||||||
}
|
}
|
||||||
if (e.isGroup) {
|
if (e.isGroup) {
|
||||||
tools.push(new QueryUserinfoTool())
|
tools.push(new QueryUserinfoTool())
|
||||||
if (e.member?.is_admin) {
|
// let self = e.group.pickMember(e.self_id)
|
||||||
|
if (e.group.is_admin || e.group.is_owner) {
|
||||||
tools.push(new EditCardTool())
|
tools.push(new EditCardTool())
|
||||||
tools.push(new JinyanTool())
|
tools.push(new JinyanTool())
|
||||||
tools.push(new KickOutTool())
|
tools.push(new KickOutTool())
|
||||||
}
|
}
|
||||||
if (e.member.is_owner) {
|
if (e.group.is_owner) {
|
||||||
tools.push(new SetTitleTool())
|
tools.push(new SetTitleTool())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -199,7 +199,12 @@ export class CustomGoogleGeminiClient extends GoogleGeminiClient {
|
||||||
} else {
|
} else {
|
||||||
// execute function
|
// execute function
|
||||||
try {
|
try {
|
||||||
functionResponse.response.content = await chosenTool.func(functionCall.args, this.e)
|
let args = Object.assign(functionCall.args, {
|
||||||
|
isAdmin: this.e.group.is_admin,
|
||||||
|
isOwner: this.e.group.is_owner,
|
||||||
|
sender: this.e.sender
|
||||||
|
})
|
||||||
|
functionResponse.response.content = await chosenTool.func(args, this.e)
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
logger.info(JSON.stringify(functionResponse.response.content))
|
logger.info(JSON.stringify(functionResponse.response.content))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ export class SetTitleTool extends AbstractTool {
|
||||||
return `failed, the user ${qq} is not in group ${groupId}`
|
return `failed, the user ${qq} is not in group ${groupId}`
|
||||||
}
|
}
|
||||||
if (mm.get(e.bot.uin).role !== 'owner') {
|
if (mm.get(e.bot.uin).role !== 'owner') {
|
||||||
return 'on group owner can give title'
|
return 'failed, only group owner can give title'
|
||||||
}
|
}
|
||||||
logger.info('edit card: ', groupId, qq)
|
logger.info('edit card: ', groupId, qq)
|
||||||
let result = await group.setTitle(qq, title)
|
let result = await group.setTitle(qq, title)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue