mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
feat: 一些小工具
This commit is contained in:
parent
c99af43571
commit
ca28b00679
3 changed files with 113 additions and 9 deletions
42
utils/tools/HandleMessageMsgTool.js
Normal file
42
utils/tools/HandleMessageMsgTool.js
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { AbstractTool } from './AbstractTool.js'
|
||||
|
||||
export class HandleMessageMsgTool extends AbstractTool {
|
||||
name = 'handleMsg'
|
||||
|
||||
parameters = {
|
||||
properties: {
|
||||
type: {
|
||||
type: 'string',
|
||||
enum: ['recall', 'essence'],
|
||||
description: 'what do you want to do with the message'
|
||||
},
|
||||
messageId: {
|
||||
type: 'string',
|
||||
description: 'which message, current one by default'
|
||||
}
|
||||
},
|
||||
required: ['type']
|
||||
}
|
||||
|
||||
func = async function (opts, e) {
|
||||
let { type = 'recall', messageId = e.message_id } = opts
|
||||
try {
|
||||
switch (type) {
|
||||
case 'recall': {
|
||||
await e.group.recallMsg(messageId)
|
||||
break
|
||||
}
|
||||
case 'essence': {
|
||||
await Bot.setEssenceMessage(messageId)
|
||||
break
|
||||
}
|
||||
}
|
||||
return 'success!'
|
||||
} catch (err) {
|
||||
logger.error(err)
|
||||
return 'operation failed: ' + err.message
|
||||
}
|
||||
}
|
||||
|
||||
description = '用来撤回消息或将消息设为精华'
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue