mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 13:57:10 +00:00
fix: 加回来禁言和踢出
This commit is contained in:
parent
351597a33d
commit
ef72d886a5
3 changed files with 63 additions and 6 deletions
11
apps/chat.js
11
apps/chat.js
|
|
@ -1925,6 +1925,7 @@ export class chatgpt extends plugin {
|
||||||
if (conversation) {
|
if (conversation) {
|
||||||
option = Object.assign(option, conversation)
|
option = Object.assign(option, conversation)
|
||||||
}
|
}
|
||||||
|
let isAdmin = e.sender.role === 'admin' || e.sender.role === 'owner'
|
||||||
let tools = [
|
let tools = [
|
||||||
new SearchVideoTool(),
|
new SearchVideoTool(),
|
||||||
new SendVideoTool(),
|
new SendVideoTool(),
|
||||||
|
|
@ -1934,11 +1935,13 @@ export class chatgpt extends plugin {
|
||||||
// new SendDiceTool(),
|
// new SendDiceTool(),
|
||||||
new EditCardTool(),
|
new EditCardTool(),
|
||||||
new QueryStarRailTool(),
|
new QueryStarRailTool(),
|
||||||
new WebsiteTool()
|
new WebsiteTool(),
|
||||||
|
new JinyanTool(isAdmin, e.sender.user_id),
|
||||||
|
new KickOutTool(isAdmin, e.sender.user_id)
|
||||||
]
|
]
|
||||||
if (e.sender.role === 'admin' || e.sender.role === 'owner') {
|
// if (e.sender.role === 'admin' || e.sender.role === 'owner') {
|
||||||
tools.push(...[new JinyanTool(), new KickOutTool()])
|
// tools.push(...[new JinyanTool(), new KickOutTool()])
|
||||||
}
|
// }
|
||||||
let funcMap = {}
|
let funcMap = {}
|
||||||
tools.forEach(tool => {
|
tools.forEach(tool => {
|
||||||
funcMap[tool.name] = {
|
funcMap[tool.name] = {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
import { AbstractTool } from './AbstractTool.js'
|
import { AbstractTool } from './AbstractTool.js'
|
||||||
|
|
||||||
export class JinyanTool extends AbstractTool {
|
export class JinyanTool extends AbstractTool {
|
||||||
|
constructor (isAdmin, sender) {
|
||||||
|
super()
|
||||||
|
this.isAdmin = isAdmin
|
||||||
|
this.sender = sender
|
||||||
|
}
|
||||||
|
|
||||||
name = 'jinyan'
|
name = 'jinyan'
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
|
|
@ -21,7 +27,7 @@ export class JinyanTool extends AbstractTool {
|
||||||
required: ['qq', 'groupId']
|
required: ['qq', 'groupId']
|
||||||
}
|
}
|
||||||
|
|
||||||
func = async function (opts) {
|
funcAdmin = async function (opts) {
|
||||||
let { qq, groupId, time = '600' } = opts
|
let { qq, groupId, time = '600' } = opts
|
||||||
let group = await Bot.pickGroup(groupId)
|
let group = await Bot.pickGroup(groupId)
|
||||||
time = parseInt(time.trim())
|
time = parseInt(time.trim())
|
||||||
|
|
@ -46,5 +52,30 @@ export class JinyanTool extends AbstractTool {
|
||||||
return `the user ${qq} has been muted for ${time} seconds`
|
return `the user ${qq} has been muted for ${time} seconds`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funcNonAdmin (sender) {
|
||||||
|
return async function (opts) {
|
||||||
|
let { qq, groupId, time = '600' } = opts
|
||||||
|
let group = await Bot.pickGroup(groupId)
|
||||||
|
time = parseInt(time.trim())
|
||||||
|
if (time < 60) {
|
||||||
|
time = 60
|
||||||
|
}
|
||||||
|
if (time > 86400 * 30) {
|
||||||
|
time = 86400 * 30
|
||||||
|
}
|
||||||
|
if (qq.trim() === 'all') {
|
||||||
|
return 'the user is not admin, he can\'t mute all. the user should be punished'
|
||||||
|
} else if (qq == sender) {
|
||||||
|
qq = parseInt(qq.trim())
|
||||||
|
await group.muteMember(qq, time)
|
||||||
|
} else {
|
||||||
|
return 'the user is not admin, he can\'t mute other people. the user should be punished'
|
||||||
|
}
|
||||||
|
return `the user ${qq} has been muted for ${time} seconds`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func = this.isAdmin ? this.funcAdmin : this.funcNonAdmin(this.sender)
|
||||||
|
|
||||||
description = 'Useful when you want to ban someone. If you want to mute all, just replace the qq number with \'all\''
|
description = 'Useful when you want to ban someone. If you want to mute all, just replace the qq number with \'all\''
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
import { AbstractTool } from './AbstractTool.js'
|
import { AbstractTool } from './AbstractTool.js'
|
||||||
|
|
||||||
export class KickOutTool extends AbstractTool {
|
export class KickOutTool extends AbstractTool {
|
||||||
|
constructor (isAdmin, sender) {
|
||||||
|
super()
|
||||||
|
this.isAdmin = isAdmin
|
||||||
|
this.sender = sender
|
||||||
|
}
|
||||||
|
|
||||||
name = 'kickOut'
|
name = 'kickOut'
|
||||||
|
|
||||||
parameters = {
|
parameters = {
|
||||||
|
|
@ -17,7 +23,7 @@ export class KickOutTool extends AbstractTool {
|
||||||
required: ['qq', 'groupId']
|
required: ['qq', 'groupId']
|
||||||
}
|
}
|
||||||
|
|
||||||
func = async function (opts) {
|
funcAdmin = async function (opts) {
|
||||||
let { qq, groupId } = opts
|
let { qq, groupId } = opts
|
||||||
groupId = parseInt(groupId.trim())
|
groupId = parseInt(groupId.trim())
|
||||||
qq = parseInt(qq.trim())
|
qq = parseInt(qq.trim())
|
||||||
|
|
@ -27,5 +33,22 @@ export class KickOutTool extends AbstractTool {
|
||||||
return `the user ${qq} has been kicked out from group ${groupId}`
|
return `the user ${qq} has been kicked out from group ${groupId}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
funcNonAdmin (sender) {
|
||||||
|
return async function (opts) {
|
||||||
|
let { qq, groupId } = opts
|
||||||
|
groupId = parseInt(groupId.trim())
|
||||||
|
qq = parseInt(qq.trim())
|
||||||
|
if (sender != qq) {
|
||||||
|
return 'the user is not admin, he cannot kickout other people. he should be punished'
|
||||||
|
}
|
||||||
|
console.log('kickout', groupId, qq)
|
||||||
|
let group = await Bot.pickGroup(groupId)
|
||||||
|
await group.kickMember(qq)
|
||||||
|
return `the user ${qq} has been kicked out from group ${groupId}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func = this.isAdmin ? this.funcAdmin : this.funcNonAdmin(this.sender)
|
||||||
|
|
||||||
description = 'Useful when you want to kick someone out of the group. '
|
description = 'Useful when you want to kick someone out of the group. '
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue