mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-16 13:27:08 +00:00
fix: #713
This commit is contained in:
parent
3822da62b0
commit
f0a17dc422
4 changed files with 44 additions and 31 deletions
|
|
@ -53,6 +53,14 @@ export class ChatGPTButtonHandler extends plugin {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 按钮处理器
|
||||
* @param e
|
||||
* @param options
|
||||
* @param reject
|
||||
* @deprecated
|
||||
* @return {Promise<{appid: number, rows: [{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]}]}|{appid: number, rows: [{buttons: [{render_data: {style: number, label: *, visited_label: *}, action: {data: *, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string},{render_data: {style: number, label: *, visited_label: *}, action: {data: *, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string},{render_data: {style: number, label: *, visited_label: *}, action: {data: *, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}]}]}|{appid: number, rows: [{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]},{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]},{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]},{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]}]}|{appid: number, rows: [{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]},{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]},{buttons: {render_data: {style: number, label, visited_label}, action: {data, permission: {type: number}, unsupport_tips: string, enter: boolean, type: number}, id: string}[]}]}|null>}
|
||||
*/
|
||||
async btnHandler (e, options, reject) {
|
||||
// logger.mark('[chatgpt按钮处理器]')
|
||||
if (!Config.enableMd) {
|
||||
|
|
|
|||
55
apps/chat.js
55
apps/chat.js
|
|
@ -74,43 +74,43 @@ export class chatgpt extends plugin {
|
|||
rule: [
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#chat3[sS]*',
|
||||
reg: '^#(图片)?chat3[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'chatgpt3'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#chat1[sS]*',
|
||||
reg: '^#(图片)?chat1[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'chatgpt1'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#chatglm[sS]*',
|
||||
reg: '^#(图片)?chatglm[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'chatglm'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#bing[sS]*',
|
||||
reg: '^#(图片)?bing[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'bing'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#claude(2|3|.ai)[sS]*',
|
||||
reg: '^#(图片)?claude(2|3|.ai)[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'claude2'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#claude[sS]*',
|
||||
reg: '^#(图片)?claude[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'claude'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#xh[sS]*',
|
||||
reg: '^#(图片)?xh[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'xh'
|
||||
},
|
||||
|
|
@ -124,25 +124,25 @@ export class chatgpt extends plugin {
|
|||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#glm4[sS]*',
|
||||
reg: '^#(图片)?glm4[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'glm4'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#qwen[sS]*',
|
||||
reg: '^#(图片)?qwen[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'qwen'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: '^#gemini[sS]*',
|
||||
reg: '^#(图片)?gemini[sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'gemini'
|
||||
},
|
||||
{
|
||||
/** 命令正则匹配 */
|
||||
reg: toggleMode === 'at' ? '^[^#][sS]*' : '^#chat[^gpt][sS]*',
|
||||
reg: toggleMode === 'at' ? '^[^#][sS]*' : '^#(图片)?chat[^gpt][sS]*',
|
||||
/** 执行方法 */
|
||||
fnc: 'chatgpt',
|
||||
log: false
|
||||
|
|
@ -483,6 +483,7 @@ export class chatgpt extends plugin {
|
|||
async chatgpt (e) {
|
||||
let msg = e.msg
|
||||
let prompt
|
||||
let forcePictureMode = false
|
||||
if (this.toggleMode === 'at') {
|
||||
if (!msg || e.msg?.startsWith('#')) {
|
||||
return false
|
||||
|
|
@ -533,7 +534,10 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
return false
|
||||
}
|
||||
prompt = _.replace(e.msg.trimStart(), '#chat', '').trim()
|
||||
if (e.msg.trimStart().startsWith('#图片chat')) {
|
||||
forcePictureMode = true
|
||||
}
|
||||
prompt = _.replace(e.msg.trimStart(), /#(图片)?chat/, '').trim()
|
||||
if (prompt.length === 0) {
|
||||
return false
|
||||
}
|
||||
|
|
@ -548,10 +552,10 @@ export class chatgpt extends plugin {
|
|||
const use = (userData.mode === 'default' ? null : userData.mode) || await redis.get('CHATGPT:USE') || 'api'
|
||||
// 自动化插件本月已发送xx条消息更新太快,由于延迟和缓存问题导致不同客户端不一样,at文本和获取的card不一致。因此单独处理一下
|
||||
prompt = prompt.replace(/^|本月已发送\d+条消息/, '')
|
||||
await this.abstractChat(e, prompt, use)
|
||||
await this.abstractChat(e, prompt, use, forcePictureMode)
|
||||
}
|
||||
|
||||
async abstractChat (e, prompt, use) {
|
||||
async abstractChat (e, prompt, use, forcePictureMode = false) {
|
||||
// 关闭私聊通道后不回复
|
||||
if (!e.isMaster && e.isPrivate && !Config.enablePrivateChat) {
|
||||
return false
|
||||
|
|
@ -981,7 +985,7 @@ export class chatgpt extends plugin {
|
|||
} else {
|
||||
await this.reply('合成语音发生错误~')
|
||||
}
|
||||
} else if (userSetting.usePicture || (!Config.enableMd && Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
||||
} else if (forcePictureMode || userSetting.usePicture || (Config.autoUsePicture && response.length > Config.autoUsePictureThreshold)) {
|
||||
try {
|
||||
await this.renderImage(e, use, response, prompt, quotemessage, mood, chatMessage.suggestedResponses, imgUrls)
|
||||
} catch (err) {
|
||||
|
|
@ -1052,11 +1056,11 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
|
||||
async chatgpt1 (e) {
|
||||
return await this.otherMode(e, 'api', '#chat1')
|
||||
return await this.otherMode(e, 'api', /#(图片)?chat1/)
|
||||
}
|
||||
|
||||
async chatgpt3 (e) {
|
||||
return await this.otherMode(e, 'api3', '#chat3')
|
||||
return await this.otherMode(e, 'api3', /#(图片)?chat3/)
|
||||
}
|
||||
|
||||
async chatglm (e) {
|
||||
|
|
@ -1064,31 +1068,31 @@ export class chatgpt extends plugin {
|
|||
}
|
||||
|
||||
async bing (e) {
|
||||
return await this.otherMode(e, 'bing')
|
||||
return await this.otherMode(e, 'bing', /#(图片)?bing/)
|
||||
}
|
||||
|
||||
async claude2 (e) {
|
||||
return await this.otherMode(e, 'claude2', /^#claude(2|3|.ai)/)
|
||||
return await this.otherMode(e, 'claude2', /^#(图片)?claude(2|3|.ai)/)
|
||||
}
|
||||
|
||||
async claude (e) {
|
||||
return await this.otherMode(e, 'claude')
|
||||
return await this.otherMode(e, 'claude', /#(图片)?claude/)
|
||||
}
|
||||
|
||||
async qwen (e) {
|
||||
return await this.otherMode(e, 'qwen')
|
||||
return await this.otherMode(e, 'qwen', /#(图片)?qwen/)
|
||||
}
|
||||
|
||||
async glm4 (e) {
|
||||
return await this.otherMode(e, 'chatglm4', '#glm4')
|
||||
return await this.otherMode(e, 'chatglm4', /#(图片)?glm4/)
|
||||
}
|
||||
|
||||
async gemini (e) {
|
||||
return await this.otherMode(e, 'gemini')
|
||||
return await this.otherMode(e, 'gemini', /#(图片)?gemini/)
|
||||
}
|
||||
|
||||
async xh (e) {
|
||||
return await this.otherMode(e, 'xh')
|
||||
return await this.otherMode(e, 'xh', /#(图片)?xh/)
|
||||
}
|
||||
|
||||
async cacheContent (e, use, content, prompt, quote = [], mood = '', suggest = '', imgUrls = []) {
|
||||
|
|
@ -1396,7 +1400,8 @@ export class chatgpt extends plugin {
|
|||
if (prompt.length === 0) {
|
||||
return false
|
||||
}
|
||||
await this.abstractChat(e, prompt, mode)
|
||||
let forcePictureMode = e.msg.trimStart().startsWith('#图片')
|
||||
await this.abstractChat(e, prompt, mode, forcePictureMode)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,12 +63,12 @@ export function supportGuoba () {
|
|||
bottomHelpMessage: '独立的后台管理面板(默认3321端口),与锅巴类似。工具箱会有额外占用,启动速度稍慢,酌情开启。修改后需重启生效!!!',
|
||||
component: 'Switch'
|
||||
},
|
||||
{
|
||||
field: 'enableMd',
|
||||
label: 'QQ开启markdown',
|
||||
bottomHelpMessage: 'qq的第三方md,非QQBot。需要适配器实现segment.markdown和segment.button方可使用,否则不建议开启,会造成各种错误。默认关闭',
|
||||
component: 'Switch'
|
||||
},
|
||||
// {
|
||||
// field: 'enableMd',
|
||||
// label: 'QQ开启markdown',
|
||||
// bottomHelpMessage: 'qq的第三方md,非QQBot。需要适配器实现segment.markdown和segment.button方可使用,否则不建议开启,会造成各种错误。默认关闭',
|
||||
// component: 'Switch'
|
||||
// },
|
||||
{
|
||||
field: 'translateSource',
|
||||
label: '翻译来源',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue