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
|
|
@ -1,6 +1,12 @@
|
|||
import { AbstractTool } from './AbstractTool.js'
|
||||
|
||||
export class JinyanTool extends AbstractTool {
|
||||
constructor (isAdmin, sender) {
|
||||
super()
|
||||
this.isAdmin = isAdmin
|
||||
this.sender = sender
|
||||
}
|
||||
|
||||
name = 'jinyan'
|
||||
|
||||
parameters = {
|
||||
|
|
@ -21,7 +27,7 @@ export class JinyanTool extends AbstractTool {
|
|||
required: ['qq', 'groupId']
|
||||
}
|
||||
|
||||
func = async function (opts) {
|
||||
funcAdmin = async function (opts) {
|
||||
let { qq, groupId, time = '600' } = opts
|
||||
let group = await Bot.pickGroup(groupId)
|
||||
time = parseInt(time.trim())
|
||||
|
|
@ -46,5 +52,30 @@ export class JinyanTool extends AbstractTool {
|
|||
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\''
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
import { AbstractTool } from './AbstractTool.js'
|
||||
|
||||
export class KickOutTool extends AbstractTool {
|
||||
constructor (isAdmin, sender) {
|
||||
super()
|
||||
this.isAdmin = isAdmin
|
||||
this.sender = sender
|
||||
}
|
||||
|
||||
name = 'kickOut'
|
||||
|
||||
parameters = {
|
||||
|
|
@ -17,7 +23,7 @@ export class KickOutTool extends AbstractTool {
|
|||
required: ['qq', 'groupId']
|
||||
}
|
||||
|
||||
func = async function (opts) {
|
||||
funcAdmin = async function (opts) {
|
||||
let { qq, groupId } = opts
|
||||
groupId = parseInt(groupId.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}`
|
||||
}
|
||||
|
||||
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. '
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue