diff --git a/.github/workflows/pause.yaml b/.github/workflows/pause.yaml index 2e8aac9..91ccb2d 100644 --- a/.github/workflows/pause.yaml +++ b/.github/workflows/pause.yaml @@ -7,7 +7,7 @@ on: - cron: '0 16 * * *' jobs: - build: + pause: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -22,5 +22,4 @@ jobs: run: | node main.js env: - LEISHEN_USERNAME: ${{ secrets.LEISHEN_USERNAME }} - LEISHEN_PASSWORD: ${{ secrets.LEISHEN_PASSWORD }} \ No newline at end of file + LEISHEN_ACCOUNT_TOKEN: ${{ secrets.LEISHEN_ACCOUNT_TOKEN }} \ No newline at end of file diff --git a/README.md b/README.md index cb5b61c..d5792a9 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ ## 📐部署 1. Fork 仓库 -3. 设置雷神账号密码 +3. 设置雷神账号的 account_token 3. 启用 Action @@ -20,18 +20,18 @@ - 将仓库默认分支设置为 master 分支 -### 2. 设置雷神账号密码 - +### 2. 设置雷神账号的 account_token +- 使用电脑登录雷神加速器官网,点击右上角头像,然后按 F12 打开开发者工具,找到`Application`选项卡,点击左侧`Storage`-->`Local Storage`-->`https://vip.leigod.com`,找到`account_token`,复制其值 +- ![image.png](https://s2.loli.net/2025/01/22/tnp6wIjDWaeSBkN.png) +- 选择`账号设置`,在`账号设置`页面找到`账号Token`,点击`复制`按钮 - 回到项目页面,依次点击`Settings`-->`Secrets`-->`New secret` -![new-secret.png](https://i.loli.net/2020/10/28/sxTuBFtRvzSgUaA.png) - -![add-secret](https://i.loli.net/2021/04/08/ZtAw6Qmcrq2S5de.png) +![new-secret.png](https://s2.loli.net/2025/01/22/ZLcmqzhpMUPBODf.png) +![add-secret](https://s2.loli.net/2025/01/23/C9EdjuWvQDsgRGl.png) -- LEISHEN_USERNAME 账号 -- LEISHEN_PASSWORD 密码 +- LEISHEN_ACCOUNT_TOKEN 账户Token -依次配置 账号密码 +配置好 account_token ### 3. 启用 Actions diff --git a/api/auth.js b/api/auth.js index cd2ad0f..eef6459 100644 --- a/api/auth.js +++ b/api/auth.js @@ -1,13 +1,5 @@ const request = require('../utils/request'); -function login(data) { - return request({ - url: '/api/auth/login/v1', - method: 'post', - data - }) -} - function pause(data) { return request({ url: '/api/user/pause', @@ -16,4 +8,4 @@ function pause(data) { }) } -module.exports = {login, pause} \ No newline at end of file +module.exports = {pause} \ No newline at end of file diff --git a/main.js b/main.js index 0f00dc0..798f682 100644 --- a/main.js +++ b/main.js @@ -1,82 +1,32 @@ -md5 = require('js-md5'); -crypto = require('crypto'); - -const login = require("./api/auth").login; const pause = require("./api/auth").pause; const Secrets = { - username: process.env.LEISHEN_USERNAME, - password: md5(process.env.LEISHEN_PASSWORD) + account_token: process.env.LEISHEN_ACCOUNT_TOKEN } - -function start(username, password) { +async function start(account_token) { console.log('🌀雷神加速器暂停助手 开始运行-------') - if (!username || !password) { - console.log("Empty username or password"); - return; - } - const user = { - country_code: 86, - lang: "zh_CN", - mobile_num: username, - os_type: 4, - password: Secrets.password, - region_code: 1, - user_type: "0", - src_channel: "guanwang", - username: Secrets.username - }; - const sign_user_request = sign(user) - login(sign_user_request).then(res => { - if (res.data.code == 0) { - let account_token = res.data.data.login_info.account_token; - pause({"account_token": account_token, "lang": "zh_CN"}).then(res2 => { - console.log(res2.data.code + ':' + res2.data.msg); - console.log('🌀雷神加速器暂停助手 成功-------') + try { + const res = await pause({"account_token": account_token, "lang": "zh_CN"}); - }) - } else { - console.log('🌀雷神加速器暂停助手 失败-------') + if (res.data.code !== 0) { + if (res.data.code === 400803) { // 400803 - 账号已经停止加速,请不要重复操作 + console.warn(`🟡雷神加速器暂停成功: ${res.data.code} - ${res.data.msg}`); + return; + } + console.error(`🔴雷神加速器暂停失败: ${res.data.code} - ${res.data.msg}`); + process.exit(1); // 非零退出码可以让 GitHub Action 失败 } - console.log('🌀雷神加速器暂停助手 结束运行-------') - }) - - -} -function sign(t) { - const a = Math.floor((new Date).getTime() / 1e3).toString() - , n = { - ts: a, - ...t + console.log(res.data.code + ':' + res.data.msg); + console.log('🌀雷神加速器暂停助手 成功-------') + } catch (error) { + console.error('🔴雷神加速器暂停失败:', error.message); + process.exit(1); } - , s = Object.keys(n).sort() - , o = {}; - for (const t of s) - o[t] = n[t]; - const r = queryString({ - ...o, - key: "5C5A639C20665313622F51E93E3F2783" - }, !1).toString(); - return console.log("signal", r), - { - ...t, - ts: a, - sign: hexMD5(r) - } + console.log('🌀雷神加速器暂停助手 结束运行-------') } -function queryString(t, e = true) { - return Object.entries(t) - .map(([t, i]) => `${t}=${e ? encodeURIComponent(i) : i}`) - .join("&"); -} - -function hexMD5(str) { - return crypto.createHash('md5').update(str).digest('hex'); -} - -start(Secrets.username, Secrets.password); \ No newline at end of file +start(Secrets.account_token); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 47c1507..4a9c430 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,24 +1,39 @@ { + "name": "LeishenAuto", + "lockfileVersion": 3, "requires": true, - "lockfileVersion": 1, - "dependencies": { - "axios": { + "packages": { + "": { + "dependencies": { + "axios": "^0.21.0" + } + }, + "node_modules/axios": { "version": "0.21.1", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", - "requires": { + "dependencies": { "follow-redirects": "^1.10.0" } }, - "follow-redirects": { + "node_modules/follow-redirects": { "version": "1.13.3", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.3.tgz", - "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==" - }, - "js-md5": { - "version": "0.7.3", - "resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.7.3.tgz", - "integrity": "sha512-ZC41vPSTLKGwIRjqDh8DfXoCrdQIyBgspJVPXHBGu4nZlAEvG3nf+jO9avM9RmLiGakg7vz974ms99nEV0tmTQ==" + "integrity": "sha512-DUgl6+HDzB0iEptNQEXLx/KhTmDb8tZUHSeLqpnjpknR70H0nC2t9N73BK6fN4hOvJ84pKlIQVQ4k5FFlBedKA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } } } } diff --git a/package.json b/package.json index cc71636..3590c79 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "dependencies": { - "axios": "^0.21.0", - "js-md5": "^0.7.3" + "axios": "^0.21.0" } }