Skip to content

Commit

Permalink
feat:新增企业微信机器人推送
Browse files Browse the repository at this point in the history
  • Loading branch information
sunjvhui committed Aug 24, 2022
1 parent 8cb4ea6 commit 98b9fc4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 6 additions & 1 deletion workflows/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ module.exports = {
* PushPlus配置
* http://www.pushplus.plus/doc/guide/openApi.html
*/
PUSHPLUS_TOKEN: env.PUSHPLUS_TOKEN
PUSHPLUS_TOKEN: env.PUSHPLUS_TOKEN,
/**
* 企业微信机器人配置
* https://developer.work.weixin.qq.com/document/path/91770
*/
WEIXIN_WEBHOOK: env.WEIXIN_WEBHOOK
};
2 changes: 2 additions & 0 deletions workflows/utils/pushMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ const env = require("./env");
const email = require("./email");
const pushplus = require("./pushplus");
const dingding = require("./dingding");
const weixinrobot = require("./weixinrobot");

async function pushMessage({ subject, text, html }) {
env.EMAIL_USER && (await email({ subject, text, html }));
env.DINGDING_WEBHOOK && (await dingding({ subject, text, html }));
env.PUSHPLUS_TOKEN && (await pushplus({ subject, text, html }));
env.WEIXIN_WEBHOOK && (await weixinrobot({ subject, text, html }));
}

module.exports = pushMessage;
20 changes: 20 additions & 0 deletions workflows/utils/weixinrobot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const axios = require('axios');

const env = require("./env");

async function weixinrobot({ subject, text, html }) {
axios.post(env.WEIXIN_WEBHOOK,{
"msgtype": "text",
"text": {
"content": `${subject}\n${text || html}`
}
})
.then(response => {
console.log(response.data);
})
.catch(error => {
console.log(error)
})

}
module.exports = weixinrobot;

0 comments on commit 98b9fc4

Please sign in to comment.