-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |