2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

更新云原神自动签到以及帮助文档

This commit is contained in:
Ctrlcvs 2022-08-06 22:43:54 +08:00 committed by leiyilu
parent df3af7a87c
commit 5b719abeba
4 changed files with 97 additions and 12 deletions

View File

@ -4,6 +4,8 @@
* 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********`
* 新增指令`#云原神签到`可进行云原神签到
* 新增指令`#云原神查询`可查询当前绑定token的剩余时间
* 新增云原神自动签到
* 新增`云原神帮助`
# 1.1.5
* 体力模板列表更改为转发形式更具体呈现效果
* 新增自动签到配置

View File

@ -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()
}
});
}

View File

@ -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;
}
}
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
}

View File

@ -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