Skip to content

Commit

Permalink
Merge branch 'iDerekLi:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wekerSnail committed Mar 18, 2024
2 parents 4ab9d60 + 21afcf8 commit a3ae9ff
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 50 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
PUSHPLUS_TOKEN: ${{ secrets.PUSHPLUS_TOKEN }}
WEIXIN_WEBHOOK: ${{ secrets.WEIXIN_WEBHOOK }}
SERVERPUSHKEY: ${{ secrets.SERVERPUSHKEY }}
FEISHU_WEBHOOK: ${{ secrets.FEISHU_WEBHOOK }}

jobs:
CheckIn:
Expand All @@ -30,6 +31,7 @@ jobs:
cd workflows
yarn
yarn checkin
# SeaGold:
# needs: CheckIn
# runs-on: ubuntu-latest
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<p align="center">签到、抽奖、沾喜气、消除Bug、海底掘金游戏、自动化工作流。</p>

## 通知
✨ 自动化工作流,新增飞书推送。 \
🔈 海底掘金游戏官方已下线 `juejin-helper >= 1.7.3`

## 如何使用?
Expand All @@ -27,17 +28,18 @@

2. 仓库 -> Settings -> Secrets -> New repository secret, 添加Secrets变量如下:

| Name | Value | Required |
| --- | --- | --- |
| COOKIE | 掘金网站Cookie ||
| COOKIE_2 | 多用户, 当需要同时运行多个掘金用户时所需, 支持最多 **5** 名用户(即COOKIE + COOKIE_2 - COOKIE_5) ||
| EMAIL_USER | 发件人邮箱地址(需要开启 SMTP) ||
| EMAIL_PASS | 发件人邮箱密码(SMTP密码) ||
| EMAIL_TO | 订阅人邮箱地址(收件人). 如需多人订阅使用 `, ` 分割, 例如: `a@163.com, b@qq.com` ||
| DINGDING_WEBHOOK | 钉钉机器人WEBHOOK ||
| PUSHPLUS_TOKEN | [Pushplus](http://www.pushplus.plus/) 官网申请,支持微信消息推送 ||
| SERVERPUSHKEY | [Server酱](https://sct.ftqq.com//) 官网申请,支持微信消息推送 ||
| Name | Value | Required |
| --- | --- | --- |
| COOKIE | 掘金网站Cookie ||
| COOKIE_2 | 多用户, 当需要同时运行多个掘金用户时所需, 支持最多 **5** 名用户(即COOKIE + COOKIE_2 - COOKIE_5) ||
| EMAIL_USER | 发件人邮箱地址(需要开启 SMTP) ||
| EMAIL_PASS | 发件人邮箱密码(SMTP密码) ||
| EMAIL_TO | 订阅人邮箱地址(收件人). 如需多人订阅使用 `, ` 分割, 例如: `a@163.com, b@qq.com` ||
| DINGDING_WEBHOOK | 钉钉机器人WEBHOOK ||
| PUSHPLUS_TOKEN | [Pushplus](http://www.pushplus.plus/) 官网申请,支持微信消息推送 ||
| SERVERPUSHKEY | [Server酱](https://sct.ftqq.com//) 官网申请,支持微信消息推送 ||
| WEIXIN_WEBHOOK | 企业微信机器人WEBHOOK ||
| FEISHU_WEBHOOK | 飞书机器人WEBHOOK ||

4. 仓库 -> Actions, 检查Workflows并启用。

Expand Down
77 changes: 40 additions & 37 deletions workflows/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,25 @@ class GrowthTask extends Task {
class DipLuckyTask extends Task {
taskName = "沾喜气";

dipStatus = 0;
dipStatus = -1;
dipValue = 0;
luckyValue = 0;

async run() {
const growth = this.juejin.growth();

const luckyusersResult = await growth.getLotteriesLuckyUsers();
if (luckyusersResult.count > 0) {
const no1LuckyUser = luckyusersResult.lotteries[0];
const dipLuckyResult = await growth.dipLucky(no1LuckyUser.history_id);
if (dipLuckyResult.has_dip) {
this.dipStatus = 2;
} else {
this.dipStatus = 1;
this.dipValue = dipLuckyResult.dip_value;
}
}
// 掘金沾喜气功能以停用!
// const luckyusersResult = await growth.getLotteriesLuckyUsers();
// if (luckyusersResult.count > 0) {
// const no1LuckyUser = luckyusersResult.lotteries[0];
// const dipLuckyResult = await growth.dipLucky(no1LuckyUser.history_id);
// if (dipLuckyResult.has_dip) {
// this.dipStatus = 2;
// } else {
// this.dipStatus = 1;
// this.dipValue = dipLuckyResult.dip_value;
// }
// }

const luckyResult = await growth.getMyLucky();
this.luckyValue = luckyResult.total_value;
Expand All @@ -76,7 +77,7 @@ class DipLuckyTask extends Task {
class BugfixTask extends Task {
taskName = "Bugfix";

bugStatus = 0;
bugStatus = -1;
collectBugCount = 0;
userOwnBug = 0;

Expand All @@ -87,15 +88,16 @@ class BugfixTask extends Task {
const bugfixInfo = await bugfix.getUser(competition);
this.userOwnBug = bugfixInfo.user_own_bug;

try {
const notCollectBugList = await bugfix.getNotCollectBugList();
await bugfix.collectBugBatch(notCollectBugList);
this.bugStatus = 1;
this.collectBugCount = notCollectBugList.length;
this.userOwnBug += this.collectBugCount;
} catch (e) {
this.bugStatus = 2;
}
// 掘金Bugfix功能已停用。
// try {
// const notCollectBugList = await bugfix.getNotCollectBugList();
// await bugfix.collectBugBatch(notCollectBugList);
// this.bugStatus = 1;
// this.collectBugCount = notCollectBugList.length;
// this.userOwnBug += this.collectBugCount;
// } catch (e) {
// this.bugStatus = 2;
// }
}
}

Expand Down Expand Up @@ -263,7 +265,7 @@ class CheckIn {
await juejin.logout();
console.log("-------------------------");

return this.growthTask.todayStatus
return this.growthTask.todayStatus;
}

toString() {
Expand All @@ -285,20 +287,21 @@ ${
1: `签到成功 +${this.growthTask.incrPoint} 矿石`,
2: "今日已完成签到"
}[this.growthTask.todayStatus]
}
${
{
0: "沾喜气失败",
1: `沾喜气 +${this.dipLuckyTask.dipValue} 幸运值`,
2: "今日已经沾过喜气"
}[this.dipLuckyTask.dipStatus]
}
${
this.bugfixTask.bugStatus === 1
? this.bugfixTask.collectBugCount > 0
? `收集Bug +${this.bugfixTask.collectBugCount}`
: "没有可收集Bug"
: "收集Bug失败"
// ${
// {
// "-1": "沾喜气已停用",
// 0: "沾喜气失败",
// 1: `沾喜气 +${this.dipLuckyTask.dipValue} 幸运值`,
// 2: "今日已经沾过喜气"
// }[this.dipLuckyTask.dipStatus]
// }
// ${
// this.bugfixTask.bugStatus === 1
// ? this.bugfixTask.collectBugCount > 0
// ? `收集Bug +${this.bugfixTask.collectBugCount}`
// : "没有可收集Bug"
// : "收集Bug失败"
// }
}
连续签到天数 ${this.growthTask.contCount}
累计签到天数 ${this.growthTask.sumCount}
Expand Down
2 changes: 1 addition & 1 deletion workflows/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "workflows",
"version": "1.7.3",
"version": "1.8.0",
"private": true,
"description": "稀土掘金助手:签到、抽奖、沾喜气、消除Bug、海底掘金游戏、自动化工作流。",
"author": "Derek Li",
Expand Down
4 changes: 4 additions & 0 deletions workflows/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ module.exports = {
* https://sct.ftqq.com/sendkey
*/
SERVERPUSHKEY: env.SERVERPUSHKEY,
/**
* 飞书配置
*/
FEISHU_WEBHOOK: env.FEISHU_WEBHOOK
};
37 changes: 35 additions & 2 deletions workflows/utils/notification-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface DingTalkOptions extends NotificationOptions {}
interface PushPlusOptions extends NotificationOptions {}
interface WeComOptions extends NotificationOptions {}
interface WeiXinOptions extends WeComOptions {}
interface FeiShuOptions extends NotificationOptions {}

export class NotificationKit {
/**
Expand Down Expand Up @@ -145,10 +146,10 @@ export class NotificationKit {
const config = {
title: options.title,
desp: options.content,
channel: "9",
channel: "9"
};

return axios.post(`https://sctapi.ftqq.com/${token}.send`, config, {
return axios.post(`https://sctapi.ftqq.com/${token}.send`, config, {
headers: {
"Content-Type": "application/json"
}
Expand All @@ -173,6 +174,37 @@ export class NotificationKit {
});
}

/**
* 飞书Webhook
* @param options
*/
async feishuWebhook(options: FeiShuOptions) {
const url: string | unknown = env.FEISHU_WEBHOOK;
if (!url || url === "") {
throw new Error("未配置飞书Webhook。");
}

return axios.post(url as string, {
msg_type: "interactive",
card: {
elements: [
{
tag: "markdown",
content: options.content,
text_align: "left"
}
],
header: {
template: "blue",
title: {
content: options.title,
tag: "plain_text"
}
}
}
});
}

/**
* 企业微信Webhook
* @param options
Expand Down Expand Up @@ -230,6 +262,7 @@ export class NotificationKit {
await trycatch("微信", this.wecomWebhook.bind(this));
await trycatch("PushPlus", this.pushplus.bind(this));
await trycatch("Server酱", this.serverPush.bind(this));
await trycatch("飞书", this.feishuWebhook.bind(this));
}
}

Expand Down

0 comments on commit a3ae9ff

Please sign in to comment.