From 8eb3d53cdc4c1d34af8f47f67073de8e357ac5e7 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:08:08 +0800 Subject: [PATCH 01/28] . --- .github/workflows/passnat.yml | 20 ++++++++++++++++++++ passnat.js | 17 +++++++++++++++++ utils/passnat_api.js | 22 ++++++++++++++++++++++ utils/utils.js | 2 +- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/passnat.yml create mode 100644 passnat.js create mode 100644 utils/passnat_api.js diff --git a/.github/workflows/passnat.yml b/.github/workflows/passnat.yml new file mode 100644 index 0000000..567ecf3 --- /dev/null +++ b/.github/workflows/passnat.yml @@ -0,0 +1,20 @@ +name: run +on: + workflow_dispatch: + # push: + schedule: + - cron: 1 15 * * * +jobs: + run: + runs-on: ubuntu-latest + timeout-minutes: 50 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - run: npm run install + - run: npm run passnat + env: + TOKEN: ${{ secrets.TOKEN }} + USERID: ${{ secrets.USERID }} diff --git a/passnat.js b/passnat.js new file mode 100644 index 0000000..dbbdc31 --- /dev/null +++ b/passnat.js @@ -0,0 +1,17 @@ +import { post } from "./utils/passnat_api.js"; + +async function passnat() { + + const phone = process.env.PASSNAT_PHONE + const password = process.env.PASSNAT_PASSWORD + + + //先登录 + const res = await post("/public/login", {"password":password,"phone_number":phone,"platform":1}) + console.log(res) + + const checkin = await get("/user/checkIn", {}) + console.log(checkin) +} + +passnat() diff --git a/utils/passnat_api.js b/utils/passnat_api.js new file mode 100644 index 0000000..24152b0 --- /dev/null +++ b/utils/passnat_api.js @@ -0,0 +1,22 @@ + +// 发送请求 +async function get(path,headers) { + const result = await fetch("https://api.passnat.com" + path, { + method: "GET", + headers: headers + }).then(r => r.json()) + // console.log(result) + return result +} + + +async function post(path,body) { + const result = await fetch("https://api.passnat.com" + path, { + method: "POST", + body: boby + }).then(r => r.json()) + // console.log(result) + return result +} + +export { get, post } diff --git a/utils/utils.js b/utils/utils.js index 97e1e88..9722602 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -23,7 +23,7 @@ function startService() { throw new Error(`${data}`) }) return api - +`` } // 关闭api服务 From c0997c8bed33e0ed9b4acad35dd78e063c519b11 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:08:42 +0800 Subject: [PATCH 02/28] . --- .github/workflows/passnat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/passnat.yml b/.github/workflows/passnat.yml index 567ecf3..7ccb061 100644 --- a/.github/workflows/passnat.yml +++ b/.github/workflows/passnat.yml @@ -1,4 +1,4 @@ -name: run +name: passnat on: workflow_dispatch: # push: From 67456fb1992fb9d1c8f554e324d476822b0893bc Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:10:01 +0800 Subject: [PATCH 03/28] . --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 023208e..87c4605 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "login": "node login.js", "listen": "node listen.js", "sent": "node sent.js", - "qrcode": "node QRcode.js" + "qrcode": "node QRcode.js", + "passnat": "node passnat.js" } } From 689d6f330167c04d7d79192eaf0447c9b912f7eb Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:11:33 +0800 Subject: [PATCH 04/28] . --- utils/passnat_api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/passnat_api.js b/utils/passnat_api.js index 24152b0..2d2c292 100644 --- a/utils/passnat_api.js +++ b/utils/passnat_api.js @@ -13,7 +13,7 @@ async function get(path,headers) { async function post(path,body) { const result = await fetch("https://api.passnat.com" + path, { method: "POST", - body: boby + body: body }).then(r => r.json()) // console.log(result) return result From f3ab647cefa3e98ea5329401a19a7f47104eb982 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:15:17 +0800 Subject: [PATCH 05/28] . --- .github/workflows/passnat.yml | 4 ++-- passnat.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/passnat.yml b/.github/workflows/passnat.yml index 7ccb061..69e09ff 100644 --- a/.github/workflows/passnat.yml +++ b/.github/workflows/passnat.yml @@ -16,5 +16,5 @@ jobs: - run: npm run install - run: npm run passnat env: - TOKEN: ${{ secrets.TOKEN }} - USERID: ${{ secrets.USERID }} + PASSNAT_PHONE: ${{ secrets.PASSNAT_PHONE }} + PASSNAT_PASSWORD: ${{ secrets.PASSNAT_PASSWORD }} diff --git a/passnat.js b/passnat.js index dbbdc31..9b7e249 100644 --- a/passnat.js +++ b/passnat.js @@ -10,8 +10,8 @@ async function passnat() { const res = await post("/public/login", {"password":password,"phone_number":phone,"platform":1}) console.log(res) - const checkin = await get("/user/checkIn", {}) - console.log(checkin) + // const checkin = await get("/user/checkIn", {}) + // console.log(checkin) } passnat() From 3a420e40ed20faf96d8eeb4bb538700fc1ddea61 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:22:27 +0800 Subject: [PATCH 06/28] . --- passnat.js | 4 ++-- utils/passnat_api.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/passnat.js b/passnat.js index 9b7e249..cffa8d0 100644 --- a/passnat.js +++ b/passnat.js @@ -2,9 +2,9 @@ import { post } from "./utils/passnat_api.js"; async function passnat() { - const phone = process.env.PASSNAT_PHONE + const phone = process.env.PASSNAT_PHONE const password = process.env.PASSNAT_PASSWORD - + console.log("phone:%s password:%s",phone,password) //先登录 const res = await post("/public/login", {"password":password,"phone_number":phone,"platform":1}) diff --git a/utils/passnat_api.js b/utils/passnat_api.js index 2d2c292..badbcd8 100644 --- a/utils/passnat_api.js +++ b/utils/passnat_api.js @@ -15,7 +15,7 @@ async function post(path,body) { method: "POST", body: body }).then(r => r.json()) - // console.log(result) + console.log("post body:%s",body) return result } From e8d3373d074d77b50da22a9e9a8ce8f54768746f Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:28:29 +0800 Subject: [PATCH 07/28] . --- passnat.js | 22 +++++++++++++--------- utils/passnat_api.js | 11 +++++++---- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/passnat.js b/passnat.js index cffa8d0..1876a58 100644 --- a/passnat.js +++ b/passnat.js @@ -1,17 +1,21 @@ -import { post } from "./utils/passnat_api.js"; +import { post, get } from "./utils/passnat_api.js"; async function passnat() { - const phone = process.env.PASSNAT_PHONE const password = process.env.PASSNAT_PASSWORD - console.log("phone:%s password:%s",phone,password) + console.log("phone:%s password:%s", phone, password) - //先登录 - const res = await post("/public/login", {"password":password,"phone_number":phone,"platform":1}) + // 先登录 + const res = await post("/public/login", { "password": password, "phone_number": phone, "platform": 1 }) console.log(res) - - // const checkin = await get("/user/checkIn", {}) - // console.log(checkin) + + // // 如果登录成功,执行签到 + // if (res.code === 0) { + // const token = res.data.token + // // 设置token到环境变量或请求头中 + // const checkin = await post("/user/checkIn", { "token": token }) + // console.log(checkin) + // } } -passnat() +passnat() \ No newline at end of file diff --git a/utils/passnat_api.js b/utils/passnat_api.js index badbcd8..093d969 100644 --- a/utils/passnat_api.js +++ b/utils/passnat_api.js @@ -1,6 +1,6 @@ // 发送请求 -async function get(path,headers) { +async function get(path, headers) { const result = await fetch("https://api.passnat.com" + path, { method: "GET", headers: headers @@ -10,12 +10,15 @@ async function get(path,headers) { } -async function post(path,body) { +async function post(path, body) { const result = await fetch("https://api.passnat.com" + path, { method: "POST", - body: body + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(body) }).then(r => r.json()) - console.log("post body:%s",body) + console.log("post body:%s", JSON.stringify(body)) return result } From cc1cb64b22df9317c3bdf4ed00d69c471b253cdd Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:31:56 +0800 Subject: [PATCH 08/28] . --- passnat.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/passnat.js b/passnat.js index 1876a58..dc2cb46 100644 --- a/passnat.js +++ b/passnat.js @@ -3,19 +3,21 @@ import { post, get } from "./utils/passnat_api.js"; async function passnat() { const phone = process.env.PASSNAT_PHONE const password = process.env.PASSNAT_PASSWORD - console.log("phone:%s password:%s", phone, password) // 先登录 const res = await post("/public/login", { "password": password, "phone_number": phone, "platform": 1 }) - console.log(res) + // // 如果登录成功,执行签到 - // if (res.code === 0) { - // const token = res.data.token - // // 设置token到环境变量或请求头中 - // const checkin = await post("/user/checkIn", { "token": token }) - // console.log(checkin) - // } + if (res.code === 10000) { + console.log("登录成功") + const auth_token = res.data.auth_token + // 设置token到环境变量或请求头中 + const checkin = await post("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) + console.log(checkin) + }else { + console.log("登录失败") + } } passnat() \ No newline at end of file From 180e0479c59e7abe1da398a808a0b4f7abf4d2a5 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:33:19 +0800 Subject: [PATCH 09/28] . --- passnat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/passnat.js b/passnat.js index dc2cb46..160d39d 100644 --- a/passnat.js +++ b/passnat.js @@ -13,7 +13,7 @@ async function passnat() { console.log("登录成功") const auth_token = res.data.auth_token // 设置token到环境变量或请求头中 - const checkin = await post("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) + const checkin = await get("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) console.log(checkin) }else { console.log("登录失败") From 9b4b6d56aaa831a0a7ab72b28bd0d022b02bfaca Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:34:51 +0800 Subject: [PATCH 10/28] . --- utils/passnat_api.js | 1 - 1 file changed, 1 deletion(-) diff --git a/utils/passnat_api.js b/utils/passnat_api.js index 093d969..9761173 100644 --- a/utils/passnat_api.js +++ b/utils/passnat_api.js @@ -18,7 +18,6 @@ async function post(path, body) { }, body: JSON.stringify(body) }).then(r => r.json()) - console.log("post body:%s", JSON.stringify(body)) return result } From c2993687a2b02bc35298d280627c5c4dda9e899e Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 15:39:20 +0800 Subject: [PATCH 11/28] . --- .github/workflows/passnat.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/passnat.yml b/.github/workflows/passnat.yml index 69e09ff..13a67b2 100644 --- a/.github/workflows/passnat.yml +++ b/.github/workflows/passnat.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: # push: schedule: - - cron: 1 15 * * * + - cron: 30 16 * * * jobs: run: runs-on: ubuntu-latest From 4b57f6ed96b060df7637ef71b92eb43d1b8f9f4b Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Tue, 28 Oct 2025 16:53:06 +0800 Subject: [PATCH 12/28] . --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..10a2cf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# 忽略 sow.html 文件 +sow.html \ No newline at end of file From 9857dcf909103c8aa8e2256be033e942a967a994 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:03:30 +0800 Subject: [PATCH 13/28] . --- utils/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/utils.js b/utils/utils.js index 9722602..97e1e88 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -23,7 +23,7 @@ function startService() { throw new Error(`${data}`) }) return api -`` + } // 关闭api服务 From 0c3a9a44ad4fd32ea2d433892b9cf3cd8932fd76 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:22:39 +0800 Subject: [PATCH 14/28] . --- .github/workflows/run.yml | 2 + main.js | 21 ++++++++- passnat.js | 19 +++++++- utils/dingtalk.js | 93 +++++++++++++++++++++++++++++++++++++++ utils/utils.js | 2 +- 5 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 utils/dingtalk.js diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 5f02e69..acb71a9 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -18,3 +18,5 @@ jobs: env: TOKEN: ${{ secrets.TOKEN }} USERID: ${{ secrets.USERID }} + DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} + DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} diff --git a/main.js b/main.js index 16538eb..3177c59 100644 --- a/main.js +++ b/main.js @@ -1,8 +1,15 @@ import { close_api, delay, send, startService } from "./utils/utils.js"; +import DingTalkNotifier from "./utils/dingtalk.js"; async function main() { const t = process.env.TOKEN const uid = process.env.USERID + // 获取钉钉webhook地址和密钥(从环境变量中获取) + const dingtalkWebhook = process.env.DINGTALK_WEBHOOK + const dingtalkSecret = process.env.DINGTALK_SECRET + + // 创建钉钉通知实例(仅在配置了webhook时创建) + const dingtalkNotifier = dingtalkWebhook ? new DingTalkNotifier(dingtalkWebhook, dingtalkSecret) : null; if (!t || !uid) { throw new Error("参数错误!请检查") @@ -29,6 +36,17 @@ async function main() { } else { console.log("响应内容") console.dir(res, { depth: null }) + // token刷新失败时发送钉钉通知 + if (dingtalkNotifier) { + try { + await dingtalkNotifier.sendWithTitle( + "酷狗概念VIP签到系统警告", + `Token刷新失败\n时间: ${date}\n 请尽快检查并重新登录获取新的token` + ); + } catch (notifyError) { + console.error("钉钉通知发送失败:", notifyError); + } + } throw new Error("token刷新失败") } // 开始签到 @@ -69,5 +87,4 @@ async function main() { } } -main() - +main() \ No newline at end of file diff --git a/passnat.js b/passnat.js index 160d39d..d1801c5 100644 --- a/passnat.js +++ b/passnat.js @@ -1,8 +1,14 @@ import { post, get } from "./utils/passnat_api.js"; - +import DingTalkNotifier from "./utils/dingtalk.js"; async function passnat() { const phone = process.env.PASSNAT_PHONE const password = process.env.PASSNAT_PASSWORD + // 获取钉钉webhook地址和密钥(从环境变量中获取) + const dingtalkWebhook = process.env.DINGTALK_WEBHOOK + const dingtalkSecret = process.env.DINGTALK_SECRET + + // 创建钉钉通知实例(仅在配置了webhook时创建) + const dingtalkNotifier = dingtalkWebhook ? new DingTalkNotifier(dingtalkWebhook, dingtalkSecret) : null; // 先登录 const res = await post("/public/login", { "password": password, "phone_number": phone, "platform": 1 }) @@ -15,6 +21,17 @@ async function passnat() { // 设置token到环境变量或请求头中 const checkin = await get("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) console.log(checkin) + + if (dingtalkNotifier) { + try { + await dingtalkNotifier.sendWithTitle( + "恭喜!", + "PASSNAT签到成功" + ); + } catch (notifyError) { + console.error("钉钉通知发送失败:", notifyError); + } + } }else { console.log("登录失败") } diff --git a/utils/dingtalk.js b/utils/dingtalk.js new file mode 100644 index 0000000..61603d3 --- /dev/null +++ b/utils/dingtalk.js @@ -0,0 +1,93 @@ + +/** + * 钉钉通知类 + * 用于发送钉钉机器人消息 + */ +class DingTalkNotifier { + /** + * 构造函数 + * @param {string} webhookUrl - 钉钉机器人的webhook地址 + * @param {string} secret - 钉钉机器人的加签密钥 + */ + constructor(webhookUrl, secret) { + this.webhookUrl = webhookUrl; + this.secret = secret; + } + + /** + * 生成签名(Node.js环境兼容版本) + * @param {number} timestamp - 时间戳 + * @returns {string} 签名 + */ + generateSign(timestamp) { + if (!this.secret) { + return ''; + } + + const crypto = require('crypto'); + const stringToSign = timestamp + '\n' + this.secret; + const sign = crypto.createHmac('sha256', this.secret) + .update(stringToSign, 'utf8') + .digest('base64'); + return encodeURIComponent(sign); + } + + /** + * 发送文本消息 + * @param {string} content - 消息内容 + * @returns {Promise} 响应结果 + */ + async sendText(content) { + if (!this.webhookUrl) { + console.warn('钉钉webhook地址未配置,跳过消息发送'); + return; + } + + const timestamp = Date.now(); + let url = this.webhookUrl + '×tamp=' + timestamp; + + // 如果配置了密钥,则添加签名 + if (this.secret) { + const sign = this.generateSign(timestamp); + if (sign) { + url += '&sign=' + sign; + } + } + + const message = { + msgtype: 'text', + text: { + content: content + } + }; + + try { + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(message) + }); + + const result = await response.json(); + return result; + } catch (error) { + console.error('钉钉消息发送失败:', error); + throw new Error('钉钉消息发送失败: ' + error.message); + } + } + + /** + * 发送带标题和内容的消息 + * @param {string} title - 标题 + * @param {string} content - 内容 + * @returns {Promise} 响应结果 + */ + async sendWithTitle(title, content) { + const fullContent = `${title}\n\n${content}`; + return await this.sendText(fullContent); + } +} + +export default DingTalkNotifier; \ No newline at end of file diff --git a/utils/utils.js b/utils/utils.js index 97e1e88..672c7ff 100644 --- a/utils/utils.js +++ b/utils/utils.js @@ -41,4 +41,4 @@ async function send(path, method, headers) { return result } -export { delay, startService, close_api, send } +export { delay, startService, close_api, send } \ No newline at end of file From c096dddf3795fda40f3e2c8aaeec44a132e0bb66 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:23:53 +0800 Subject: [PATCH 15/28] . --- .github/workflows/passnat.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/passnat.yml b/.github/workflows/passnat.yml index 13a67b2..faa4d98 100644 --- a/.github/workflows/passnat.yml +++ b/.github/workflows/passnat.yml @@ -18,3 +18,5 @@ jobs: env: PASSNAT_PHONE: ${{ secrets.PASSNAT_PHONE }} PASSNAT_PASSWORD: ${{ secrets.PASSNAT_PASSWORD }} + DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} + DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} \ No newline at end of file From 0ed210bb03c134dfa5b85375531d46c171bb8d58 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:27:49 +0800 Subject: [PATCH 16/28] . --- main.js | 2 +- utils/dingtalk.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 3177c59..ba005a3 100644 --- a/main.js +++ b/main.js @@ -41,7 +41,7 @@ async function main() { try { await dingtalkNotifier.sendWithTitle( "酷狗概念VIP签到系统警告", - `Token刷新失败\n时间: ${date}\n 请尽快检查并重新登录获取新的token` + `Token刷新失败\n时间: ${date}\n 请尽快检查并重新登录获取新的token\n 响应内容:${res}` ); } catch (notifyError) { console.error("钉钉通知发送失败:", notifyError); diff --git a/utils/dingtalk.js b/utils/dingtalk.js index 61603d3..4250587 100644 --- a/utils/dingtalk.js +++ b/utils/dingtalk.js @@ -1,3 +1,4 @@ +import crypto from 'crypto'; /** * 钉钉通知类 @@ -24,7 +25,6 @@ class DingTalkNotifier { return ''; } - const crypto = require('crypto'); const stringToSign = timestamp + '\n' + this.secret; const sign = crypto.createHmac('sha256', this.secret) .update(stringToSign, 'utf8') From 0acf85fcf7988e4a80d5fc0194e13d5dd8ac9692 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:29:45 +0800 Subject: [PATCH 17/28] . --- .github/workflows/run.yml | 2 +- package.json | 5 ++++- utils/dingtalk.js | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index acb71a9..7225dd5 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -19,4 +19,4 @@ jobs: TOKEN: ${{ secrets.TOKEN }} USERID: ${{ secrets.USERID }} DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} - DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} + DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} \ No newline at end of file diff --git a/package.json b/package.json index 87c4605..f75b8ba 100644 --- a/package.json +++ b/package.json @@ -10,5 +10,8 @@ "sent": "node sent.js", "qrcode": "node QRcode.js", "passnat": "node passnat.js" + }, + "dependencies": { + "node-fetch": "^3.3.2" } -} +} \ No newline at end of file diff --git a/utils/dingtalk.js b/utils/dingtalk.js index 4250587..640ad96 100644 --- a/utils/dingtalk.js +++ b/utils/dingtalk.js @@ -1,4 +1,5 @@ import crypto from 'crypto'; +import fetch from 'node-fetch'; /** * 钉钉通知类 From ab544e76cbdb2f19ec17043af41edbc13ab6ad7f Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:31:05 +0800 Subject: [PATCH 18/28] . --- package.json | 3 --- utils/dingtalk.js | 1 - 2 files changed, 4 deletions(-) diff --git a/package.json b/package.json index f75b8ba..d4bf9bf 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,5 @@ "sent": "node sent.js", "qrcode": "node QRcode.js", "passnat": "node passnat.js" - }, - "dependencies": { - "node-fetch": "^3.3.2" } } \ No newline at end of file diff --git a/utils/dingtalk.js b/utils/dingtalk.js index 640ad96..4250587 100644 --- a/utils/dingtalk.js +++ b/utils/dingtalk.js @@ -1,5 +1,4 @@ import crypto from 'crypto'; -import fetch from 'node-fetch'; /** * 钉钉通知类 From fe115b0edfdc57b00d541f79e0ff2e10f52881a2 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:31:27 +0800 Subject: [PATCH 19/28] . --- .github/workflows/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 7225dd5..acb71a9 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -19,4 +19,4 @@ jobs: TOKEN: ${{ secrets.TOKEN }} USERID: ${{ secrets.USERID }} DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} - DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} \ No newline at end of file + DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} From 3be49dbcd99f8f5a00f19e271f6c39951bf93155 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:33:37 +0800 Subject: [PATCH 20/28] . --- passnat.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/passnat.js b/passnat.js index d1801c5..5a45b3d 100644 --- a/passnat.js +++ b/passnat.js @@ -22,18 +22,18 @@ async function passnat() { const checkin = await get("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) console.log(checkin) - if (dingtalkNotifier) { - try { - await dingtalkNotifier.sendWithTitle( - "恭喜!", - "PASSNAT签到成功" - ); - } catch (notifyError) { - console.error("钉钉通知发送失败:", notifyError); - } - } }else { console.log("登录失败") + if (dingtalkNotifier) { + try { + await dingtalkNotifier.sendWithTitle( + "注意!", + "passnat登陆失败!" + ); + } catch (notifyError) { + console.error("钉钉通知发送失败:", notifyError); + } + } } } From 02fb63e0152280978366c118663b1104ccab8124 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:35:12 +0800 Subject: [PATCH 21/28] . --- main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index ba005a3..c4607d9 100644 --- a/main.js +++ b/main.js @@ -40,8 +40,8 @@ async function main() { if (dingtalkNotifier) { try { await dingtalkNotifier.sendWithTitle( - "酷狗概念VIP签到系统警告", - `Token刷新失败\n时间: ${date}\n 请尽快检查并重新登录获取新的token\n 响应内容:${res}` + "酷狗签到系统警告", + "Token刷新失败,请尽快检查并重新登录获取新的token" ); } catch (notifyError) { console.error("钉钉通知发送失败:", notifyError); From cd89394232869942a2f574c09b7b0af6958755ec Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:36:49 +0800 Subject: [PATCH 22/28] . --- passnat.js | 1 + 1 file changed, 1 insertion(+) diff --git a/passnat.js b/passnat.js index 5a45b3d..90ea6c1 100644 --- a/passnat.js +++ b/passnat.js @@ -17,6 +17,7 @@ async function passnat() { // // 如果登录成功,执行签到 if (res.code === 10000) { console.log("登录成功") + await delay(10 * 1000) const auth_token = res.data.auth_token // 设置token到环境变量或请求头中 const checkin = await get("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) From 28591f74e90a2a8efa8afacf815c7faa01f48b73 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Thu, 30 Oct 2025 09:38:17 +0800 Subject: [PATCH 23/28] . --- passnat.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/passnat.js b/passnat.js index 90ea6c1..9c0331e 100644 --- a/passnat.js +++ b/passnat.js @@ -1,4 +1,5 @@ import { post, get } from "./utils/passnat_api.js"; +import { delay } from "./utils/utils.js"; import DingTalkNotifier from "./utils/dingtalk.js"; async function passnat() { const phone = process.env.PASSNAT_PHONE @@ -17,7 +18,7 @@ async function passnat() { // // 如果登录成功,执行签到 if (res.code === 10000) { console.log("登录成功") - await delay(10 * 1000) + await delay(5 * 1000) const auth_token = res.data.auth_token // 设置token到环境变量或请求头中 const checkin = await get("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) From cbfe60d7240e696d414d5fcd369efacbdb96b965 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Sat, 15 Nov 2025 14:10:16 +0800 Subject: [PATCH 24/28] . --- .github/workflows/enshan.yml | 21 ++++++++++++++ enshan.js | 54 ++++++++++++++++++++++++++++++++++++ utils/enshan_api.js | 14 ++++++++++ 3 files changed, 89 insertions(+) create mode 100644 .github/workflows/enshan.yml create mode 100644 enshan.js create mode 100644 utils/enshan_api.js diff --git a/.github/workflows/enshan.yml b/.github/workflows/enshan.yml new file mode 100644 index 0000000..040e787 --- /dev/null +++ b/.github/workflows/enshan.yml @@ -0,0 +1,21 @@ +name: passnat +on: + workflow_dispatch: + # push: + schedule: + - cron: 40 16 * * * +jobs: + run: + runs-on: ubuntu-latest + timeout-minutes: 50 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - run: npm run install + - run: npm run passnat + env: + ENSHAN_COOKIE: ${{ secrets.ENSHAN_COOKIE }} + DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} + DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} \ No newline at end of file diff --git a/enshan.js b/enshan.js new file mode 100644 index 0000000..66605c6 --- /dev/null +++ b/enshan.js @@ -0,0 +1,54 @@ +import { check_in } from "./utils/enshan_api.js"; +import { delay } from "./utils/utils.js"; +import DingTalkNotifier from "./utils/dingtalk.js"; +async function passnat() { + const cookie = process.env.ENSHAN_COOKIE + + // 获取钉钉webhook地址和密钥(从环境变量中获取) + const dingtalkWebhook = process.env.DINGTALK_WEBHOOK + const dingtalkSecret = process.env.DINGTALK_SECRET + // 创建钉钉通知实例(仅在配置了webhook时创建) + const dingtalkNotifier = dingtalkWebhook ? new DingTalkNotifier(dingtalkWebhook, dingtalkSecret) : null; + + + + headers = { + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0', + 'Connection' : 'keep-alive', + 'Host' : 'www.right.com.cn', + 'Upgrade-Insecure-Requests' : '1', + 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', + 'Accept-Language' : 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2', + 'Accept-Encoding' : 'gzip, deflate, br', + 'Cookie': cookie + } + + // 先登录 + + let res = await check_in(headers) + console.log(res) + // // 如果登录成功,执行签到 + // if (res.code === 10000) { + // console.log("登录成功") + // await delay(5 * 1000) + // const auth_token = res.data.auth_token + // // 设置token到环境变量或请求头中 + // const checkin = await get("/user/checkIn", { "authorization": 'Bearer ' + auth_token}) + // console.log(checkin) + + // }else { + // console.log("登录失败") + // if (dingtalkNotifier) { + // try { + // await dingtalkNotifier.sendWithTitle( + // "注意!", + // "passnat登陆失败!" + // ); + // } catch (notifyError) { + // console.error("钉钉通知发送失败:", notifyError); + // } + // } + // } +} + +passnat() \ No newline at end of file diff --git a/utils/enshan_api.js b/utils/enshan_api.js new file mode 100644 index 0000000..18de116 --- /dev/null +++ b/utils/enshan_api.js @@ -0,0 +1,14 @@ + +// 发送请求 +async function check_in(headers) { + const result = await fetch("https://www.right.com.cn/forum/home.php?mod=spacecp&ac=credit&op=log&suboperation=creditrulelog", { + method: "GET", + headers: headers + }).then(r => r.text) + // console.log(result) + return result +} + + + +export { check_in } From 44e861d7b97b93d32716bbd615b36b5fb1e9e75c Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Sat, 15 Nov 2025 14:12:25 +0800 Subject: [PATCH 25/28] . --- .github/workflows/enshan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enshan.yml b/.github/workflows/enshan.yml index 040e787..46adcd5 100644 --- a/.github/workflows/enshan.yml +++ b/.github/workflows/enshan.yml @@ -1,4 +1,4 @@ -name: passnat +name: enshan on: workflow_dispatch: # push: From 9d8892ce9b7bd065b2327674aee09f129eec2ebd Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Sat, 15 Nov 2025 14:13:05 +0800 Subject: [PATCH 26/28] . --- .github/workflows/enshan.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/enshan.yml b/.github/workflows/enshan.yml index 46adcd5..3ae0496 100644 --- a/.github/workflows/enshan.yml +++ b/.github/workflows/enshan.yml @@ -14,7 +14,7 @@ jobs: with: node-version: 18 - run: npm run install - - run: npm run passnat + - run: npm run enshan env: ENSHAN_COOKIE: ${{ secrets.ENSHAN_COOKIE }} DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} From 34793d8acb9e62140b8353b8296e49d998ca6bd5 Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Sat, 15 Nov 2025 14:14:52 +0800 Subject: [PATCH 27/28] . --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index d4bf9bf..00c7880 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "listen": "node listen.js", "sent": "node sent.js", "qrcode": "node QRcode.js", - "passnat": "node passnat.js" + "passnat": "node passnat.js", + "enshan": "node enshan.js" } } \ No newline at end of file From 5273b021f1bfd6af476d7b33961ec26078af0b0e Mon Sep 17 00:00:00 2001 From: ge <861719405@qq.com> Date: Sat, 15 Nov 2025 14:15:53 +0800 Subject: [PATCH 28/28] . --- enshan.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/enshan.js b/enshan.js index 66605c6..a7307aa 100644 --- a/enshan.js +++ b/enshan.js @@ -12,7 +12,7 @@ async function passnat() { - headers = { + const headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0', 'Connection' : 'keep-alive', 'Host' : 'www.right.com.cn',