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-21 22:37:42 +08:00
commit bf53a18563
8 changed files with 158 additions and 110 deletions

View File

@ -9,10 +9,13 @@ const _path = process.cwd()
export async function render (app = '', tpl = '', data = {}, imgType = 'jpeg') { export async function render (app = '', tpl = '', data = {}, imgType = 'jpeg') {
// 在data中保存plugin信息 // 在data中保存plugin信息
data._plugin = plugin data._plugin = plugin
if (lodash.isUndefined(data._res_path)) { if (lodash.isUndefined(data._res_path)) {
data._res_path = `../../../../../plugins/${plugin}/resources/` data._res_path = `../../../../../plugins/${plugin}/resources/`
} }
if(imgType == "png"){
data.omitBackground=true;
}
data.imgType=imgType;
Data.createDir(_path + '/data/', `html/${plugin}/${app}/${tpl}`) Data.createDir(_path + '/data/', `html/${plugin}/${app}/${tpl}`)
data.saveId = data.saveId || data.save_id || tpl data.saveId = data.saveId || data.save_id || tpl
data.tplFile = `./plugins/${plugin}/resources/${app}/${tpl}.html` data.tplFile = `./plugins/${plugin}/resources/${app}/${tpl}.html`

View File

@ -358,16 +358,16 @@ export async function DailyNoteTask() {
redis.set(sendkey, "1", { redis.set(sendkey, "1", {
EX: sendCD EX: sendCD
}); });
await Note(e, getPluginRender("xiaoyao-cvs-plugin")); // await Note(e, getPluginRender("xiaoyao-cvs-plugin"));
} }
} }
} }
export async function pokeNote(e) { export async function pokeNote(e,{render}) {
if (!Cfg.get("note.poke")) { if (!Cfg.get("note.poke")) {
return false; return false;
} }
return await Note(e, getPluginRender("xiaoyao-cvs-plugin"), "poke"); return await Note(e,{render}, "poke");
} }

View File

@ -122,7 +122,8 @@ export async function mysSign(e) {
} }
let iscount = ""; let iscount = "";
let miHoYoApi = new MihoYoApi(e); let miHoYoApi = new MihoYoApi(e);
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) { let stokens=await miHoYoApi.getStoken(e.user_id)
if (Object.keys(stokens).length==0) {
e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容") e.reply("未读取到stoken请检查cookies是否包含login_ticket、以及云崽是否为最新版本V3、V2兼容")
return true; return true;
} }
@ -231,7 +232,8 @@ export async function bbsSeach(e){
return true; return true;
} }
let miHoYoApi = new MihoYoApi(e); let miHoYoApi = new MihoYoApi(e);
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length == 0) { let stokens=await miHoYoApi.getStoken(e.user_id)
if (Object.keys(stokens).length==0) {
let cookiesDoc = await getcookiesDoc() let cookiesDoc = await getcookiesDoc()
await replyMsg(e, "未读取到stoken请检查cookies是否包含login_ticket请先绑定stoken再查询~\n"+cookiesDoc); await replyMsg(e, "未读取到stoken请检查cookies是否包含login_ticket请先绑定stoken再查询~\n"+cookiesDoc);
return true; return true;
@ -286,13 +288,12 @@ async function cookie(e) {
} = await getCookie(e); } = await getCookie(e);
let miHoYoApi = new MihoYoApi(e); let miHoYoApi = new MihoYoApi(e);
let cookiesDoc = await getcookiesDoc(); let cookiesDoc = await getcookiesDoc();
if (!cookie) { if (!cookie) {
e.reply("cookie失效请重新绑定~【教程】\n" + cookiesDoc) e.reply("cookie失效请重新绑定~【教程】\n" + cookiesDoc)
return false; return false;
} }
let stokens=miHoYoApi.getStoken(e.user_id)
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) { if (Object.keys(stokens).length>0) {
return true; return true;
} }
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) { if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
@ -300,7 +301,6 @@ 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); //延迟加载防止文件未生成 await utils.sleepAsync(1000); //延迟加载防止文件未生成
if (!flot) { if (!flot) {
e.reply("登录失效请重新登录获取cookie发送机器人~") e.reply("登录失效请重新登录获取cookie发送机器人~")
@ -347,8 +347,10 @@ export async function allMysSign() {
let stoken = await gsCfg.getBingStoken(); let stoken = await gsCfg.getBingStoken();
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign
//获取需要签到的用户 //获取需要签到的用户
for (let data of stoken) { for (let dataUid of stoken) {
let user_id = data.qq; for(let uuId in dataUid){
let data=dataUid[uuId]
let user_id = data.userId*1;
let e = { let e = {
user_id, user_id,
isTask: true isTask: true
@ -363,11 +365,12 @@ export async function allMysSign() {
} }
if (msg.includes("OK")) { //签到成功并且不是已签到的才推送 if (msg.includes("OK")) { //签到成功并且不是已签到的才推送
// msg = msg.replace("签到成功", "自动签到成功"); // msg = msg.replace("签到成功", "自动签到成功");
utils.relpyPrivate(user_id, msg + "\n自动签到成功"); utils.relpyPrivate(user_id, msg + "uid:"+uuId+"\n自动签到成功");
} }
}; };
await mysSign(e); await mysSign(e);
await utils.sleepAsync(10000); await utils.sleepAsync(10000);
}
} }
Bot.logger.mark(`米社米币签到任务完成`); Bot.logger.mark(`米社米币签到任务完成`);
return true return true

View File

@ -16,7 +16,7 @@ const _path = process.cwd();
const __dirname = path.resolve(); const __dirname = path.resolve();
const list = ["wuqi_tujian", "shiwu_tujian", "yuanmo_tujian", "mijin_tujian", "shengyiwu_tujian", "daoju_tujian"] const list = ["wuqi_tujian", "shiwu_tujian", "yuanmo_tujian", "mijin_tujian", "shengyiwu_tujian", "daoju_tujian"]
const reglist=["(#|专武|武器|图鉴|突破)","(#|食物|特殊料理|特色|料理|食材)","(#|原魔|怪物|图鉴|信息)","(#|秘境|信息|图鉴)","(#|圣遗物|图鉴)","(#|图鉴|道具)"] const reglist=["(#|专武|武器|图鉴|突破)","(#|食物|特殊料理|特色|料理|食材|图鉴)","(#|原魔|怪物|图鉴|信息)","(#|秘境|信息|图鉴)","(#|圣遗物|图鉴)","(#|图鉴|道具)"]
export async function AtlasAlias(e) { export async function AtlasAlias(e) {
if (!Cfg.get("Atlas.all")) { if (!Cfg.get("Atlas.all")) {
return false; return false;

View File

@ -1,15 +1,15 @@
import { Cfg } from "./index.js"; import { Cfg } from "./index.js";
import { segment } from "oicq"; import { segment } from "oicq";
import { currentVersion, yunzaiVersion } from "./Changelog.js"; import { currentVersion, yunzaiVersion,isV3 } from "./Changelog.js";
import {render1} from "../apps/render.js";
export const render = async function (path, params, cfg) { export const render = async function (path, params, cfg) {
let paths = path.split("/"); let paths = path.split("/");
let { render, e } = cfg; let { render, e } = cfg;
let _layout_path = process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/"; let _layout_path = process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/";
let layout_path= process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/common/layout/"; let layout_path= process.cwd() + "/plugins/xiaoyao-cvs-plugin/resources/common/layout/";
let base64 = await render1(paths[0], paths[1], { let base64 = await render(paths[0], paths[1], {
...params, ...params,
_layout_path, _layout_path,
_tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/',
defaultLayout: layout_path + "default.html", defaultLayout: layout_path + "default.html",
elemLayout: layout_path + "elem.html", elemLayout: layout_path + "elem.html",
sys: { sys: {
@ -17,21 +17,21 @@ export const render = async function (path, params, cfg) {
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>` copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
} }
},"png"); },"png");
let ret = true
if (base64) { if (base64) {
e.reply(segment.image(`base64://${base64}`)); ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
} }
return cfg.retMsgId ? ret : true
return true;
} }
export const render_path = async function (path, params, cfg,path_) { export const render_path = async function (path, params, cfg,path_) {
let paths = path.split("/"); let paths = path.split("/");
let { render, e } = cfg; let { render, e } = cfg;
let _layout_path = process.cwd() + path_; let _layout_path = process.cwd() + path_;
let base64 = await render1(paths[0], paths[1], { let base64 = await render(paths[0], paths[1], {
...params, ...params,
_layout_path, _layout_path,
_tpl_path: process.cwd() + '/plugins/xiaoyao-cvs-plugin/resources/common/tpl/',
defaultLayout: _layout_path + "default.html", defaultLayout: _layout_path + "default.html",
elemLayout: _layout_path + "elem.html", elemLayout: _layout_path + "elem.html",
sys: { sys: {
@ -39,12 +39,11 @@ export const render_path = async function (path, params, cfg,path_) {
copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>` copyright: `Created By Yunzai-Bot<span class="version">${yunzaiVersion}</span> & xiaoyao-cvs-Plugin<span class="version">${currentVersion}</span>`
} }
}); });
let ret = true
if (base64) { if (base64) {
e.reply(segment.image(`base64://${base64}`)); ret = isV3 ? await e.reply(base64) : await e.reply(segment.image(`base64://${base64}`))
} }
return cfg.retMsgId ? ret : true
return true;
} }

View File

@ -5,7 +5,9 @@ import {
promisify promisify
} from 'node:util' } from 'node:util'
import lodash from 'lodash' import lodash from 'lodash'
import {
Data
} from "../components/index.js";
const plugin = "xiaoyao-cvs-plugin" const plugin = "xiaoyao-cvs-plugin"
/** 配置文件 */ /** 配置文件 */
class GsCfg { class GsCfg {
@ -47,9 +49,9 @@ class GsCfg {
} }
} }
/** 通用yaml读取*/ /** 通用yaml读取*/
getfileYaml(path,name){ getfileYaml(path, name) {
return YAML.parse( return YAML.parse(
fs.readFileSync(path+name+".yaml", 'utf8') fs.readFileSync(path + name + ".yaml", 'utf8')
) )
} }
/** /**
@ -133,7 +135,7 @@ class GsCfg {
ckQQ ckQQ
} }
} }
/** 读取所有用户绑定的stoken */ /** 读取所有用户绑定的stoken */
async getBingStoken() { async getBingStoken() {
let ck = [] let ck = []
let ckQQ = {} let ckQQ = {}
@ -146,11 +148,9 @@ class GsCfg {
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8'))) files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
const res = await Promise.all(promises) const res = await Promise.all(promises)
res.forEach((v,index) => { res.forEach((v, index) => {
let tmp = YAML.parse(v) let tmp = YAML.parse(v)
tmp["qq"]=files[index].split(".")[0]*1
ck.push(tmp) ck.push(tmp)
}) })
return ck return ck
} }
@ -169,10 +169,18 @@ class GsCfg {
try { try {
let ck = fs.readFileSync(file, 'utf-8') let ck = fs.readFileSync(file, 'utf-8')
ck = YAML.parse(ck) ck = YAML.parse(ck)
for(let item in ck){ for (let item in ck) {
let login_ticket=ck[item]?.login_ticket let login_ticket;
ck=ck[item].ck if (!ck[item].isMain) {
return {ck,item,login_ticket}; continue;
}
login_ticket = ck[item]?.login_ticket
ck = ck[item].ck
return {
ck,
item,
login_ticket
};
} }
} catch (error) { } catch (error) {
return {} return {}
@ -187,7 +195,27 @@ class GsCfg {
fs.writeFileSync(file, yaml, 'utf8') fs.writeFileSync(file, yaml, 'utf8')
} }
} }
saveBingStoken(userId, data) {
let file = `./plugins/${plugin}/data/yaml/${userId}.yaml`
if (lodash.isEmpty(data)) {
fs.existsSync(file) && fs.unlinkSync(file)
} else {
fs.exists(file, (exists) => {
if (!exists) {
fs.writeFileSync(file, "", 'utf8')
}
let ck = fs.readFileSync(file, 'utf-8')
let yaml = YAML.stringify(data)
ck = YAML.parse(ck)
if (!ck) {
fs.writeFileSync(file, yaml, 'utf8')
} else {
ck = YAML.stringify(ck)
fs.writeFileSync(file, yaml + ck, 'utf8')
}
})
}
}
/** /**
* 原神角色id转换角色名字 * 原神角色id转换角色名字
*/ */

View File

@ -12,8 +12,10 @@ import {
isV3 isV3
} from '../../components/Changelog.js'; } from '../../components/Changelog.js';
import fetch from "node-fetch" import fetch from "node-fetch"
const APP_VERSION = "2.34.1"; const APP_VERSION = "2.35.2";
const salt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9"; const salt = "ZSHlXeQUBis52qD1kEgKt5lUYed4b7Bb";
const salt2="t0qEgfub6cvueAPgR5m9aQWWVciEer7v";
const saltWeb="N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep";
//b253c83ab2609b1b600eddfe974df47b //b253c83ab2609b1b600eddfe974df47b
const DEVICE_ID = utils.randomString(32).toUpperCase(); const DEVICE_ID = utils.randomString(32).toUpperCase();
const DEVICE_NAME = utils.randomString(_.random(1, 10)); const DEVICE_NAME = utils.randomString(_.random(1, 10));
@ -156,8 +158,9 @@ export default class MihoYoApi {
} }
} }
async forumSign(forumId) { async forumSign(forumId) {
const url = `https://api-takumi.mihoyo.com/apihub/sapi/signIn?gids=${forumId}`; const url = `https://bbs-api.mihoyo.com/apihub/app/api/signIn`;
let res = await superagent.post(url).set(this._getHeader()).timeout(10000); this.forumId=forumId;
let res = await superagent.post(url).set(this._getHeader()).send(JSON.stringify({gids:forumId*1})).timeout(10000);
let resObj = JSON.parse(res.text); let resObj = JSON.parse(res.text);
// Bot.logger.mark(`ForumSign: ${res.text}`); // Bot.logger.mark(`ForumSign: ${res.text}`);
return resObj; return resObj;
@ -264,7 +267,8 @@ export default class MihoYoApi {
async stoken(cookie, e) { async stoken(cookie, e) {
this.e = e; this.e = e;
if (Object.keys(this.getStoken(e.user_id)).length != 0) { let datalist=this.getStoken(e.user_id) || {}
if (Object.keys(datalist).length>0){
return true; return true;
} }
const map = this.getCookieMap(cookie); const map = this.getCookieMap(cookie);
@ -294,18 +298,18 @@ export default class MihoYoApi {
return false; return false;
} }
response.json().then(function(data) { response.json().then(function(data) {
// console.log(data);
if (!data.data) { if (!data.data) {
return false; return false;
} }
let datalist = { datalist[e.uid] = {
stuid: map.get("account_id"), stuid: map.get("account_id"),
stoken: data.data.list[0].token, stoken: data.data.list[0].token,
ltoken: data.data.list[1].token, ltoken: data.data.list[1].token,
uid: e.uid uid: e.uid,
userId:e.user_id,
is_sign:true
} }
let yamlStr = YAML.stringify(datalist); gsCfg.saveBingStoken(e.user_id,datalist)
fs.writeFileSync(`${YamlDataUrl}/${e.user_id}.yaml`, yamlStr, 'utf8');
return true; return true;
}); });
} }
@ -319,7 +323,7 @@ export default class MihoYoApi {
getpubHeaders(board) { getpubHeaders(board) {
const randomStr = utils.randomString(6); const randomStr = utils.randomString(6);
const timestamp = Math.floor(Date.now() / 1000) const timestamp = Math.floor(Date.now() / 1000)
let sign = md5(`salt=9nQiU3AV0rJSIBWgdynfoGMGKaklfbM7&t=${timestamp}&r=${randomStr}`); let sign = md5(`salt=${saltWeb}&t=${timestamp}&r=${randomStr}`);
return { return {
'accept-language': 'zh-CN,zh;q=0.9,ja-JP;q=0.8,ja;q=0.7,en-US;q=0.6,en;q=0.5', 'accept-language': 'zh-CN,zh;q=0.9,ja-JP;q=0.8,ja;q=0.7,en-US;q=0.6,en;q=0.5',
'x-rpc-device_id': DEVICE_ID, 'x-rpc-device_id': DEVICE_ID,
@ -327,7 +331,7 @@ export default class MihoYoApi {
Referer: board.getReferer(), Referer: board.getReferer(),
Host: 'api-takumi.mihoyo.com', Host: 'api-takumi.mihoyo.com',
'x-rpc-channel': 'appstore', 'x-rpc-channel': 'appstore',
'x-rpc-app_version': '2.34.1', 'x-rpc-app_version': APP_VERSION,
'x-requested-with': 'com.mihoyo.hyperion', 'x-requested-with': 'com.mihoyo.hyperion',
'x-rpc-client_type': '5', 'x-rpc-client_type': '5',
'Content-Type': 'application/json;charset=UTF-8', 'Content-Type': 'application/json;charset=UTF-8',
@ -335,24 +339,39 @@ export default class MihoYoApi {
'Cookie': this.cookie 'Cookie': this.cookie
} }
} }
//社区签到ds
get_ds2(q="",b){
let n = salt2
let i = Math.floor(Date.now() / 1000)
let r = _.random(100001,200000)
let add = `&b=${b}&q=${q}`
let c= md5("salt=" + n + "&t=" + i + "&r=" + r + add)
return `${i},${r},${c}`
}
// 米游币任务的 headers // 米游币任务的 headers
_getHeader() { _getHeader() {
const randomStr = utils.randomString(6); const randomStr = utils.randomString(6);
const timestamp = Math.floor(Date.now() / 1000) const timestamp = Math.floor(Date.now() / 1000)
let sign = md5(`salt=${salt}&t=${timestamp}&r=${randomStr}`); let sign = md5(`salt=${salt}&t=${timestamp}&r=${randomStr}`);
let ds=`${timestamp},${randomStr},${sign}`
if(this.forumId){
ds = this.get_ds2("",JSON.stringify({gids:this.forumId*1}));
this.forumId="";
}
return { return {
'Cookie': this.cookies, 'Cookie': this.cookies,
"Referer": "https://app.mihoyo.com", "x-rpc-channel": "miyousheluodi",
"x-rpc-sys_version": "6.0.1",
"Host": "bbs-api.mihoyo.com",
"User-Agent": "okhttp/4.8.0",
'x-rpc-channel': 'appstore',
'x-rpc-device_id': DEVICE_ID, 'x-rpc-device_id': DEVICE_ID,
'x-rpc-app_version': APP_VERSION, 'x-rpc-app_version': APP_VERSION,
"x-rpc-device_model": "Mi 10", "x-rpc-device_model": "Mi 10",
'x-rpc-device_name': DEVICE_NAME, 'x-rpc-device_name': DEVICE_NAME,
'x-rpc-client_type': '2', // 1 - iOS, 2 - Android, 4 - Web 'x-rpc-client_type': '2', // 1 - iOS, 2 - Android, 4 - Web
'DS': `${timestamp},${randomStr},${sign}` 'DS': ds,
"Referer": "https://app.mihoyo.com",
"x-rpc-sys_version": "12",
"Host": "bbs-api.mihoyo.com",
"User-Agent": "okhttp/4.8.0",
// 'DS': `1602569298,k0xfEh,07f4545f5d88eac59cb1257aef74a570` // 'DS': `1602569298,k0xfEh,07f4545f5d88eac59cb1257aef74a570`
} }
} }
@ -393,7 +412,14 @@ export default class MihoYoApi {
try { try {
let ck = fs.readFileSync(file, 'utf-8') let ck = fs.readFileSync(file, 'utf-8')
ck = YAML.parse(ck) ck = YAML.parse(ck)
return ck if(ck?.uid){
let datalist={};
ck.userId=this.e.user_id
datalist[ck.uid]=ck;
ck=datalist
gsCfg.saveBingStoken(this.e.user_id,datalist)
}
return ck[this.e.uid]||{}
} catch (error) { } catch (error) {
return {} return {}
} }

View File

@ -16,69 +16,57 @@ const RETRY_OPTIONS = {
minTimeout: 5000, minTimeout: 5000,
maxTimeout: 10000 maxTimeout: 10000
}; };
const nameData=["原神","崩坏3","崩坏2","未定事件簿"]; const nameData = ["原神", "崩坏3", "崩坏2", "未定事件簿"];
/** 配置文件 */ /** 配置文件 */
export default class user { export default class user {
constructor(e) { constructor(e) {
this.e=e; this.e = e;
this.stokenPath=`./plugins/${plugin}/data/yaml/` this.stokenPath = `./plugins/${plugin}/data/yaml/`
this.yunPath=`./plugins/${plugin}/data/yunToken/`; this.yunPath = `./plugins/${plugin}/data/yunToken/`;
this.getyunToken(this.e) this.getyunToken(this.e)
} }
async getCkData(){ async getCkData() {
let sumData={}; let sumData = {};
await this.cookie(this.e) await this.cookie(this.e)
this.miHoYoApi = new MihoYoApi(this.e); this.miHoYoApi = new MihoYoApi(this.e);
if(this.e.yuntoken){ if (this.e.yuntoken) {
let yunres = await promiseRetry((retry, number) => { let yunres = await this.miHoYoApi.logyunGenshen();
return this.miHoYoApi.logyunGenshen().catch((e) => {
return retry(e);
});
}, RETRY_OPTIONS);
let yundata = yunres.data let yundata = yunres.data
if(yunres.retcode===0){ if (yunres.retcode === 0) {
sumData["云原神"]={ sumData["云原神"] = {
"今日可获取":yundata?.coin?.coin_num, "今日可获取": yundata?.coin?.coin_num,
"免费时长":yundata?.free_time?.free_time, "免费时长": yundata?.free_time?.free_time,
"总时长":yundata.total_time "总时长": yundata.total_time
} }
} }
} }
if(this.e.cookies){ if (this.e.cookies) {
let mysres = await promiseRetry((retry, number) => { let mysres = await this.miHoYoApi.getTasksList();
return this.miHoYoApi.getTasksList().catch((e) => { if (mysres.retcode === 0) {
return retry(e); sumData["米游社"] = {
}); "米游币任务": mysres.data.can_get_points != 0 ? "未完成" : "已完成",
}, RETRY_OPTIONS); "米游币余额": mysres.data.total_points,
if(mysres.retcode===0){ "今日剩余可获取": mysres.data.can_get_points
sumData["米游社"]={
"米游币任务":mysres.data.can_get_points!=0?"未完成":"已完成",
"米游币余额":mysres.data.total_points,
"今日剩余可获取":mysres.data.can_get_points
} }
} }
} }
if(this.e.cookie){ if (this.e.cookie) {
for(let name of nameData){ for (let name of nameData) {
let resSign = await promiseRetry((retry, number) => { let resSign = await this.miHoYoApi.honkai3rdSignTask(name);
return this.miHoYoApi.honkai3rdSignTask(name).catch((e) => { if (resSign?.upData) {
return retry(e);
});
}, RETRY_OPTIONS);
if(resSign?.upData){
// console.log(resSign?.upData) // console.log(resSign?.upData)
for(let item of resSign?.upData){ for (let item of resSign?.upData) {
let num= lodash.random(0, 9999); let num = lodash.random(0, 9999);
item.upName=item.upName=="原神"?"ys":item.upName=="崩坏3"?"bh3":item.upName=="崩坏2"?"bh2":item.upName=="未定事件簿"?"wdy":"" item.upName = item.upName == "原神" ? "ys" : item.upName == "崩坏3" ? "bh3" : item.upName ==
sumData[item.upName+""+num]={ "崩坏2" ? "bh2" : item.upName == "未定事件簿" ? "wdy" : ""
"uid":item.game_uid, sumData[item.upName + "" + num] = {
"游戏昵称":item.nickname, "uid": item.game_uid,
"等级":item.level, "游戏昵称": item.nickname,
"今日签到":item.is_sign?"已签到":"未签到", "等级": item.level,
"累计签到":item.total_sign_day+"天", "今日签到": item.is_sign ? "已签到" : "未签到",
"今天奖励":item.awards "累计签到": item.total_sign_day + "天",
"今天奖励": item.awards
} }
} }
} }
@ -112,16 +100,17 @@ export default class user {
async cookie(e) { async cookie(e) {
let { let {
cookie, cookie,
uid,skuid uid,
skuid
} = await this.getCookie(e); } = await this.getCookie(e);
let cookiesDoc = await this.getcookiesDoc(); let cookiesDoc = await this.getcookiesDoc();
let miHoYoApi = new MihoYoApi(this.e); let miHoYoApi = new MihoYoApi(this.e);
if (!cookie) { if (!cookie) {
e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程") e.reply("请先#绑定cookie\n发送【体力帮助】查看配置教程")
return false; return false;
} }
let stokens = miHoYoApi.getStoken(e.user_id)
if (Object.keys((await miHoYoApi.getStoken(e.user_id))).length != 0) { if (!stokens) {
return true; return true;
} }
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) { if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
@ -137,7 +126,7 @@ export default class user {
} }
return true; return true;
} }
async getcookiesDoc() { async getcookiesDoc() {
return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").cookiesDoc return await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").cookiesDoc
} }
async getCookie(e) { async getCookie(e) {