mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 21:37:11 +00:00
fix: 命令正则;更改为回复消息
This commit is contained in:
parent
09004accc1
commit
d4a0cfc836
1 changed files with 13 additions and 5 deletions
18
index.js
18
index.js
|
|
@ -17,12 +17,14 @@ export class example extends plugin {
|
||||||
rule: [
|
rule: [
|
||||||
{
|
{
|
||||||
/** 命令正则匹配 */
|
/** 命令正则匹配 */
|
||||||
reg: '^#chatgpt.*$',
|
reg: '^#chatgpt([\s\S]*)',
|
||||||
/** 执行方法 */
|
/** 执行方法 */
|
||||||
fnc: 'chatgpt'
|
fnc: 'chatgpt'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
const api = new ChatGPTAPI({ sessionToken: SESSION_TOKEN, markdown: false })
|
||||||
|
this.chatGPTApi = api
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 调用chatgpt接口
|
* 调用chatgpt接口
|
||||||
|
|
@ -31,11 +33,17 @@ export class example extends plugin {
|
||||||
async chatgpt (e) {
|
async chatgpt (e) {
|
||||||
logger.info(e.msg)
|
logger.info(e.msg)
|
||||||
let question = _.trimStart(e.msg, "#chatgpt")
|
let question = _.trimStart(e.msg, "#chatgpt")
|
||||||
|
question = question.trimStart()
|
||||||
logger.info(`chatgpt question: ${question}`)
|
logger.info(`chatgpt question: ${question}`)
|
||||||
const api = new ChatGPTAPI({ sessionToken: SESSION_TOKEN, markdown: false })
|
await this.chatGPTApi.ensureAuth()
|
||||||
await api.ensureAuth()
|
// @todo conversation
|
||||||
const response = await api.sendMessage(question)
|
// const response = await this.chatGPTApi.sendMessage(question, { conversationId: '0c382256-d267-4dd4-90e3-a01dd22c20a2', onProgress: this.onProgress })
|
||||||
|
const response = await this.chatGPTApi.sendMessage(question)
|
||||||
/** 最后回复消息 */
|
/** 最后回复消息 */
|
||||||
await this.reply(`${response}`)
|
await this.reply(`${response}`, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
onProgress(partialResponse) {
|
||||||
|
console.log(partialResponse)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue