mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 05:17:10 +00:00
fix: WIP
This commit is contained in:
parent
116479e34e
commit
54806ee6fb
6 changed files with 265 additions and 15 deletions
41
apps/chat.js
41
apps/chat.js
|
|
@ -1,9 +1,9 @@
|
|||
import Config from '../config/config.js'
|
||||
import { Chaite, SendMessageOption } from 'chaite'
|
||||
import { getPreset, intoUserMessage } from '../utils/message.js'
|
||||
|
||||
export class Chat extends plugin {
|
||||
constructor () {
|
||||
let toggleMode = Config.basic.toggleMode
|
||||
let prefix = Config.basic.togglePrefix
|
||||
super({
|
||||
name: 'ChatGPT-Plugin对话',
|
||||
dsc: 'ChatGPT-Plugin对话',
|
||||
|
|
@ -11,24 +11,39 @@ export class Chat extends plugin {
|
|||
priority: 0,
|
||||
rule: [
|
||||
{
|
||||
reg: toggleMode === 'at' ? '^[^#][sS]*' : `^#?(图片)?${prefix}[^gpt][sS]*`,
|
||||
fnc: 'chat'
|
||||
reg: '^[^#][sS]*',
|
||||
fnc: 'chat',
|
||||
log: false
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
async chat (e) {
|
||||
|
||||
const state = await Chaite.getInstance().getUserStateStorage().getItem(e.sender.user_id + '')
|
||||
const userSettings = state.settings
|
||||
const sendMessageOptions = SendMessageOption.create({
|
||||
model: userSettings.model,
|
||||
temperature: userSettings.temperature,
|
||||
max_tokens: userSettings.maxToken,
|
||||
systemOverride: userSettings.systemOverride,
|
||||
|
||||
const sendMessageOptions = SendMessageOption.create(state.settings)
|
||||
const preset = await getPreset(e, state.settings.preset, Config.basic.toggleMode, Config.basic.togglePrefix)
|
||||
if (!preset) {
|
||||
logger.debug('未找到预设,不进入对话')
|
||||
return false
|
||||
}
|
||||
const userMessage = await intoUserMessage(e, {
|
||||
handleReplyText: false,
|
||||
handleReplyImage: true,
|
||||
useRawMessage: false,
|
||||
handleAtMsg: true,
|
||||
excludeAtBot: false,
|
||||
toggleMode: Config.basic.toggleMode,
|
||||
togglePrefix: Config.basic.togglePrefix
|
||||
})
|
||||
Chaite.getInstance().sendMessage(msg, e, )
|
||||
const response = await Chaite.getInstance().sendMessage(userMessage, e, {
|
||||
...sendMessageOptions,
|
||||
chatPreset: preset
|
||||
})
|
||||
const responseText = response.contents
|
||||
.filter(c => c.type === 'text')
|
||||
.map(c => (/** @type {import('chaite').TextContent} **/ c).text)
|
||||
.reduce((a, b) => a + b, '')
|
||||
await this.reply(responseText)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
39
apps/management.js
Normal file
39
apps/management.js
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import ChatGPTConfig from '../config/config.js'
|
||||
import { createCRUDCommandRules, createSwitchCommandRules } from '../utils/command.js'
|
||||
|
||||
export class ChatGPTManagement extends plugin {
|
||||
constructor () {
|
||||
const cmdPrefix = ChatGPTConfig.basic.commandPrefix
|
||||
super({
|
||||
name: 'ChatGPT-Plugin管理',
|
||||
dsc: 'ChatGPT-Plugin管理',
|
||||
event: 'message',
|
||||
priority: 20,
|
||||
rule: [
|
||||
{
|
||||
reg: `^${cmdPrefix}管理面板$`,
|
||||
fnc: 'managementPanel',
|
||||
permission: 'master'
|
||||
},
|
||||
{
|
||||
reg: `^${cmdPrefix}结束(全部)?对话$`,
|
||||
fnc: 'destroyConversation'
|
||||
},
|
||||
...createCRUDCommandRules(cmdPrefix, '渠道', 'channels'),
|
||||
...createCRUDCommandRules(cmdPrefix, '预设', 'presets'),
|
||||
...createCRUDCommandRules(cmdPrefix, '工具', 'tools'),
|
||||
...createCRUDCommandRules(cmdPrefix, '处理器', 'processors'),
|
||||
createSwitchCommandRules(cmdPrefix, '(预设切换|其他人切换预设)', 'customPreset', 1),
|
||||
createSwitchCommandRules(cmdPrefix, '(调试|debug)(模式)?', 'debug'),
|
||||
...createCRUDCommandRules(cmdPrefix, '预设切换黑名单', 'blackCustomPreset', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '预设切换白名单', 'whiteCustomPreset', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '输入屏蔽词', 'blackPromptWords', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '输出屏蔽词', 'blackResponseWords', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '黑名单群', 'blackGroups', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '白名单群', 'whiteGroups', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '黑名单用户', 'blackUsers', false),
|
||||
...createCRUDCommandRules(cmdPrefix, '白名单用户', 'whiteUsers', false)
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue