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

对于原神签到加入geetest绕验证码方法以及延迟修正

This commit is contained in:
Ctrlcvs 2022-10-14 10:02:45 +08:00
parent 7118ecf5a1
commit 8b39d7e3ec
3 changed files with 85 additions and 55 deletions

View File

@ -27,9 +27,9 @@ export default class miHoYoApi {
this.userId = String(e.user_id) this.userId = String(e.user_id)
this.yuntoken = e.yuntoken this.yuntoken = e.yuntoken
this.devId = e.devId this.devId = e.devId
this.isOs=false; this.isOs = false;
if(this.e?.uid){ if (this.e?.uid) {
this.isOs=this.e?.uid[0] * 1 > 5 this.isOs = this.e?.uid[0] * 1 > 5
} }
this.apiMap = { this.apiMap = {
apiWeb: mys.web_api, apiWeb: mys.web_api,
@ -191,6 +191,10 @@ export default class miHoYoApi {
query: `login_ticket=${data.loginTicket}&token_types=3&uid=${data.loginUid}`, query: `login_ticket=${data.loginTicket}&token_types=3&uid=${data.loginUid}`,
types: 'stoken' types: 'stoken'
}, },
validate: {
url: `https://api.geetest.com/ajax.php`,
query: `gt=${data?.gt}&challenge=${data?.challenge}&lang=zh-cn&pt=3&client_type=web_mobile`
},
cloudLogin: { cloudLogin: {
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/login`, url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/login`,
types: 'cloud' types: 'cloud'
@ -202,7 +206,9 @@ export default class miHoYoApi {
}, },
cloudGamer: { cloudGamer: {
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/ackNotification`, url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/ackNotification`,
body: {id:data.reward_id}, body: {
id: data.reward_id
},
types: 'cloud' types: 'cloud'
}, },
cloudGet: { cloudGet: {
@ -315,7 +321,7 @@ export default class miHoYoApi {
Referer: 'https://app.mihoyo.com', Referer: 'https://app.mihoyo.com',
Origin: 'https://webstatic.mihoyo.com', Origin: 'https://webstatic.mihoyo.com',
Cookie: this.cookies, Cookie: this.cookies,
DS: this.getDs(this.isOs?mys.osSalt:mys.saltWeb), DS: this.getDs(this.isOs ? mys.osSalt : mys.saltWeb),
'x-rpc-sys_version': '12', 'x-rpc-sys_version': '12',
'x-rpc-channel': 'mihoyo', 'x-rpc-channel': 'mihoyo',
'x-rpc-device_id': DEVICE_ID, 'x-rpc-device_id': DEVICE_ID,
@ -325,16 +331,15 @@ export default class miHoYoApi {
} }
if (this.isOs) { if (this.isOs) {
let os_Header = { let os_Header = {
'x-rpc-app_version':'2.9.0', 'x-rpc-app_version': '2.18.1',
app_version: '2.9.0', app_version: '2.18.1',
// User_Agent: `Mozilla/5.0 (Linux; Android 9.0; SAMSUNG SM-F900U Build/PPR1.180610.011) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBSOversea/2.9.0`,
client_type: '2', client_type: '2',
'x-rpc-client_type': '2', 'x-rpc-client_type': '2',
Origin: 'https://webstatic-sea.hoyolab.com', Origin: 'https://app.hoyolab.com',
X_Requested_With: 'com.mihoyo.hoyolab', X_Requested_With: 'com.mihoyo.hoyolab',
Referer: 'https://app.hoyolab.com', Referer: 'https://app.hoyolab.com',
Host: 'api-os-takumi.mihoyo.com', Host: 'api-os-takumi.mihoyo.com',
'x-rpc-channel':'hoyolab' 'x-rpc-channel': 'hoyolab'
} }
header = Object.assign({}, header, os_Header) header = Object.assign({}, header, os_Header)
} }

View File

@ -10,24 +10,30 @@ export async function sleepAsync(sleepms) {
export async function randomSleepAsync(end) { export async function randomSleepAsync(end) {
let sleep = 3 * 1000 + _.random((end||5) * 1000); let sleep = 3 * 1000 + _.random((end || 5) * 1000);
await sleepAsync(sleep); await sleepAsync(sleep);
} }
export function randomString(length,os=false) { export function randomString(length, os = false) {
let randomStr = ''; let randomStr = '';
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
randomStr += _.sample(os?'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz':'abcdefghijklmnopqrstuvwxyz0123456789'); randomStr += _.sample(os ? '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' :
'abcdefghijklmnopqrstuvwxyz0123456789');
} }
return randomStr; return randomStr;
} }
export async function redisGet(userId,type='bbs'){ export async function redisGet(userId, type = 'bbs') {
await redis.get(`xiaoyao:${type}:${userId}`); await redis.get(`xiaoyao:${type}:${userId}`);
} }
export async function redisSet(userId,type='bbs',data){ export async function redisSet(userId="all", type = 'bbs', data, time=0) {
var time = moment(Date.now()).add('days', 1).format('YYYY-MM-DD 00:00:00') 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 //获取隔天凌晨的时间差 var new_date = (new Date(time).getTime() - new Date().getTime()) / 1000 //获取隔天凌晨的时间差
await redis.set(`xiaoyao:${type}:${userId}`,JSON.stringify(data),{EX:parseInt(new_date)}); if (time!==0) {
new_date = time
}
await redis.set(`xiaoyao:${type}:${userId}`, JSON.stringify(data), {
EX: parseInt(new_date)
});
} }
/** /**
* 发送私聊消息仅给好友发送 * 发送私聊消息仅给好友发送
@ -61,14 +67,14 @@ export async function replyMake(e, _msg, lenght) {
user_id: Bot.uin user_id: Bot.uin
}) })
} }
if(e._reply){ if (e._reply) {
e._reply(await Bot.makeForwardMsg(msgList)); e._reply(await Bot.makeForwardMsg(msgList));
}else { } else {
e.reply(await Bot.makeForwardMsg(msgList)); e.reply(await Bot.makeForwardMsg(msgList));
} }
} }
export function getServer (uid) { export function getServer(uid) {
switch (String(uid)[0]) { switch (String(uid)[0]) {
case '1': case '1':
case '2': case '2':
@ -94,13 +100,16 @@ export async function getCookieMap(cookie) {
if (!entry[0]) continue; if (!entry[0]) continue;
cookieMap.set(entry[0], entry[1]); cookieMap.set(entry[0], entry[1]);
} }
return cookieMap||{}; return cookieMap || {};
} }
export default { export default {
sleepAsync,getServer, sleepAsync,
getServer,
randomSleepAsync, randomSleepAsync,
replyMake, replyMake,
randomString,redisGet,redisSet, randomString,
redisGet,
redisSet,
relpyPrivate, relpyPrivate,
getCookieMap getCookieMap
} }

View File

@ -76,8 +76,8 @@ export default class user {
} }
return sumData; return sumData;
} }
async getData(type, data = {},isck=true) { async getData(type, data = {}, isck = true) {
if(isck){ if (isck) {
await this.cookie(this.e) await this.cookie(this.e)
} }
this.miHoYoApi = new miHoYoApi(this.e); this.miHoYoApi = new miHoYoApi(this.e);
@ -110,29 +110,46 @@ export default class user {
if (res?.data?.is_sign) { if (res?.data?.is_sign) {
message += `${item.nickname}-${item.game_uid}:今日已签到~\n`; message += `${item.nickname}-${item.game_uid}:今日已签到~\n`;
} else { } else {
for (let i = 0; i < 2; i++) { //循环请求
let signTime = await redis.get(`xiaoyao:sign`)
if (signTime) {
//有数据的时候不得行必须出去
if (!mysTask) {
message += "${item.nickname}-${item.game_uid}:验证码失败请等待6分钟后重试或者手动上米游社签到~";
break;
} else {
await utils.sleepAsync(60000 * 6) //等6分钟再说
//ps你要是觉得改有加高过的概率就改吧随便你反正到时候黑IP的不是我
}
}
res = await this.getData("sign", data) res = await this.getData("sign", data)
if (res?.data?.gt) { //去除geetest await utils.sleepAsync(2000)
// let validate = await geetest(res.data) if (res?.data?.gt) { //进行3次验证码访问签到加高通过概率
// if (validate) { let validate = await this.geetest(res.data)
// let header = {} if (validate) {
// header["x-rpc-challenge"] = res["data"]["challenge"] let header = {}
// header["x-rpc-validate"] = validate header["x-rpc-challenge"] = res["data"]["challenge"]
// header["x-rpc-seccode"] = `${validate}|jordan` header["x-rpc-validate"] = validate
// data.headers = header header["x-rpc-seccode"] = `${validate}|jordan`
// res = await this.getData("sign", data) data.headers = header
// if (!res?.data?.gt) { res = await this.getData("sign", data)
// message += `${item.nickname}-${item.game_uid}:验证码签到成功~` if (!res?.data?.gt) {
// } else { message += `${item.nickname}-${item.game_uid}:验证码签到成功~\n`
break;
} else {
item.is_sign = false; item.is_sign = false;
message += `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`; message +=
// } `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
// } }
}
} else { } else {
item.total_sign_day++; item.total_sign_day++;
message += message +=
`${item.nickname}-${item.game_uid}${res.message=="OK"?"签到成功":res.message}\n` `${item.nickname}-${item.game_uid}${res.message=="OK"?"签到成功":res.message}\n`
} }
} }
await utils.sleepAsync(2000)
}
//获取签到信息和奖励信息 //获取签到信息和奖励信息
const SignInfo = await this.getData("home", data) const SignInfo = await this.getData("home", data)
if (SignInfo) { if (SignInfo) {
@ -206,10 +223,10 @@ export default class user {
challenge = '', challenge = '',
res; res;
try { try {
res=await this.bbsSeachSign() res = await this.bbsSeachSign()
if(res?.data?.can_get_points==0){ if (res?.data?.can_get_points == 0) {
return { return {
message:`签到任务已完成,无需重复签到` message: `签到任务已完成,无需重复签到`
} }
} }
for (let forum of forumData) { for (let forum of forumData) {
@ -344,7 +361,6 @@ export default class user {
// let ck=`${dir}${qq*1}.yaml` // let ck=`${dir}${qq*1}.yaml`
// let cklis=fs.readFileSync(ck, 'utf-8') // let cklis=fs.readFileSync(ck, 'utf-8')
// cklist=YAML.parse(cklis) // cklist=YAML.parse(cklis)
// console.log(cklist)
// }else{ // }else{
// cklist=NoteCookie[qq*1] // cklist=NoteCookie[qq*1]
// } // }
@ -539,6 +555,10 @@ export default class user {
if (res?.data?.validate) { if (res?.data?.validate) {
let validate = res?.data?.validate let validate = res?.data?.validate
return validate return validate
} else if (res?.data?.result !== "slide") {
await redis.set(`xiaoyao:sign`, 1, { //写入缓存 过不了了
EX: 60 * 6 //等6分钟后再给用指令 避免ddos
});
} }
return "" return ""
} }
@ -623,10 +643,6 @@ export default class user {
loginUid, loginUid,
loginTicket loginTicket
}) })
// this.getData("bbsStoken", {
// loginUid,
// loginTicket
// })
if (res?.data) { if (res?.data) {
datalist[e.uid] = { datalist[e.uid] = {
stuid: map?.get("account_id"), stuid: map?.get("account_id"),