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