2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-23 03:20:52 +08:00

修复文件未读写导致无法存入stoken的bug

This commit is contained in:
Ctrlcvs 2022-07-29 09:59:48 +08:00 committed by leiyilu
parent c6324d6323
commit c5b888f322
2 changed files with 20 additions and 4 deletions

View File

@ -32,11 +32,16 @@ const RETRY_OPTIONS = {
maxTimeout: 10000 maxTimeout: 10000
}; };
export async function sign(e) { export async function sign(e) {
if (!(await cookie(e))) { let isck=await cookie(e);
if (!isck) {
return true; return true;
} }
START = moment().unix(); START = moment().unix();
let miHoYoApi = new MihoYoApi(e); let miHoYoApi = new MihoYoApi(e);
if(Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0){
e.reply("未读取到stoken请尝试重新登录获取cookies")
return true;
}
let resultMessage=""; let resultMessage="";
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, ""); let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
let ForumData = await getDataList(msg); let ForumData = await getDataList(msg);
@ -64,11 +69,17 @@ export async function sign(e) {
return true return true
} }
export async function mysSign(e) { export async function mysSign(e) {
if (!(await cookie(e))) { let isck=await cookie(e);
if (!isck) {
return true;
}
let iscount="";
let miHoYoApi = new MihoYoApi(e);
if(Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0){
e.reply("未读取到stoken请尝试重新登录获取cookies")
return true; return true;
} }
START = moment().unix(); START = moment().unix();
let miHoYoApi = new MihoYoApi(e);
let resultMessage=""; let resultMessage="";
// Execute task // Execute task
let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, ""); let msg = e.msg.replace(/#|签到|井|米游社|mys|社区/g, "");
@ -173,6 +184,8 @@ async function cookie(e) {
return false; return false;
} }
let flot = (await miHoYoApi.stoken(cookie, e)); let flot = (await miHoYoApi.stoken(cookie, e));
// console.log(flot)
await utils.sleepAsync(1000); //延迟加载防止文件未生成
if (!flot) { if (!flot) {
e.reply("登录失效请重新登录获取cookie发送机器人~") e.reply("登录失效请重新登录获取cookie发送机器人~")
return false; return false;

View File

@ -68,7 +68,7 @@ export default class MihoYoApi {
} }
async stoken(cookie, e) { async stoken(cookie, e) {
this.e=e; this.e=e;
if(this.getStoken(e.user_id)){ if(Object.keys(this.getStoken(e.user_id)).length != 0){
return true; return true;
} }
const map = this.getCookieMap(cookie); const map = this.getCookieMap(cookie);
@ -96,6 +96,9 @@ export default class MihoYoApi {
} }
response.json().then(function(data) { response.json().then(function(data) {
// console.log(data); // console.log(data);
if(!data.data){
return false;
}
let datalist = { let datalist = {
stuid: map.get("account_id"), stuid: map.get("account_id"),
stoken: data.data.list[0].token, stoken: data.data.list[0].token,