Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引入环境变量COOKIE__1COOKIE__2以支持多用户 #48

Merged
merged 4 commits into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/checkin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
- name: Run Project
env:
COOKIE: ${{ secrets.COOKIE }}
COOKIE__1: ${{ secrets.COOKIE__1 }}
COOKIE__2: ${{ secrets.COOKIE__2 }}
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/seaGold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
- name: Run Project
env:
COOKIE: ${{ secrets.COOKIE }}
COOKIE__1: ${{ secrets.COOKIE__1 }}
COOKIE__2: ${{ secrets.COOKIE__2 }}
EMAIL_USER: ${{ secrets.EMAIL_USER }}
EMAIL_PASS: ${{ secrets.EMAIL_PASS }}
EMAIL_TO: ${{ secrets.EMAIL_TO }}
Expand Down
3 changes: 2 additions & 1 deletion .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"semi": true,
"singleQuote": false,
"printWidth": 100,
"trailingComma": "none"
"trailingComma": "none",
"bracketSpacing": false
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@

| Name | Value | 是否必填 |
| --- | --- | --- |
| COOKIE | 掘金网站Cookie, 如有多个Cookie则用 `,`分隔 | ✅ |
| COOKIE | 掘金网站Cookie | ✅ |
| COOKIE__1 | 掘金网站Cookie | ❌ |
| COOKIE__2 | 掘金网站Cookie | ❌ |
| DINGDING_WEBHOOK | 钉钉机器人WEBHOOK | ❌ |
| EMAIL_USER | 发件人邮箱地址(需要开启 SMTP) | ❌ |
| EMAIL_PASS | 发件人邮箱密码(SMTP密码) | ❌ |
Expand Down
3 changes: 2 additions & 1 deletion scripts/checkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ ${this.lotteryCount > 0 ? "==============\n" + drawLotteryHistory + "\n=========
}

async function run(args) {
for (let cookie of env.COOKIE.split(",")) {
const cookies = [env.COOKIE, env.COOKIE__1, env.COOKIE__2].filter((d) => d); // 数组拼接并去除假值
for (let cookie of cookies) {
const checkin = new CheckIn(cookie.trim());

await utils.wait(utils.randomRangeNumber(1000, 5000)); // 初始等待1-5s
Expand Down
13 changes: 7 additions & 6 deletions scripts/seaGold.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,19 @@ class SeaGold {
掘友: ${userInfo.name}
今日限制矿石数 ${userInfo.todayLimitDiamond}
${
userInfo.todayDiamond < userInfo.todayLimitDiamond
? `今日获取矿石数 ${userInfo.todayDiamond}`
: "今日获取已达上限"
}
userInfo.todayDiamond < userInfo.todayLimitDiamond
? `今日获取矿石数 ${userInfo.todayDiamond}`
: "今日获取已达上限"
}
${this.history.length ? `\n游戏记录\n${gameLives}` : ""}
`.trim();
}
}

async function run(args) {
for (let cookie of env.COOKIE.split(",")) {
const seaGold = new SeaGold(cookie.trim());
const cookies = [env.COOKIE, env.COOKIE__1, env.COOKIE__2].filter((d) => d); // 数组拼接并去除假值
for (let cookie of cookies) {
const seaGold = new SeaGold(cookie);

await utils.wait(utils.randomRangeNumber(1000, 5000)); // 初始等待1-5s
await seaGold.run();
Expand Down
2 changes: 2 additions & 0 deletions scripts/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const env = process.env || {};
module.exports = {
/* 掘金Cookie */
COOKIE: env.COOKIE,
COOKIE__1: env.COOKIE__1,
COOKIE__2: env.COOKIE__2,
/**
* 邮箱配置
* user 发件人邮箱, pass, 发件人密码, to收件人
Expand Down