egg_server/utils/genMsg.ts
zhaoyingbo b992ee0b21
Some checks failed
Egg Server MIflow / build-image (push) Failing after 5m7s
feat(group-agent): 新增支持群组问答
2024-09-25 09:14:10 +00:00

97 lines
2.3 KiB
TypeScript

/**
* 生成错误消息的 JSON 字符串
* @param {string} title - 消息标题
* @param {string} content - 消息内容
* @returns {string} JSON 字符串
*/
const genErrorMsg = (title: string, content: string) =>
JSON.stringify({
elements: [
{
tag: "markdown",
content,
},
],
header: {
title: {
content: title,
tag: "plain_text",
},
template: "red",
},
})
/**
* 生成成功消息的 JSON 字符串
* @param {string} title - 消息标题
* @param {string} content - 消息内容
* @returns {string} JSON 字符串
*/
const genSuccessMsg = (title: string, content: string) =>
JSON.stringify({
elements: [
{
tag: "markdown",
content,
},
],
header: {
title: {
content: title,
tag: "plain_text",
},
template: "green",
},
})
/**
* 生成模板消息的 JSON 字符串
* @param {string} id - 模板 ID
* @param {any} variable - 模板变量
* @returns {string} JSON 字符串
*/
export const genTempMsg = (id: string, variable: any) =>
JSON.stringify({
type: "template",
data: {
config: {
update_multi: true,
enable_forward: false,
},
template_id: id,
template_variable: variable,
},
})
/**
* 生成 Sheet DB 错误消息的 JSON 字符串
* @param {string} content - 消息内容
* @returns {string} JSON 字符串
*/
export const genSheetDbErrorMsg = (content: string) =>
genErrorMsg("🍪 小煎蛋 Sheet DB 错误提醒", content)
/**
* 生成 Sheet DB 成功消息的 JSON 字符串
* @param {string} content - 消息内容
* @returns {string} JSON 字符串
*/
export const genSheetDbSuccessMsg = (content: string) =>
genSuccessMsg("🍪 感谢使用小煎蛋 Sheet DB", content)
/**
* 生成 Group Agent 错误消息的 JSON 字符串
* @param {string} content - 消息内容
* @returns {string} JSON 字符串
*/
export const genGroupAgentErrorMsg = (content: string) =>
genErrorMsg("🧑‍💻 小煎蛋 Group Agent 错误提醒", content)
/**
* 生成 Group Agent 成功消息的 JSON 字符串
* @param {string} content - 消息内容
* @returns {string} JSON 字符串
*/
export const genGroupAgentSuccessMsg = (content: string) =>
genSuccessMsg("🧑‍💻 感谢使用小煎蛋 Group Agent", content)