Skip to content

Commit

Permalink
Merge pull request iDerekLi#125 from lupingW/main
Browse files Browse the repository at this point in the history
feat: 支持Server酱推送
  • Loading branch information
iDerekLi authored Jun 19, 2023
2 parents bd00ab6 + 6c9ee94 commit 721211e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env:
DINGDING_WEBHOOK: ${{ secrets.DINGDING_WEBHOOK }}
PUSHPLUS_TOKEN: ${{ secrets.PUSHPLUS_TOKEN }}
WEIXIN_WEBHOOK: ${{ secrets.WEIXIN_WEBHOOK }}
SERVERPUSHKEY: ${{ secrets.SERVERPUSHKEY }}

jobs:
CheckIn:
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
| EMAIL_TO | 订阅人邮箱地址(收件人). 如需多人订阅使用 `, ` 分割, 例如: `[email protected], [email protected]` ||
| DINGDING_WEBHOOK | 钉钉机器人WEBHOOK ||
| PUSHPLUS_TOKEN | [Pushplus](http://www.pushplus.plus/) 官网申请,支持微信消息推送 ||
| SERVERPUSHKEY | [Server酱](https://sct.ftqq.com//) 官网申请,支持微信消息推送 ||
| WEIXIN_WEBHOOK | 企业微信机器人WEBHOOK ||

4. 仓库 -> Actions, 检查Workflows并启用。
Expand Down
2 changes: 2 additions & 0 deletions workflows/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ class CheckIn {
await this.bugfixTask.run();
await juejin.logout();
console.log("-------------------------");

return this.growthTask.todayStatus
}

toString() {
Expand Down
7 changes: 6 additions & 1 deletion workflows/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,10 @@ module.exports = {
* 企业微信机器人配置
* https://developer.work.weixin.qq.com/document/path/91770
*/
WEIXIN_WEBHOOK: env.WEIXIN_WEBHOOK
WEIXIN_WEBHOOK: env.WEIXIN_WEBHOOK,
/**
* server酱推送key
* https://sct.ftqq.com/sendkey
*/
SERVERPUSHKEY: env.SERVERPUSHKEY,
};
24 changes: 24 additions & 0 deletions workflows/utils/notification-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,29 @@ export class NotificationKit {
});
}

/**
* serverPush推送
* @param options
*/
async serverPush(options: PushPlusOptions) {
const token: string | unknown = env.SERVERPUSHKEY;
if (!token || token === "") {
throw new Error("未配置Server酱 key。");
}

const config = {
title: options.title,
desp: options.content,
channel: "9",
};

return axios.post(`https://sctapi.ftqq.com/${token}.send`, config, {
headers: {
"Content-Type": "application/json"
}
});
}

/**
* 钉钉Webhook
* @param options
Expand Down Expand Up @@ -206,6 +229,7 @@ export class NotificationKit {
await trycatch("钉钉", this.dingtalkWebhook.bind(this));
await trycatch("微信", this.wecomWebhook.bind(this));
await trycatch("PushPlus", this.pushplus.bind(this));
await trycatch("Server酱", this.serverPush.bind(this));
}
}

Expand Down

0 comments on commit 721211e

Please sign in to comment.