mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 05:17:10 +00:00
fix: 对接
This commit is contained in:
parent
89ab58b3d7
commit
eee1285e2f
11 changed files with 221 additions and 26 deletions
|
|
@ -21,8 +21,8 @@ export class Chat extends plugin {
|
|||
|
||||
async chat (e) {
|
||||
const state = await Chaite.getInstance().getUserStateStorage().getItem(e.sender.user_id + '')
|
||||
const sendMessageOptions = SendMessageOption.create(state.settings)
|
||||
const preset = await getPreset(e, state.settings.preset, Config.basic.toggleMode, Config.basic.togglePrefix)
|
||||
const sendMessageOptions = SendMessageOption.create(state?.settings)
|
||||
const preset = await getPreset(e, state?.settings.preset || Config.llm.defaultChatPresetId, Config.basic.toggleMode, Config.basic.togglePrefix)
|
||||
if (!preset) {
|
||||
logger.debug('未找到预设,不进入对话')
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import ChatGPTConfig from '../config/config.js'
|
||||
import { createCRUDCommandRules, createSwitchCommandRules } from '../utils/command.js'
|
||||
import { Chaite } from '../../../../../../WebstormProjects/node-chaite/src/index.js'
|
||||
import { Chaite } from 'chaite'
|
||||
import { resolve } from 'eslint-plugin-promise/rules/lib/promise-statics.js'
|
||||
|
||||
export class ChatGPTManagement extends plugin {
|
||||
constructor () {
|
||||
|
|
@ -22,7 +23,19 @@ export class ChatGPTManagement extends plugin {
|
|||
}
|
||||
]
|
||||
})
|
||||
this.rules.push(...[
|
||||
this.initCommand(cmdPrefix)
|
||||
}
|
||||
|
||||
async initCommand (cmdPrefix) {
|
||||
const waitForChaite = async () => {
|
||||
while (!Chaite.getInstance()) {
|
||||
await new Promise(resolve => setTimeout(resolve, 1000))
|
||||
}
|
||||
return Chaite.getInstance()
|
||||
}
|
||||
|
||||
await waitForChaite()
|
||||
this.rule.push(...[
|
||||
...createCRUDCommandRules.bind(this)(cmdPrefix, '渠道', 'channels'),
|
||||
...createCRUDCommandRules.bind(this)(cmdPrefix, '预设', 'presets'),
|
||||
...createCRUDCommandRules.bind(this)(cmdPrefix, '工具', 'tools'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue