2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 11:40:51 +08:00
xiaoyao-cvs-plugin/apps/sign.js

117 lines
3.2 KiB
JavaScript
Raw Normal View History

2022-10-12 16:51:51 +08:00
import User from "../model/user.js"
import moment from 'moment';
export const rule = {
sign: {
reg: `^#*(原神|崩坏3|崩坏2|未定事件簿|崩坏星穹铁道)签到$`,
describe: "米社规则签到"
},
2022-10-12 16:51:51 +08:00
bbsSign: {
reg: `^#*(米游社|mys|社区)(原神|崩坏3|崩坏2|未定事件簿|大别野|崩坏星穹铁道|绝区零|全部)签到$`,
describe: "米游社米游币签到(理论上会签到全部所以区分开了)"
},
2022-10-12 16:51:51 +08:00
cloudSign:{
reg: "^#*云原神签到$",
describe: "云原神签到"
},
2022-10-12 16:51:51 +08:00
seach: {
reg: `^#*(米游币|米币|云原神)查询$`,
describe: "米游币、云原神查询"
},
cookiesDocHelp: {
2022-10-12 16:51:51 +08:00
reg: "^#*(米游社|cookies|米游币|stoken|Stoken|云原神|云)(帮助|教程|绑定)$",
describe: "cookies获取帮助"
},
2022-10-12 16:51:51 +08:00
signTask:{
reg: `^#((米游币|云原神|米社(原神|崩坏3|崩坏2|未定事件簿)*))全部签到$`,
describe: "米游币、云原神查询"
},
}
2022-10-12 16:51:51 +08:00
export async function cloudSign(e){
let user = new User(e);
START = moment().unix();
2022-11-10 23:38:34 +08:00
if(!e.yuntoken){
e.reply('尚未绑定云原神账号!')
return true;
}
let res= await user.cloudSign()
await replyMsg(e, res.message);
return true;
}
2022-10-18 07:12:47 +08:00
const checkAuth = async function (e) {
2022-10-20 08:48:45 +08:00
if (!e?.isMaster&&e?.reply) {
e?.reply(`只有主人才能命令我哦~
2022-10-18 07:12:47 +08:00
(*/ω*)`)
return false
}
return true;
}
2022-10-12 16:51:51 +08:00
export async function signTask(e){
2022-10-20 08:48:45 +08:00
if (e&&!await checkAuth(e)) {
2022-10-18 07:12:47 +08:00
return true;
}
2022-10-12 16:51:51 +08:00
let user = new User(e);
2022-10-13 00:07:37 +08:00
let task=e?.msg?.includes("米游币")?'bbs':e?.msg?.includes("云原神")?'cloud':e?.msg?.includes("米社")?'mys':''
2022-10-12 16:51:51 +08:00
if(!task){
task=e;
e='';
}
2022-10-12 16:51:51 +08:00
if(task==="bbs"){
await user.bbsTask(e)
}
2022-10-12 16:51:51 +08:00
if(task==="cloud"){
await user.cloudTask(e)
}
2022-10-12 16:51:51 +08:00
if(task==="mys"){
await user.signTask(e)
}
return true;
}
2022-10-12 16:51:51 +08:00
export async function cookiesDocHelp(e){
let user = new User(e);
2022-10-12 21:16:44 +08:00
e.reply(`${e.msg.replace(/帮助|教程|绑定/g,"")}帮助】${await user.docHelp(e.msg)}`);
return true;
}
2022-10-12 16:51:51 +08:00
export async function seach(e){
let user = new User(e);
START = moment().unix();
let res
if(e.msg.includes('币')){
res= await user.bbsSeachSign()
}else{
res= await user.cloudSeach()
}
2022-10-12 16:51:51 +08:00
await replyMsg(e, res.message);
return true;
}
2022-10-12 16:51:51 +08:00
export async function bbsSign(e) {
let user = new User(e);
START = moment().unix();
let res = await user.bbsSeachSign()
if(res.isOk&&res?.data?.can_get_points!==0){
2022-10-12 21:16:44 +08:00
let msg=e.msg.replace(/(米游社|mys|社区|签到|#)/g,"")
let forumData = await user.getDataList(msg);
e.reply(`开始尝试${msg}社区签到预计${msg=='全部'?"10-20":"1-3"}分钟~`)
2022-10-12 16:51:51 +08:00
res=await user.getbbsSign(forumData)
}
2022-10-12 16:51:51 +08:00
await replyMsg(e, res.message);
return true;
}
2022-10-12 16:51:51 +08:00
let START;
export async function sign(e) {
let user = new User(e);
START = moment().unix();
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
let ForumData = await user.getDataList(msg);
e.reply(`开始尝试${msg}签到\n预计${msg=='全部'?"60":"5-10"}秒~`)
2022-11-08 00:17:37 +08:00
let res = await user.multiSign(ForumData,true);
2022-10-12 16:51:51 +08:00
await replyMsg(e, res.message);
return true;
}
2022-10-12 16:51:51 +08:00
async function replyMsg(e, resultMessage) {
const END = moment().unix();
Bot.logger.info(`运行结束, 用时 ${END - START}`);
resultMessage += `\n用时 ${END - START}`;
e.reply([segment.at(e.user_id), "\n" + resultMessage]);
}