diff --git a/维誉链.js b/维誉链.js new file mode 100644 index 0000000..596c9e0 --- /dev/null +++ b/维誉链.js @@ -0,0 +1,130 @@ +/* + * @File: wyl_signin.js + * @Author: Gemini + * @Date: 2025-10-02 + * @Description: 维誉链项目每日签到脚本,适配青龙面板,并支持运行后发送通知。 + */ + +// 引入 axios 依赖 +const axios = require('axios'); + +// ======================= 主要修改点 ======================= +// 从旧版 sendNotify.js 导出的对象中,解构出 sendNotify 函数 +// 这样就可以兼容您的通知文件了 +const { sendNotify } = require('./sendNotify'); +// ======================================================= + + +// --- 配置区 --- +// 请在青龙面板 -> 环境变量 中添加新变量 +// 名称: WYL_USER_IDS +// 值: 你的用户ID (例如: 1003153) +// 备注: 维誉链签到 +// +// 多账号支持: 如果有多个账号,用 & 或者 换行符 分隔 + +const userIdsEnv = process.env.WYL_USER_IDS; +const userIds = userIdsEnv ? userIdsEnv.split(/&|\n/).filter(id => !!id) : []; + +// --- 工具函数 --- +const logSeparator = () => console.log("-" .repeat(40)); + +// --- 主逻辑 --- + +/** + * 为指定的用户ID执行签到操作,并返回结果字符串 + * @param {string} userId - 用户ID + * @returns {Promise} 包含执行结果的单行消息 + */ +async function signIn(userId) { + const url = `https://zjz.114kaili.com:200/webapi/AddUsersIntegral?users_id=${userId}&type=1`; + 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' + }; + + const config = { + method: 'POST', + url: url, + headers: headers, + timeout: 10000 // 设置10秒超时 + }; + + let resultMessage = `账号 [${userId}]`; + + try { + console.log(`正在为账号 [${userId}] 执行签到...`); + const response = await axios.request(config); + const data = response.data; + + console.log(`账号 [${userId}] 服务器返回:`, JSON.stringify(data)); + + if (data.Status === 1) { + resultMessage += ` ✅ 签到成功: ${data.Message || '操作成功'}`; + } else if (data.Message) { + resultMessage += ` ❕ 操作提示: ${data.Message}`; + } else { + resultMessage += ` ❌ 操作失败: 服务器返回了未知状态。`; + } + + } catch (error) { + console.error(`❌ 账号 [${userId}] 请求发生严重错误:`); + if (error.response) { + console.error(` - 状态码: ${error.response.status}, 返回数据: ${JSON.stringify(error.response.data)}`); + resultMessage += ` ❌ 请求失败: 服务器返回状态码 ${error.response.status}`; + } else if (error.request) { + console.error(' - 网络错误,服务器未响应。'); + resultMessage += ` ❌ 请求失败: 服务器未响应`; + } else { + console.error(' - 请求配置错误:', error.message); + resultMessage += ` ❌ 请求失败: 脚本配置错误`; + } + } + + return resultMessage; +} + +// --- 任务入口 --- +(async () => { + let notificationContent = ''; + const taskName = "【维誉链】签到通知"; + + console.log(`===== 开始执行${taskName} =====`); + logSeparator(); + + if (userIds.length === 0) { + const errorMsg = "错误: 未找到任何用户ID。\n请先在青龙面板【环境变量】中添加名为 WYL_USER_IDS 的变量。"; + console.log(errorMsg); + notificationContent = errorMsg; + } else { + console.log(`共检测到 ${userIds.length} 个账号,即将开始执行...`); + logSeparator(); + + let summary = []; + for (let i = 0; i < userIds.length; i++) { + console.log(`--> 开始执行第 ${i + 1} 个账号`); + const result = await signIn(userIds[i]); + console.log(result); + summary.push(result); + logSeparator(); + } + notificationContent = summary.join('\n'); + console.log("✅ 所有账号任务已执行完毕。"); + } + + // 发送通知 + // 您的旧版 sendNotify 函数需要两个参数: 标题(text) 和 内容(desp) + if (sendNotify) { + try { + console.log("正在发送通知..."); + await sendNotify(taskName, notificationContent); + console.log("通知发送成功!"); + } catch (e) { + console.error("通知发送失败:", e); + } + } else { + console.log("未找到通知函数,请检查 sendNotify.js 文件。"); + } + + console.log(`===== ${taskName} 执行结束 =====`); +})(); \ No newline at end of file