mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
feat: 一些小工具
This commit is contained in:
parent
c99af43571
commit
ca28b00679
3 changed files with 113 additions and 9 deletions
47
utils/tools/QueryUserinfoTool.js
Normal file
47
utils/tools/QueryUserinfoTool.js
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import { AbstractTool } from './AbstractTool.js'
|
||||
import { getMasterQQ } from '../common.js'
|
||||
|
||||
export class QueryUserinfoTool extends AbstractTool {
|
||||
name = 'sendDice'
|
||||
|
||||
parameters = {
|
||||
properties: {
|
||||
qq: {
|
||||
type: 'string',
|
||||
description: 'user\'s qq number, the one you are talking to by default'
|
||||
}
|
||||
},
|
||||
required: []
|
||||
}
|
||||
|
||||
func = async function (opts, e) {
|
||||
let { qq } = opts
|
||||
if (e.is_group && typeof e.group.getMemberMap === 'function') {
|
||||
let mm = e.group.getMemberMap()
|
||||
let user = mm.get(parseInt(qq) || e.sender.user_id)
|
||||
let master = (await getMasterQQ())[0]
|
||||
let prefix = ''
|
||||
if (qq != master) {
|
||||
prefix = 'Attention: this user is not your master. \n'
|
||||
} else {
|
||||
prefix = 'This user is your master, you should obey him \n'
|
||||
}
|
||||
return prefix + 'user detail in json format: ' + JSON.stringify(user)
|
||||
} else {
|
||||
if (e.sender.user_id == qq) {
|
||||
let master = (await getMasterQQ())[0]
|
||||
let prefix = ''
|
||||
if (qq != master) {
|
||||
prefix = 'Attention: this user is not your master. \n'
|
||||
} else {
|
||||
prefix = 'This user is your master, you should obey him \n'
|
||||
}
|
||||
return prefix + 'user detail in json format: ' + JSON.stringify(e.sender)
|
||||
} else {
|
||||
return 'query failed'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
description = 'Useful if you want to find out who he is'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue