PushMe 支持插件功能,可以对接收的消息进行验签、解密、加工处理
Git仓库,主要提供一些插件demo以便参考、使用。
注意:对于消息类型type属性,数据消息和普通消息不能互转。text、markdown为普通消息,data、markdata、chart为数据消息。
/**
* @name 智能主题
* @description 根据消息标题文字,自动设置主题
* @param {Object} msg - 消息体
* @param {String} msg.title - 消息标题
* @param {String} msg.content - 消息内容
* @param {String} msg.date - 消息时间
* @param {String} msg.type - 消息类型
* @param {Function} next - 下一个插件
*/
function(msg, next) {
if(!['', 'text', 'markdown', 'html'].includes(msg.type)) return next();
if(/^\[[iswf]\]/.test(msg.title)) return next();
const theme = Object.entries({
f: ['失败', '错误', '异常', '失效', '过期', '不存在'],
w: ['告警', '警告', '通知', '提示', '提醒'],
s: ['成功', '完成'],
i: ['消息', '信息']
}).find(([_, words]) => words.some(word => msg.title.includes(word)))?.[0];
if(theme) msg.title = `[${theme}]${msg.title}`;
next();
}
更多插件,请关注Git仓库