mirror of
https://github.com/Jerryplusy/crystelf-plugin.git
synced 2025-12-05 15:41:56 +00:00
🔧 fix(constants/prompts): update "at" field to use -1 instead of false for message structure consistency
🔧 fix(lib/responseHandler): standardize "at" field default value to -1 for message processing 🔧 fix(apps/ai): adjust message quoting to clarify sender in response formatting and update "at" field to -1
This commit is contained in:
parent
4e440aaae7
commit
21d8546486
23
apps/ai.js
23
apps/ai.js
@ -163,10 +163,10 @@ async function extractUserMessage(msg, nickname, e) {
|
||||
const msgArr = Array.isArray(reply) ? reply : reply.message || [];
|
||||
msgArr.forEach((msg) => {
|
||||
if(msg.type === 'text'){
|
||||
returnMessage += `[${e.sender?.nickname}]引用了[被引用消息:${reply.sender?.nickname},id:${reply.user_id},seq:${reply.message_id}]发的一段文本:${msg.text}\n`
|
||||
returnMessage += `[${e.sender?.nickname}]引用了[被引用消息:${reply.user_id == e.bot.uin ? '你' : reply.sender?.nickname},id:${reply.user_id},seq:${reply.message_id}]发的一段文本:${msg.text}\n`
|
||||
}
|
||||
if(msg.type === 'image'){
|
||||
returnMessage += `[${e.sender?.nickname}]引用了[被引用消息:${reply.sender?.nickname},id:${reply.user_id},seq:${reply.message_id}]发的一张图片(你可能暂时无法查看)\n`;
|
||||
returnMessage += `[${e.sender?.nickname}]引用了[被引用消息:${reply.user_id == e.bot.uin ? '你' : reply.sender?.nickname},id:${reply.user_id},seq:${reply.message_id}]发的一张图片(你可能暂时无法查看)\n`;
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -214,7 +214,7 @@ async function handleKeywordMode(userMessage, e) {
|
||||
{
|
||||
type: 'message',
|
||||
data: matchResult.text,
|
||||
at: false,
|
||||
at: -1,
|
||||
quote: -1,
|
||||
recall: false,
|
||||
},
|
||||
@ -250,7 +250,7 @@ async function handleMixMode(userMessage, e, aiConfig) {
|
||||
{
|
||||
type: 'message',
|
||||
data: matchResult.text,
|
||||
at: false,
|
||||
at: -1,
|
||||
quote: -1,
|
||||
recall: false,
|
||||
},
|
||||
@ -258,7 +258,7 @@ async function handleMixMode(userMessage, e, aiConfig) {
|
||||
let resMessage = {
|
||||
type: 'message',
|
||||
data: matchResult.text,
|
||||
at: false,
|
||||
at: -1,
|
||||
quote: -1,
|
||||
recall: false,
|
||||
};
|
||||
@ -347,20 +347,7 @@ async function sendResponse(e, messages) {
|
||||
for (const message of messages) {
|
||||
switch (message.type) {
|
||||
case 'message':
|
||||
if(message.quote === -1) {
|
||||
if(message.recall) {
|
||||
await e.reply(message.data, false, {
|
||||
recallMsg: 60,
|
||||
at: message.at,
|
||||
});
|
||||
} else {
|
||||
await e.reply(message.data, false, {
|
||||
at: message.at,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await Message.sendGroupMessage(e,e.group_id,message.data,message.at,message.quote,adapter);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'code':
|
||||
|
||||
@ -25,7 +25,7 @@ export const RESPONSE_FORMAT = `请严格按照以下格式按顺序返回你的
|
||||
{
|
||||
"type": "message",
|
||||
"data": "你的回复内容",
|
||||
"at": false,
|
||||
"at": -1,
|
||||
"quote": -1,
|
||||
"recall": false
|
||||
}
|
||||
@ -33,15 +33,13 @@ export const RESPONSE_FORMAT = `请严格按照以下格式按顺序返回你的
|
||||
|
||||
支持的消息类型(type):
|
||||
常规消息:
|
||||
- message(必须,其他均为可选): 普通文本消息,请将长句子分成多个message块返回(如果有多句话),data:回复内容,at:是否在发送本条消息的时候提醒用户,一般只在需要让用户注意的时候为true(另外,不要在message里面加@qq号),quote:是否引用用户的问题,一般只需要在回答用户问题或第一条回复或需要用到用户问题的时候才引用该消息,注意这里如果不需要引用,则填写-1,需要引用时填写消息的seq,seq会在用户发的消息那里给出,也可以引用用户回复的消息或聊天记录的相关消息,但是一个message只能含有一个引用seq,recall:值为true的时候会在发送消息后过一会撤回自己的这条消息
|
||||
- at: @某人(需要提供id,被at人qq号(number)),一般用于提醒用户,不常用
|
||||
- message(必须,其他均为可选): 普通文本消息,请将长句子分成多个message块返回(如果有多句话),data:回复内容,at:是否在发送本条消息的时候提醒用户,一般只在需要让用户注意的时候为用户的qq号(另外,不要在message里面加@qq号,不需要的时候填写-1),quote:是否引用用户的问题,一般只需要在回答用户问题或第一条回复或需要用到用户问题的时候才引用该消息,注意这里如果不需要引用,则填写-1,需要引用时填写消息的seq,seq会在用户发的消息那里给出,也可以引用用户回复的消息或聊天记录的相关消息,但是一个message只能含有一个引用seq,recall:值为true的时候会在发送消息后过一会撤回自己的这条消息
|
||||
- meme: 表情包(data值为情绪名称:angry、bye、confused、default、good、goodmorning、goodnight、happy、sad、shy、sorry、surprise),请根据聊天语境灵活选择需不需要表情包,如果感觉语境尴尬或需要表情包,那么发送一个default值的表情包,其他情绪的表情包按照当前你的情绪按需选择,注意:并不是每个聊天都需要有表情包,并且一次聊天最多回复一个表情包
|
||||
- poke: 戳一戳某人(需要提供id,被戳人qq号(number)),一般用户与用户互动,当想逗用户的时候可以使用,不要使用太过频繁(频率小于百分之20)
|
||||
功能性消息:
|
||||
- code: 代码块(会自动渲染为高亮图片,必须有language参数指定编程语言)
|
||||
- markdown: 需要渲染的markdown内容(会自动渲染为图片)
|
||||
- memory: 存储记忆(需要提供data(记忆内容,需要简明扼要)、key(字符串数组,可以有多个关键词),timeout(遗忘世间,单位为天,建议一个月)),重要:如果你认为本次用户说的话有一些值得记住的东西(例如用户希望你叫他什么,用户说她生日是多少多少等),那么使用本功能记住用户说的话
|
||||
- ai-record: AI语音(需要提供data),发送语音,不常用,用户要求你发语音的时候可以发,发的data需要简短,可以多条消息,但是不能太长
|
||||
|
||||
重要规则:
|
||||
1. 必须返回JSON数组格式,一定要是数组!无论有多少条消息,一条消息也要是数组!
|
||||
@ -63,7 +61,7 @@ export const RESPONSE_FORMAT = `请严格按照以下格式按顺序返回你的
|
||||
{
|
||||
"type": "message",
|
||||
"data": "你好呀~",
|
||||
"at": false,
|
||||
"at": -1,
|
||||
"quote": -1,
|
||||
"recall": false
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ class ResponseHandler {
|
||||
let processedMessage = {
|
||||
type: message.type,
|
||||
data: message.data,
|
||||
at: message.at || false,
|
||||
at: message.at || -1,
|
||||
quote: message.quote || -1,
|
||||
recall: message.recall || false
|
||||
};
|
||||
@ -158,7 +158,7 @@ class ResponseHandler {
|
||||
return [{
|
||||
type: 'message',
|
||||
data: `${nickName}的服务器去火星开小差了..`,
|
||||
at: false,
|
||||
at: -1,
|
||||
quote: -1,
|
||||
recall: true
|
||||
}];
|
||||
@ -169,7 +169,7 @@ class ResponseHandler {
|
||||
return [{
|
||||
type: 'message',
|
||||
data: `${nickName}的服务器去火星开小差了..`,
|
||||
at: false,
|
||||
at: -1,
|
||||
quote: -1,
|
||||
recall: true
|
||||
}];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user