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

补充ck查询渲染奖励数据

This commit is contained in:
Ctrlcvs 2022-08-17 21:51:22 +08:00 committed by leiyilu
parent dac7e241b5
commit 156db9a23c
4 changed files with 53 additions and 57 deletions

View File

@ -80,7 +80,7 @@ const boards = {
url: "https://bbs.mihoyo.com/zzz/"
}
}
let web_api = `https://api-takumi.mihoyo.com`
export default class MihoYoApi {
constructor(e) {
if (e) {
@ -122,33 +122,31 @@ export default class MihoYoApi {
for (let item of data.list) {
item.upName=name
let objshuj = await this.isPostSign(kkbody, item.game_uid, item.region)
item.total_sign_day=objshuj?.data?.total_sign_day
if(objshuj?.data?.is_sign){
item.is_sign=true;
upData.push(item)
// console.log(objshuj)
message+=`游戏id${item.nickname}-${item.game_uid}:今日已签到~\n`;
continue;
}
objshuj=(await this.postSign(kkbody, item.game_uid, item.region))
if(objshuj?.data?.gt){
item.is_sign=false;
message+=`游戏id${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到`;
}else{
item.is_sign=true;
message += `游戏id${item.nickname}-${item.game_uid}${objshuj.message=="OK"?"签到成功":objshuj.message}\n`
objshuj=(await this.postSign(kkbody, item.game_uid, item.region))
if(objshuj?.data?.gt){
item.is_sign=false;
message+=`游戏id${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到`;
}else{
item.total_sign_day++;
item.is_sign=true;
message += `游戏id${item.nickname}-${item.game_uid}${objshuj.message=="OK"?"签到成功":objshuj.message}\n`
}
}
//获取签到信息和奖励信息
const SignInfo = await this.getSignInfo(kkbody)
if (SignInfo) {
let awards= SignInfo.data.awards[item.total_sign_day-1];
item.awards=awards.name+"*"+awards.cnt
}
upData.push(item)
await utils.randomSleepAsync();
}
// 获取签到信息和奖励信息 、、后续重新梳理补充
// const {
// name,
// count
// } = await this.getHonkai3rdSignInfo(objData.game_uid, objData.region, objData.nickname, boards.honkai3rd)
// if (!name) {
// return {
// message: `获取签到信息和奖励信息异常`
// }
// }
// 签到操作
return {
message,upData
@ -171,40 +169,21 @@ export default class MihoYoApi {
return resObj
}
// 获取签到状态和奖励信息
async getHonkai3rdSignInfo(game_uid, region, nickname, board) {
async getSignInfo(board) {
let url=`${web_api}/event/luna/home?lang=zh-cn&`
if (board.name == "原神") {
url = `${web_api}/event/bbs_sign_reward/home?`
}
// if (board.name == "崩坏2" || board.name == "未定事件簿") {
// url = `${web_api}/event/luna/home?lang=zh-cn`
// }
let res = await superagent.get(
`https://api-takumi.mihoyo.com/common/eutheniav2/index?region=${region}&act_id=${boards.honkai3rd.actid}&uid=${game_uid}`
`${url}act_id=${board.actid}`
).set(this
.getpubHeaders(board)).timeout(10000);
let resObj = JSON.parse(res.text);
// logger.mark(`ForumSign: ${res.text}`);
let data = resObj.data
const list = data?.sign?.list
const signCount = data?.sign?. ['sign_cnt']
if (list && signCount !== undefined) {
const award = list?. [signCount]
const status = award?.status
// status 2 已签到, 1 未签到, 0 未到签到时间
if (status === 0) {
// 未到签到时间, 说明今天已签到, 当前奖励已经领取
return "ok"
} else if (status === 1) {
// 未签到
const name = award?.name
const count = award?.cnt
if (name && count) {
if (status === 2) {} else {
return {
name,
count
}
}
} else {
Bot.logger.mark(`ForumSign: error`);
}
}
}
return "";
// logger.mark(`getSignInfo: ${res.text}`);
return resObj;
}
@ -441,7 +420,6 @@ export default class MihoYoApi {
}
// 游戏签到操作查询
async isPostSign(board, game_uid, region) {
let web_api = `https://api-takumi.mihoyo.com`
let url =
`${web_api}/event/luna/info?lang=zh-cn`
if (board.name == "原神") {
@ -457,7 +435,6 @@ export default class MihoYoApi {
}
// 游戏签到操作
async postSign(board, game_uid, region) {
let web_api = `https://api-takumi.mihoyo.com`
let url =
`${web_api}/event/luna/sign`
if (board.name == "原神") {

View File

@ -53,6 +53,7 @@ export default class user {
}, RETRY_OPTIONS);
if(mysres.retcode===0){
sumData["米游社"]={
"米游币任务":mysres.data.can_get_points!=0?"未完成":"已完成",
"米游币余额":mysres.data.total_points,
"今日剩余可获取":mysres.data.can_get_points
}
@ -75,7 +76,9 @@ export default class user {
"uid":item.game_uid,
"游戏昵称":item.nickname,
"等级":item.level,
"今日签到":item.is_sign?"已签到":"未签到"
"今日签到":item.is_sign?"已签到":"未签到",
"累计签到":item.total_sign_day+"天",
"今天奖励":item.awards
}
}
}
@ -122,7 +125,7 @@ export default class user {
return true;
}
if (!cookie.includes("login_ticket") && (isV3 && !skuid?.login_ticket)) {
e.reply("米游社登录cookie不完整请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
// e.reply("米游社登录cookie不完整请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
return false;
}
let flot = (await miHoYoApi.stoken(cookie, e));

View File

@ -105,5 +105,13 @@
}
.false-color {
color: #ef3644 !important;
color: #fff !important;
position: relative;
width: 60%;
height: 100%;
background-color: #ef3644 !important;
display: inline-block;
text-align: center;
right: -30px;
border-radius: 0px 20px 20px 0;
}

View File

@ -7,7 +7,7 @@
font-size: 1.125rem;
/* 全局字体大小 */
background-color: rgb(243,242,241);
padding: 20px 0 0 0 !important;
padding: 20px 0 10px 0 !important;
}
</style>
{{/block}}
@ -22,7 +22,7 @@
</div>
{{each sumData}}
<div class="list">
<div class="list-title">
<div class="list-title" style="width: {{$index.indexOf('wdy')>=0?'160px':''}};">
{{$index=="Yun"?"云原神":$index=="mysbbs"?"米游社":$index.indexOf("ys")>=0?"原神":$index.indexOf("bh3")>=0?"崩坏3":$index.indexOf("bh2")>=0?"崩坏2":$index.indexOf("wdy")>=0?"未定事件簿":$index}}
</div>
{{each $value item}}
@ -30,9 +30,17 @@
<div>
{{$index}}
</div>
{{if item=="未完成"|| item=="未签到" }}
<div>
<span class="false-color">
{{item}}
</span>
</div>
{{else}}
<div>
{{item}}
</div>
{{/if}}
</div>
{{/each}}
</div>