Skip to content

Commit

Permalink
fix(push): 修复钉钉缺失依赖
Browse files Browse the repository at this point in the history
  • Loading branch information
iDerekLi committed May 31, 2022
1 parent e3f626d commit 8c35db8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions scripts/utils/dingding.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const fetch = require("node-fetch");

const env = require("./env");
async function main(msg) {
DINGDING_WEBHOOK = env.DINGDING_WEBHOOK;
data = {
msgtype: "text",
text: {
content: msg
}
};
fetch(DINGDING_WEBHOOK, {
async function dingding({ subject, text, html }) {
return fetch(env.DINGDING_WEBHOOK, {
headers: {
"Content-Type": "application/json",
Charset: "UTF-8"
},
method: "POST",
body: JSON.stringify(data)
body: JSON.stringify({
msgtype: "text",
text: {
content: `${subject}\n${text || html}`
}
})
}).then((res) => console.log(JSON.stringify(res)));
}

module.exports = main;
module.exports = dingding;
12 changes: 6 additions & 6 deletions scripts/utils/pushMessage.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const env = require("./env");
const email = require("./email");
const dingding = require("./dingding");
const pushplus = require("./pushplus");
const dingding = require("./dingding");

async function main({ subject, text, html }) {
env.EMAIL_USER && email({ subject, text, html });
env.PUSHPLUS_TOKEN && pushplus({ subject, text, html });
env.DINGDING_WEBHOOK && dingding(text);
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 });
}

module.exports = main;
module.exports = pushMessage;

0 comments on commit 8c35db8

Please sign in to comment.