fix: 优化连续对话逻辑

This commit is contained in:
Mio Kurumio 2025-03-03 12:47:53 +08:00
parent b2b3d7b6c5
commit da22a94259

View file

@ -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)
}
}