2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2025-01-02 15:52:34 +08:00

修正签到查询显示问题、米游币全部签到问题、米社自动签到报错问题

This commit is contained in:
Ctrlcvs 2022-10-13 10:47:13 +08:00
parent 6bef45da11
commit 91f1d98176
4 changed files with 46 additions and 21 deletions

View File

@ -38,8 +38,9 @@ export const rule = {
}
export async function cloudSign(e){
let user = new User(e);
let res= await user.cloudSeach()
await replyMsg(e, "云原神签到成功\n当前"+res.message);
START = moment().unix();
let res= await user.cloudSign()
await replyMsg(e, res.message);
return true;
}
export async function signTask(e){

View File

@ -202,7 +202,7 @@ export default class miHoYoApi {
},
cloudGamer: {
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/ackNotification`,
query: `id=${data.reward_id}`,
body: {id:data.reward_id},
types: 'cloud'
},
cloudGet: {

View File

@ -20,6 +20,15 @@ export function randomString(length,os=false) {
}
return randomStr;
}
export async function redisGet(userId,type='bbs'){
await redis.get(`xiaoyao:${type}:${userId}`);
}
export async function redisSet(userId,type='bbs',data){
var time = moment(Date.now()).add('days', 1).format('YYYY-MM-DD 00:00:00')
var new_date = (new Date(time).getTime() - new Date().getTime()) / 1000 //获取隔天凌晨的时间差
await redis.set(`xiaoyao:${type}:${userId}`,JSON.stringify(data),{EX:parseInt(new_date)});
}
/**
* 发送私聊消息仅给好友发送
* @param user_id qq号
@ -91,7 +100,7 @@ export default {
sleepAsync,getServer,
randomSleepAsync,
replyMake,
randomString,
randomString,redisGet,redisSet,
relpyPrivate,
getCookieMap
}

View File

@ -44,7 +44,8 @@ export default class user {
let yundata = yunres.data
if (yunres.retcode === 0) {
sumData["云原神"] = {
"今日可获取": yundata?.coin?.coin_num,
"今日可获取": yundata?.coin?.free_coin_num,
"米云币":yundata?.coin?.coin_num,
"免费时长": yundata?.free_time?.free_time,
"总时长": yundata.total_time
}
@ -88,9 +89,9 @@ export default class user {
if (!(this.configSign.signlist.includes(forum.name))) {
continue;
}
message += `**${forum.name}**\n`
let res
try {
message += `**${forum.name}**\n`
res = await this.getData("userGameInfo", forum)
await utils.sleepAsync(300) //等几毫秒免得请求太频繁了
if (res?.data?.list?.length === 0 || !res?.data?.list) {
@ -152,7 +153,22 @@ export default class user {
async docHelp(type) {
return this.configSign[type.includes("云") ? "yunDoc" : "cookiesDoc"]
}
async cloudSign(){
let res = await this.getData("cloudReward")
if(res?.data?.list?.length==0||!res?.data?.list){
res.message=`您今天的奖励已经领取了~`
}else{
let sendMsg=``
for(let item of res?.data?.list){
let reward_id = item.id;
let reward_msg = item.msg;
res = await this.getData("cloudGamer",{reward_id})
sendMsg+=`\n领取奖励,ID:${reward_id},Msg:${reward_msg}`
}
res.message=sendMsg;
}
return res
}
async cloudSeach() {
let res = await this.getData("cloudGet") //这样会算签到?具体待测试
if (res?.retcode == -100) {
@ -185,10 +201,6 @@ export default class user {
challenge = '',
res;
try {
if (bbsTask) {
this.e.reply(`米游币自动签到任务进行中、暂不支持手动签到`);
return false;
}
for (let forum of forumData) {
let trueDetail = 0;
let Vote = 0;
@ -398,7 +410,7 @@ export default class user {
utils.relpyPrivate(qq, msg + "\n云原神自动签到成功");
}
};
await this.cloudSeach(e);
await this.cloudSign(e);
await utils.sleepAsync(10000);
}
let msg = `云原神签到任务完成`
@ -487,7 +499,7 @@ export default class user {
bbsTask = false;
}
async bbsGeetest() {
let res = await this.getData('bbsGetCaptcha') //?????????????????????????????
let res = await this.getData('bbsGetCaptcha')
let challenge = res.data["challenge"]
res = await this.getData("bbsValidate", res.data)
if (res?.data?.validate) {
@ -530,7 +542,6 @@ export default class user {
skuid
} = await this.getCookie(e);
let cookiesDoc = await this.getcookiesDoc();
// let miHoYoApi = new MihoYoApi(this.e);
if (!cookie) {
e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程")
return false;
@ -543,7 +554,7 @@ export default class user {
// e.reply("米游社登录cookie不完整请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
return false;
}
let flot = this.stoken(cookie, e)
let flot =await this.stoken(cookie, e)
await utils.sleepAsync(1000); //延迟加载防止文件未生成
if (!flot) {
e.reply("登录失效请重新登录获取cookie发送机器人~")
@ -585,20 +596,24 @@ export default class user {
if (Object.keys(datalist).length > 0) {
return true;
}
const map = utils.getCookieMap(cookie);
let loginTicket = map.get("login_ticket");
const loginUid = map.get("login_uid") ? map.get("login_uid") : map.get("ltuid");
const map =await utils.getCookieMap(cookie);
let loginTicket = map?.get("login_ticket");
const loginUid = map?.get("login_uid") ? map?.get("login_uid") : map?.get("ltuid");
if (isV3) {
loginTicket = gsCfg.getBingCookie(e.user_id).login_ticket
}
let res = this.getData("bbsStoken", {
let mhyapi = new miHoYoApi(this.e);
let res = await mhyapi.getData("bbsStoken", {
loginUid,
loginTicket
})
// this.getData("bbsStoken", {
// loginUid,
// loginTicket
// })
if (res?.data) {
datalist[e.uid] = {
stuid: map.get("account_id"),
stuid: map?.get("account_id"),
stoken: data.data.list[0].token,
ltoken: data.data.list[1].token,
uid: e.uid,