Skip to content

Commit

Permalink
Merge pull request #28 from iDerekLi/workflows
Browse files Browse the repository at this point in the history
添加钉钉机器人通知
  • Loading branch information
iDerekLi authored Apr 10, 2022
2 parents 54beea8 + 5bb823f commit 2667057
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/checkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
DINGDING_WEBHOOK: ${{ secrets.DINGDING_WEBHOOK }}
run: |
yarn
yarn checkin
1 change: 1 addition & 0 deletions .github/workflows/seaGold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
DINGDING_WEBHOOK: ${{ secrets.DINGDING_WEBHOOK }}
run: |
yarn
yarn seaGold
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
| Name | Value |
| --- | --- |
| COOKIE | 掘金网站Cookie, 打开浏览器,登录 [掘金](https://juejin.cn/), 打开控制台DevTools -> Network,复制 cookie, **掘金Cookie有效期约1个月需定期更新.** |
| DINGDING_WEBHOOK | 钉钉机器人WEBHOOK |
| EMAIL_USER | 发件人邮箱地址(需要开启 SMTP) |
| EMAIL_PASS | 发件人邮箱密码(SMTP密码) |
| EMAIL_TO | 订阅人邮箱地址(收件人). 如需多人订阅使用 `, ` 分割, 例如: `[email protected], [email protected]` |
Expand Down
1 change: 1 addition & 0 deletions scripts/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ async function run(args) {
subject: "掘金每日签到",
text: content
});
utils.dingding(content);
}

run(process.argv.splice(2)).catch(error => {
Expand Down
1 change: 1 addition & 0 deletions scripts/seaGold.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ async function run(args) {
subject: "海底掘金游戏",
text: content
});
utils.dingding(content);
}

run(process.argv.splice(2)).catch(error => {
Expand Down
3 changes: 2 additions & 1 deletion scripts/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ module.exports = {
EMAIL_USER: env.EMAIL_USER,
EMAIL_PASS: env.EMAIL_PASS,
EMAIL_TO: env.EMAIL_TO,
COOKIE: env.COOKIE
COOKIE: env.COOKIE,
DINGDING_WEBHOOK:env.DINGDING_WEBHOOK
};
20 changes: 20 additions & 0 deletions scripts/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,28 @@
const env = require("./env");
const fetch = require('node-fetch')
module.exports = {
async wait(time = 0) {
return new Promise(resolve => setTimeout(resolve, time));
},
randomRangeNumber(start = 500, end = 1000) {
return (Math.random() * (end - start) + start) >> 0;
},
dingding(msg) {
DINGDING_WEBHOOK = env.DINGDING_WEBHOOK
if (typeof DINGDING_WEBHOOK != "undefined" && DINGDING_WEBHOOK != null && DINGDING_WEBHOOK != "" && DINGDING_WEBHOOK != undefined) {
data = {
"msgtype": "text",
"text": {
"content": msg
}
}
fetch(DINGDING_WEBHOOK, {
headers: {
"Content-Type": "application/json", "Charset": "UTF-8"
},
method: "POST",
body: JSON.stringify(data)
}).then(res => console.log(JSON.stringify(res)))
}
}
}

0 comments on commit 2667057

Please sign in to comment.