diff --git a/apps/button.js b/apps/button.js index dfbf0ec..4ccc5c1 100644 --- a/apps/button.js +++ b/apps/button.js @@ -1,4 +1,5 @@ import plugin from '../../../lib/plugins/plugin.js' +import {Config} from "../utils/config.js"; const PLUGIN_CHAT = 'ChatGpt 对话' const PLUGIN_MANAGEMENT = 'ChatGPT-Plugin 管理' @@ -52,8 +53,8 @@ export class ChatGPTButtonHandler extends plugin { } async btnHandler (e, options, reject) { - logger.mark('[chatgpt按钮处理器]') - if (e.adapter !== 'shamrock' && (!segment.button || segment.button(1)?.content !== 1)) { + // logger.mark('[chatgpt按钮处理器]') + if (!Config.enableMd || (e.adapter !== 'shamrock' && (!segment.button || segment.button(1)?.content !== 1))) { return null } const fnc = e.logFnc @@ -192,8 +193,8 @@ export class ChatGPTButtonHandler extends plugin { { buttons: [ createButtonBase('恢复本群回复', '#chatgpt本群张嘴', false), - createButtonBase('开启上下文', '#chatgpt打开上下文'), - createButtonBase('关闭上下文 ', '#chatgpt关闭上下文') + createButtonBase('开启上下文', '#打开群聊上下文'), + createButtonBase('关闭上下文 ', '#关闭群聊上下文') ] }, diff --git a/apps/chat.js b/apps/chat.js index 38aa23d..4a35a8b 100644 --- a/apps/chat.js +++ b/apps/chat.js @@ -173,7 +173,7 @@ export class chatgpt extends plugin { }, { /** 命令正则匹配 */ - reg: '^#claude2[sS]*', + reg: '^#claude(2|3|.ai)[sS]*', /** 执行方法 */ fnc: 'claude2' }, @@ -907,7 +907,7 @@ export class chatgpt extends plugin { * #chatgpt */ async chatgpt (e) { - let msg = (Version.isTrss || e.adapter === 'shamrock') ? e.msg : e.raw_message + let msg = e.msg let prompt if (this.toggleMode === 'at') { if (!msg || e.msg?.startsWith('#')) { @@ -959,7 +959,7 @@ export class chatgpt extends plugin { } return false } - prompt = _.replace(e.raw_message.trimStart(), '#chat', '').trim() + prompt = _.replace(e.msg.trimStart(), '#chat', '').trim() if (prompt.length === 0) { return false } @@ -1506,7 +1506,7 @@ export class chatgpt extends plugin { } async claude2 (e) { - return await this.otherMode(e, 'claude2') + return await this.otherMode(e, 'claude2', /^#claude(2|3|.ai)/) } async claude (e) { @@ -2798,6 +2798,13 @@ export class chatgpt extends plugin { return await this.chatGPTApi.sendMessage(prompt, sendMessageOption) } + /** + * 其他模式 + * @param e + * @param mode + * @param {string|RegExp} pattern + * @returns {Promise} + */ async otherMode (e, mode, pattern = `#${mode}`) { if (!Config.allowOtherMode) { return false @@ -2809,7 +2816,7 @@ export class chatgpt extends plugin { } return false } - let prompt = _.replace(e.raw_message.trimStart(), pattern, '').trim() + let prompt = _.replace(e.msg.trimStart(), pattern, '').trim() if (prompt.length === 0) { return false } diff --git a/apps/md.js b/apps/md.js index 142da97..fcedcda 100644 --- a/apps/md.js +++ b/apps/md.js @@ -1,5 +1,6 @@ import plugin from '../../../lib/plugins/plugin.js' -import cfg from '../../../lib/config/config.js' +import {Config} from '../utils/config.js' + export class ChatGPTMarkdownHandler extends plugin { constructor () { super({ @@ -15,11 +16,25 @@ export class ChatGPTMarkdownHandler extends plugin { async mdHandler (e, options, reject) { const { content, prompt, use } = options - if (cfg.bot.global_md || e.adapter === 'shamrock') { - let md = `> ${prompt}\n\n---\n${content}\n\n---\n*当前模式:${use}*` - return md + if (Config.enableMd && (e.adapter === 'shamrock')) { + let mode = transUse(use) + return `> ${prompt}\n\n---\n${content}\n\n---\n*当前模式:${mode}*` } else { return content } } } + +function transUse (use) { + let useMap = { + api: Config.model, + bing: '必应(Copilot)', + gemini: Config.geminiModel, + xh: '讯飞星火', + qwen: '同义千问', + claude2: 'Claude 3 Sonnet', + glm4: 'ChatGLM4', + chat3: 'ChatGPT官网' + } + return useMap[use] || use +} diff --git a/guoba.support.js b/guoba.support.js index 9115d88..683c636 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -57,6 +57,12 @@ export function supportGuoba () { bottomHelpMessage: '将输出更多调试信息,如果不希望控制台刷屏的话,可以关闭', component: 'Switch' }, + { + field: 'enableMd', + label: 'QQ开启markdown', + bottomHelpMessage: 'qq的第三方md,非QQBot。需要适配器实现segment.markdown和segment.button方可使用,否则不建议开启,会造成各种错误。默认关闭', + component: 'Switch' + }, { field: 'translateSource', label: '翻译来源', diff --git a/utils/claude.ai/index.js b/utils/claude.ai/index.js index 4eeb663..a397aba 100644 --- a/utils/claude.ai/index.js +++ b/utils/claude.ai/index.js @@ -132,7 +132,8 @@ export class ClaudeAIClient { let body = { attachments, files: [], - model: 'claude-2.1', + // 官方更新后这里没有传值了 + // model: 'claude-2.1', prompt: text, timezone: 'Asia/Hong_Kong' } diff --git a/utils/config.js b/utils/config.js index 2d549fb..fce6809 100644 --- a/utils/config.js +++ b/utils/config.js @@ -179,6 +179,7 @@ const defaultConfig = { sunoSessToken: '', sunoClientToken: '', translateSource: 'openai', + enableMd: false, // 第三方md,非QQBot。需要适配器实现segment.markdown和segment.button方可使用,否则不建议开启,会造成各种错误 version: 'v2.7.10' } const _path = process.cwd()