mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
fix: 优化连续对话逻辑
This commit is contained in:
parent
b2b3d7b6c5
commit
da22a94259
1 changed files with 14 additions and 13 deletions
23
apps/bym.js
23
apps/bym.js
|
|
@ -6,7 +6,7 @@ import core, { roleMap } from '../model/core.js'
|
|||
import { formatDate } from '../utils/common.js'
|
||||
|
||||
export class bym extends plugin {
|
||||
constructor () {
|
||||
constructor() {
|
||||
super({
|
||||
name: 'ChatGPT-Plugin 伪人bym',
|
||||
dsc: 'bym',
|
||||
|
|
@ -25,7 +25,7 @@ export class bym extends plugin {
|
|||
}
|
||||
|
||||
/** 复读 */
|
||||
async bym (e) {
|
||||
async bym(e) {
|
||||
if (!Config.enableBYM) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -51,17 +51,13 @@ export class bym extends plugin {
|
|||
|
||||
async _handleReply(e) {
|
||||
|
||||
if(Config.bymContinue){
|
||||
const delay = Config.bymContinueDelay || 10
|
||||
this.setContext("_handleContinue", false, delay, "")
|
||||
}
|
||||
|
||||
let sender = e.sender.user_id
|
||||
let card = e.sender.card || e.sender.nickname
|
||||
let group = e.group_id
|
||||
|
||||
let fuck = false
|
||||
let candidate = Config.bymPreset
|
||||
let delay = Config.bymContinueDelay || 10
|
||||
if (Config.bymFuckList?.find(i => e.msg?.includes(i))) {
|
||||
fuck = true
|
||||
candidate = candidate + Config.bymFuckPrompt
|
||||
|
|
@ -107,14 +103,19 @@ export class bym extends plugin {
|
|||
logger.info(JSON.stringify(finalMsg))
|
||||
finalMsg = finalMsg.map(filterResponseChunk).filter(i => !!i)
|
||||
if (finalMsg && finalMsg.length > 0) {
|
||||
if(index !== 0) await new Promise((resolve) => {
|
||||
if (index !== 0) await new Promise((resolve) => {
|
||||
setTimeout(() => {
|
||||
resolve()
|
||||
}, Math.min(t.length * 200, 3000))
|
||||
})
|
||||
await this.reply(finalMsg, (this._genProp() < 10) , {
|
||||
await this.reply(finalMsg, (this._genProp() < 10), {
|
||||
recallMsg: fuck ? 10 : 0
|
||||
})
|
||||
|
||||
if (Config.bymContinue) {
|
||||
this.finish("_handleContinue", false)
|
||||
this.setContext("_handleContinue", false, delay, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,8 +127,8 @@ export class bym extends plugin {
|
|||
}
|
||||
|
||||
async _handleContinue(e) {
|
||||
logger.mark("bym继续对话")
|
||||
this.finish("_handleContinue", e.isGroup)
|
||||
logger.mark("bym continue")
|
||||
this.finish("_handleContinue", false)
|
||||
await this._handleReply(e)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue