From 5b719abeba4763eff6b8c8ca3d4093dfbad68214 Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Sat, 6 Aug 2022 22:43:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=91=E5=8E=9F=E7=A5=9E?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=AD=BE=E5=88=B0=E4=BB=A5=E5=8F=8A=E5=B8=AE?= =?UTF-8?q?=E5=8A=A9=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ apps/index.js | 15 ++++++--- apps/sign.js | 83 ++++++++++++++++++++++++++++++++++++++++++---- config/config.yaml | 9 +++++ 4 files changed, 97 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26ddf01..2792fdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ * 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********` * 新增指令`#云原神签到`可进行云原神签到 * 新增指令`#云原神查询`可查询当前绑定token的剩余时间 +* 新增云原神自动签到 +* 新增`云原神帮助` # 1.1.5 * 体力模板列表更改为转发形式更具体呈现效果 * 新增自动签到配置 diff --git a/apps/index.js b/apps/index.js index 373d53a..8be1c87 100644 --- a/apps/index.js +++ b/apps/index.js @@ -27,19 +27,19 @@ import { sign, mysSign, cookiesDocHelp, - signlist, - allMysSign,yunSign,sendyunTime,yuntoken, + signlist,yunSignlist,yunAllSign, + allMysSign,yunSign,sendyunTime,yuntoken,yunHelp, allSign } from "./sign.js" export { - updateRes, + updateRes,yunSignlist, signlist, updateMiaoPlugin, sign, - versionInfo, + versionInfo,yunAllSign, Note_appoint, pokeNote,yunSign,sendyunTime,yuntoken, - cookiesDocHelp, + cookiesDocHelp,yunHelp, sysCfg, help, DailyNoteTask, @@ -102,6 +102,11 @@ async function task() { allSign() } }); + schedule.scheduleJob(set.YunSignTime, function() { + if (set.isYunSign) { + yunSignlist() + } + }); } diff --git a/apps/sign.js b/apps/sign.js index 0e0e448..4c9e64d 100644 --- a/apps/sign.js +++ b/apps/sign.js @@ -34,6 +34,10 @@ export const rule = { reg: "^#*云原神签到$", describe: "云原神签到" }, + yunAllSign: { + reg: "^#云原神全部签到$", + describe: "云原神全部签到" + }, yuntoken:{ reg: "^(.*)ct(.*)$", describe: "云原神签到token获取" @@ -41,9 +45,14 @@ export const rule = { cookiesDocHelp: { reg: "^#*(米游社|cookies|米游币)帮助$", describe: "cookies获取帮助" + }, + yunHelp:{ + reg: "^#*(云原神|云)帮助$", + describe: "cookies获取帮助" } }; + const _path = process.cwd(); let START = moment().unix(); const TODAY_DATE = moment().format('YYYY-MM-DD'); @@ -53,6 +62,11 @@ const RETRY_OPTIONS = { maxTimeout: 10000 }; let YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`; +let yunpath=`${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/`; +init() +function init() { + Data.createDir("",yunpath , false); +} export async function sign(e) { let { skuid, @@ -283,6 +297,7 @@ export async function allMysSign() { isTask: true }; e.cookie = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`; + Bot.logger.mark(`正在为qq${user_id}进行米游币签到中...`); e.msg = "全部" //已签到不重复执行 let key = `genshin:mys:signed_bbs:${user_id}`; @@ -330,6 +345,7 @@ export async function allSign() { isTask: true }; e.msg = "全部" + Bot.logger.mark(`正在为qq${user_id}米社签到中...`); e.reply = (msg) => { if (!msg.includes("OK")) { return; @@ -386,14 +402,57 @@ export async function signlist(e) { isbool = false; return true; } -let yunpath=`${_path}/plugins/xiaoyao-cvs-plugin/data/yunToken/`; -init() -function init() { - Data.createDir("",yunpath , false); +let isYun=false; +export async function yunAllSign(e){ + if (!await checkAuth(e)) { + return true; + } + + e.reply(`开始执行云原神签到中,请勿重复执行`); + if(isYun){ + e.reply(`云原神签到中请勿重复执行`) + return true; + } + isYun=true; + await yunSignlist(e); + e.reply(`云原神签到任务已完成`); } + +export async function yunSignlist(e){ + Bot.logger.mark(`云原神签到任务开始`); + let files = fs.readdirSync(yunpath).filter(file => file.endsWith('.yaml')) + let isYunSignMsg = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isYunSignMsg + let userIdList = (files.join(",").replace(/.yaml/g, "").split(",")) + for (let qq of userIdList) { + let user_id = qq; + let e = { + user_id, + qq, + isTask: true + }; + Bot.logger.mark(`正在为qq${user_id}云原神签到中...`); + e.msg = "全部" + e.reply = (msg) => { + if (!msg.includes("OK")) { + return; + } + if (!isYunSignMsg||isYun) { + return; + } + if (msg.includes("签到成功")) { + utils.relpyPrivate(qq, msg + "\n云原神自动签到成功"); + } + }; + await yunSign(e); + await utils.sleepAsync(10000); + } + Bot.logger.mark(`云原神签到任务完成`); +} + + export async function yunSign(e){ if(!(await getyunToken(e))){ - e.reply("尚未绑定云原神token") + e.reply("尚未绑定云原神token\n"+await yunDoc()) return true; } let miHoYoApi = new MihoYoApi(e); @@ -413,7 +472,7 @@ const getyunToken=async function(e){ } export async function sendyunTime(e){ if(!(await getyunToken(e))){ - e.reply("尚未绑定云原神token") + e.reply("尚未绑定云原神token\n"+await yunDoc()) return true; } let miHoYoApi = new MihoYoApi(e); @@ -454,4 +513,14 @@ export async function yuntoken(e){ fs.writeFileSync(`${yunpath}${e.user_id}.yaml`, yamlStr, 'utf8'); e.reply("云原神cookie保存成功~\n您后续可发送【#云原神查询】获取使用时间~") return true; -} \ No newline at end of file +} + + +export async function yunHelp(e){ + e.reply("云原神帮助:\n"+await yunDoc()) + return true; +} + +const yunDoc=async function(){ + return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").yunDoc +} diff --git a/config/config.yaml b/config/config.yaml index e189188..b0cc82b 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -14,3 +14,12 @@ isAllSign: false allSignTime: 0 2 0 * * ? # 是否自动签到 isSign: true + +# 云原神是否自动签到 +isYunSign: true +# 米游社签到定时任务,Cron表达式,默认00:02开始执行签到 +YunSignTime: 0 2 0 * * ? +# 云原神签到成功是否推送 +isYunSignMsg: false +# 云原神帮助 +yunDoc: docs.qq.com/doc/DTnJIREZwTmxEVHBl