mirror of
https://github.com/XiaoGe-LiBai/yangmao.git
synced 2025-12-17 03:48:13 +08:00
Create 维誉链2.js
This commit is contained in:
137
维誉链2.js
Normal file
137
维誉链2.js
Normal file
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* @File: wyl_signin.js
|
||||
* @Author: Gemini (Modified by NULL)
|
||||
* @Date: 2025-10-02
|
||||
* @Description: 维誉链每日签到脚本(青龙面板/普通 Node 均可)
|
||||
* 积分根据星期几自动计算:周一=100, 周二=101, ..., 周日=106
|
||||
* cron: 0 0,12 * * *
|
||||
*/
|
||||
|
||||
// ========== 依赖 ==========
|
||||
const axios = require('axios');
|
||||
const { sendNotify } = require('./sendNotify'); // 通知文件路径保持与你原来一致
|
||||
// =============================
|
||||
|
||||
// ========== 配置区 ==========
|
||||
const usersDataEnv = process.env.WYL_USER_IDS;
|
||||
const users = usersDataEnv ? usersDataEnv.split(/&|\n/).filter(Boolean) : [];
|
||||
// =============================
|
||||
|
||||
// ========== 工具 ==========
|
||||
const logSeparator = () => console.log('-'.repeat(40));
|
||||
|
||||
/**
|
||||
* @description: 根据今天是星期几来计算应得的积分
|
||||
* @return {number} integral - 计算出的积分值
|
||||
* 周一 (1) -> 100
|
||||
* 周二 (2) -> 101
|
||||
* ...
|
||||
* 周六 (6) -> 105
|
||||
* 周日 (0) -> 106
|
||||
*/
|
||||
function getDailyIntegral() {
|
||||
const dayOfWeek = new Date().getDay(); // 0 = 周日, 1 = 周一, ..., 6 = 周六
|
||||
if (dayOfWeek === 0) {
|
||||
return 106; // 周日
|
||||
} else {
|
||||
return 99 + dayOfWeek; // 周一至周六
|
||||
}
|
||||
}
|
||||
// ===========================
|
||||
|
||||
// ========== 签到逻辑 ==========
|
||||
async function signIn(userData, integral) {
|
||||
const [userId, openId] = userData.split('#');
|
||||
if (!userId || !openId) {
|
||||
return {
|
||||
resultMessage: `账号 [${userData}] 格式错误,请使用 "用户ID#openId" 格式。`,
|
||||
success: false
|
||||
};
|
||||
}
|
||||
|
||||
const url = `https://zjz.114kaili.com:200/webapi/AddUsersIntegral` +
|
||||
`?business_id=2&users_id=${userId}&remark=%E7%AD%BE%E5%88%B0%E8%B5%A0%E7%A7%AF%E5%88%86&type=1` +
|
||||
`&integral=${integral}&open_id=${openId}`;
|
||||
|
||||
const headers = {
|
||||
Host: 'zjz.114kaili.com:200',
|
||||
'User-Agent': 'Mozilla/5.0 (Linux; Android 15; Mi 10 Pro Build/AQ3A.240812.002; wv) AppleWebKit/5.0 (KHTML, like Gecko) Version/4.0 Chrome/122.0.6261.120 Mobile Safari/537.36 XWEB/1220067 MMWEBSDK/20230805 MMWEBID/909 MicroMessenger/8.0.42.29(0x28002A49) WeChat/arm64 Weixin GPVersion/1 Android Tablet NetType/WIFI Language/zh_CN ABI/arm64 MiniProgramEnv/android',
|
||||
'content-type': 'application/x-www-form-urlencoded',
|
||||
Referer: 'https://servicewechat.com/wx6da7c2450ef6e28f/4/page-frame.html'
|
||||
};
|
||||
|
||||
let resultMessage = `账号 [${userId}]`;
|
||||
let success = false;
|
||||
|
||||
try {
|
||||
console.log(`正在为账号 [${userId}] 签到,使用积分: ${integral}`);
|
||||
const { data } = await axios.post(url, '', { headers, timeout: 10000 });
|
||||
|
||||
console.log(`账号 [${userId}] 返回:`, JSON.stringify(data));
|
||||
|
||||
if (data.Status === 1) {
|
||||
resultMessage += ` ✅ 签到成功(积分:${integral}): ${data.Message || '操作成功'}`;
|
||||
success = true;
|
||||
} else if (data.Message && data.Message.includes('今天已签到')) {
|
||||
resultMessage += ` ❕ 操作提示: ${data.Message}`;
|
||||
success = true;
|
||||
} else if (data.Message) {
|
||||
resultMessage += ` ❕ 操作提示: ${data.Message}`;
|
||||
} else {
|
||||
resultMessage += ` ❌ 操作失败:服务器返回未知状态`;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(`❌ 账号 [${userId}] 请求异常:`, e.message);
|
||||
resultMessage += ` ❌ 请求失败: ${e.message}`;
|
||||
}
|
||||
return { resultMessage, success };
|
||||
}
|
||||
// ================================
|
||||
|
||||
// ========== 入口 ==========
|
||||
(async () => {
|
||||
const taskName = '【维誉链】签到通知';
|
||||
let notificationContent = '';
|
||||
|
||||
console.log(`===== 开始执行 ${taskName} =====`);
|
||||
logSeparator();
|
||||
|
||||
if (!users.length) {
|
||||
const err = '错误:未找到任何账号信息!\n请在环境变量里添加 WYL_USER_IDS';
|
||||
console.log(err);
|
||||
notificationContent = err;
|
||||
} else {
|
||||
// 动态计算当天的积分
|
||||
const currentIntegral = getDailyIntegral();
|
||||
|
||||
console.log(`共检测到 ${users.length} 个账号`);
|
||||
console.log(`今天是星期${['日', '一', '二', '三', '四', '五', '六'][new Date().getDay()]},本次签到积分:${currentIntegral}`);
|
||||
logSeparator();
|
||||
|
||||
const summary = [];
|
||||
|
||||
for (let i = 0; i < users.length; i++) {
|
||||
console.log(`--> 开始执行第 ${i + 1} 个账号`);
|
||||
const { resultMessage } = await signIn(users[i], currentIntegral);
|
||||
console.log(resultMessage);
|
||||
summary.push(resultMessage);
|
||||
logSeparator();
|
||||
}
|
||||
notificationContent = summary.join('\n');
|
||||
console.log('✅ 所有账号任务已执行完毕');
|
||||
}
|
||||
|
||||
if (sendNotify) {
|
||||
try {
|
||||
console.log('正在发送通知...');
|
||||
await sendNotify(taskName, notificationContent);
|
||||
console.log('通知发送成功!');
|
||||
} catch (e) {
|
||||
console.error('通知发送失败:', e);
|
||||
}
|
||||
} else {
|
||||
console.log('未找到 sendNotify,跳过通知');
|
||||
}
|
||||
|
||||
console.log(`===== ${taskName} 执行结束 =====`);
|
||||
})();
|
||||
Reference in New Issue
Block a user