mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 22:07:10 +00:00
fix: add default md handler
This commit is contained in:
parent
2320453564
commit
89d1c3e287
2 changed files with 33 additions and 3 deletions
13
apps/chat.js
13
apps/chat.js
|
|
@ -1201,7 +1201,7 @@ export class chatgpt extends plugin {
|
||||||
bingToken: previousConversation.bingToken
|
bingToken: previousConversation.bingToken
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let handler = this.e.runtime?.handler || {}
|
||||||
try {
|
try {
|
||||||
if (Config.debug) {
|
if (Config.debug) {
|
||||||
logger.mark({ conversation })
|
logger.mark({ conversation })
|
||||||
|
|
@ -1396,7 +1396,15 @@ export class chatgpt extends plugin {
|
||||||
if (Config.ttsMode === 'vits-uma-genshin-honkai' && ttsResponse.length > parseInt(Config.ttsAutoFallbackThreshold)) {
|
if (Config.ttsMode === 'vits-uma-genshin-honkai' && ttsResponse.length > parseInt(Config.ttsAutoFallbackThreshold)) {
|
||||||
await this.reply('回复的内容过长,已转为文本模式')
|
await this.reply('回复的内容过长,已转为文本模式')
|
||||||
}
|
}
|
||||||
await this.reply(await convertFaces(response, Config.enableRobotAt, e), e.isGroup)
|
let responseText = await convertFaces(response, Config.enableRobotAt, e)
|
||||||
|
if (handler.has('chatgpt.markdown.convert')) {
|
||||||
|
responseText = await handler.call('chatgpt.markdown.convert', this.e, {
|
||||||
|
content: responseText,
|
||||||
|
use,
|
||||||
|
prompt
|
||||||
|
})
|
||||||
|
}
|
||||||
|
await this.reply(finalResponse, e.isGroup)
|
||||||
if (quotemessage.length > 0) {
|
if (quotemessage.length > 0) {
|
||||||
this.reply(await makeForwardMsg(this.e, quotemessage.map(msg => `${msg.text} - ${msg.url}`)))
|
this.reply(await makeForwardMsg(this.e, quotemessage.map(msg => `${msg.text} - ${msg.url}`)))
|
||||||
}
|
}
|
||||||
|
|
@ -1436,7 +1444,6 @@ export class chatgpt extends plugin {
|
||||||
this.reply('今日对话已达上限')
|
this.reply('今日对话已达上限')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
let handler = this.e.runtime?.handler || {}
|
|
||||||
let responseText = await convertFaces(response, Config.enableRobotAt, e)
|
let responseText = await convertFaces(response, Config.enableRobotAt, e)
|
||||||
if (handler.has('chatgpt.markdown.convert')) {
|
if (handler.has('chatgpt.markdown.convert')) {
|
||||||
responseText = await handler.call('chatgpt.markdown.convert', this.e, {
|
responseText = await handler.call('chatgpt.markdown.convert', this.e, {
|
||||||
|
|
|
||||||
23
apps/md.js
Normal file
23
apps/md.js
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import plugin from '../../../lib/plugins/plugin.js'
|
||||||
|
import cfg from '../../../lib/config/config.js'
|
||||||
|
export class ChatGPTMarkdownHandler extends plugin {
|
||||||
|
constructor () {
|
||||||
|
super({
|
||||||
|
name: 'chatgptmd处理器',
|
||||||
|
priority: -100,
|
||||||
|
namespace: 'chatgpt-plugin',
|
||||||
|
handler: [{
|
||||||
|
key: 'chatgpt.markdown.convert',
|
||||||
|
fn: 'mdHandler'
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async mdHandler (e, options, reject) {
|
||||||
|
if (cfg.bot.global_md) {
|
||||||
|
const { content, prompt, use } = options
|
||||||
|
let md = `> ${prompt}\n\n---\n${content}\n\n---\n*当前模式:${use}*`
|
||||||
|
return md
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue