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

增加失效sk拦截避免持续请求

This commit is contained in:
Ctrlcvs 2022-11-24 23:12:36 +08:00
parent 398744f1fa
commit e41c7fbcd9
4 changed files with 41 additions and 11 deletions

View File

@ -255,7 +255,8 @@ export async function bindStoken(e) {
let user = new User(e); let user = new User(e);
await user.cookie(e) await user.cookie(e)
e.region = getServer(e.uid) e.region = getServer(e.uid)
let res= await user.getData("bbsGetCookie",{cookies:msg.replace(/;/g,'&').replace(/stuid/,"uid")} ) e.cks=msg.replace(/;/g,'&').replace(/stuid/,"uid")
let res= await user.getData("bbsGetCookie",{cookies:e.cks})
if (!res?.data) { if (!res?.data) {
await e.reply(`绑定Stoken失败异常${res?.message}\n请发送【stoken帮助】查看配置教程重新配置~`); await e.reply(`绑定Stoken失败异常${res?.message}\n请发送【stoken帮助】查看配置教程重新配置~`);
return true; return true;

View File

@ -143,7 +143,7 @@ export default class miHoYoApi {
}, },
bbsGetCaptcha: { bbsGetCaptcha: {
url: `${mys.bbs_api}/misc/api/createVerification`, url: `${mys.bbs_api}/misc/api/createVerification`,
query: `is_high=true`, query: `is_high=false`,
types: 'bbs' types: 'bbs'
}, },
bbsValidate: { bbsValidate: {
@ -151,7 +151,8 @@ export default class miHoYoApi {
query: `gt=${data.gt}&challenge=${data.challenge}&lang=zh-cn&pt=3&client_type=web_mobile`, query: `gt=${data.gt}&challenge=${data.challenge}&lang=zh-cn&pt=3&client_type=web_mobile`,
}, },
bbsCaptchaVerify: { bbsCaptchaVerify: {
url: `${mys.bbs_api}/misc/api/verifyVerification` url: `${mys.bbs_api}/misc/api/verifyVerification`,
types:'bbs'
}, },
bbsCaptchaVerify: { bbsCaptchaVerify: {
url: `https://api.geetest.com/gettype.php`, url: `https://api.geetest.com/gettype.php`,
@ -196,8 +197,8 @@ export default class miHoYoApi {
types: 'stoken' types: 'stoken'
}, },
validate: { validate: {
url: `https://api.geetest.com/ajax.php`, url: ``,
query: `gt=${data?.gt}&challenge=${data?.challenge}&lang=zh-cn&pt=3&client_type=web_mobile` query: ``
}, },
cloudLogin: { cloudLogin: {
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/login`, url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/login`,
@ -230,6 +231,10 @@ export default class miHoYoApi {
}, },
types: 'authKey' types: 'authKey'
}, },
getLtoken: {
url: `${mys.pass_api}/account/auth/api/getLTokenBySToken`,
query: `${data.cookies}`,
},
} }
if (!urlMap[type]) return false if (!urlMap[type]) return false
let { let {

View File

@ -4,6 +4,7 @@ const salt = "PVeGWIZACpxXZ1ibMVJPi9inCY4Nd4y2";
const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v"; const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v";
const saltWeb = "yUZ3s0Sna1IrSNfk29Vo6vRapdOyqyhB"; const saltWeb = "yUZ3s0Sna1IrSNfk29Vo6vRapdOyqyhB";
const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9"; const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9";
const passSalt='JwYDpKvLj6MrMqqYU6jTKF17KNO2PXoS';
const osSalt= ''; //599uqkwc0dlqu3h6epzjzfhgyyrd44ae rk4xg2hakoi26nljpr099fv9fck1ah10 const osSalt= ''; //599uqkwc0dlqu3h6epzjzfhgyyrd44ae rk4xg2hakoi26nljpr099fv9fck1ah10
const osSaltWeb = ''; //os 浏览帖子需要用到的salt const osSaltWeb = ''; //os 浏览帖子需要用到的salt
const web_api = `https://api-takumi.mihoyo.com` const web_api = `https://api-takumi.mihoyo.com`
@ -12,6 +13,7 @@ const os_hk4_api = `https://hk4e-api-os.hoyoverse.com`;
const hk4_api = `https://hk4e-api.mihoyo.com`; const hk4_api = `https://hk4e-api.mihoyo.com`;
const bbs_api = `https://bbs-api.mihoyo.com`; const bbs_api = `https://bbs-api.mihoyo.com`;
const cloud_api = `https://api-cloudgame.mihoyo.com` const cloud_api = `https://api-cloudgame.mihoyo.com`
const pass_api=`https://passport-api.mihoyo.com`
const boards = { const boards = {
honkai3rd: { honkai3rd: {
forumid: 1, forumid: 1,
@ -218,5 +220,6 @@ export default {
os_hk4_api, os_hk4_api,
hk4_api, hk4_api,
bbs_api, bbs_api,
pass_api,
boards boards
} }

View File

@ -272,6 +272,11 @@ export default class user {
let sumcount = 0; let sumcount = 0;
message += `\n**${forum.name}**\n` message += `\n**${forum.name}**\n`
res = await this.getData("bbsSign", forum, false) res = await this.getData("bbsSign", forum, false)
if (res?.retcode == -100) {
return {
message: '登录失效'
}
}
if (res?.retcode == 1034) { if (res?.retcode == 1034) {
message += `社区签到: 验证码失败\n`; message += `社区签到: 验证码失败\n`;
challenge = await this.bbsGeetest() challenge = await this.bbsGeetest()
@ -279,13 +284,19 @@ export default class user {
forum["headers"] = { forum["headers"] = {
"x-rpc-challenge": challenge "x-rpc-challenge": challenge
} }
await this.getData("bbsSign", forum, false) res = await this.getData("bbsSign", forum, false)
if (res?.retcode == 1034) {
message += `社区签到: 验证码失败\n`;
} else {
message += `社区签到: 验证码成功\n`;
}
} else {
message += `社区签到: 验证码失败\n`;
} }
} else { } else {
message += `社区签到: ${res.message}\n`; message += `社区签到: ${res.message}\n`;
} }
Bot.logger.mark(`${this.e.user_id}:${this.e.uid}:${forum.name} 社区签到结果: [${res.message}]`); Bot.logger.mark(`${this.e.user_id}:${this.e.uid}:${forum.name} 社区签到结果: [${res.message}]`);
await utils.randomSleepAsync();
res = await this.getData("bbsPostList", forum, false) res = await this.getData("bbsPostList", forum, false)
sumcount++; sumcount++;
let postList = res.data.list; let postList = res.data.list;
@ -311,7 +322,6 @@ export default class user {
await this.getData("bbsPostFull", data, false) await this.getData("bbsPostFull", data, false)
} }
} }
await utils.randomSleepAsync(10);
res = await this.getData("bbsVotePost", { res = await this.getData("bbsVotePost", {
postId postId
}, false) }, false)
@ -601,6 +611,7 @@ export default class user {
async bbsGeetest() { async bbsGeetest() {
let res = await this.getData('bbsGetCaptcha', false) let res = await this.getData('bbsGetCaptcha', false)
let challenge = res.data["challenge"] let challenge = res.data["challenge"]
await this.getData("geeType", res.data, false)
res = await this.getData("bbsValidate", res.data, false) res = await this.getData("bbsValidate", res.data, false)
if (res?.data?.validate) { if (res?.data?.validate) {
let validate = res?.data?.validate let validate = res?.data?.validate
@ -739,16 +750,25 @@ export default class user {
} }
} }
async seachUid(data) { async seachUid(data) {
let ltoken = ''
if (data?.data) { if (data?.data) {
let res; let res;
if (this.e.sk) { if (this.e.sk) {
// if(this.e.sk.get('stoken').includes('v2_')){
// res=await this.getData('getLtoken',{cookies:this.e.raw_message},false)
// ltoken=res?.data?.ltoken
// }
this.e.cookie = this.e.cookie =
`ltoken=${this.e.sk.get('ltoken')};ltuid=${this.e.sk.get('stuid')};cookie_token=${data.data.cookie_token}; account_id=${this.e.sk.get('stuid')};` `ltoken=${this.e.sk?.get('ltoken')||ltoken};ltuid=196576671;cookie_token=${data.data.cookie_token}; account_id=196576671;`
// if(this.e.sk?.get('mid')){
// this.e.cookie =
// `ltoken_v2=${this.e.sk?.get('ltoken')||ltoken};cookie_token_v2=${data.data.cookie_token}; account_mid_v2=${this.e.sk.get('mid')};ltmid_v2=${this.e.sk.get('mid')}`
// }
} else { } else {
this.e.cookie = this.e.original_msg this.e.cookie = this.e.original_msg
} }
res = await this.getData("userGameInfo", this.ForumData[1], false) res = await this.getData("userGameInfo", this.ForumData[1], false)
let uids=[] let uids = []
for (let s of res.data.list) { for (let s of res.data.list) {
let datalist = {} let datalist = {}
let uid = s.game_uid let uid = s.game_uid
@ -756,7 +776,8 @@ export default class user {
datalist[uid] = { datalist[uid] = {
stuid: this.e?.sk?.get('stuid') || this.e.stuid, stuid: this.e?.sk?.get('stuid') || this.e.stuid,
stoken: this.e?.sk?.get('stoken') || data?.data?.list[0].token, stoken: this.e?.sk?.get('stoken') || data?.data?.list[0].token,
ltoken: this.e?.sk?.get('ltoken') || data?.data?.list[1].token, ltoken: this.e?.sk?.get('ltoken') || ltoken || data?.data?.list[1].token,
mid: this.e?.sk?.get('mid'),
uid: uid, uid: uid,
userId: this.e.user_id, userId: this.e.user_id,
is_sign: true is_sign: true