mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2025-01-22 13:51:10 +08:00
对于原神签到加入geetest绕验证码方法以及延迟修正
This commit is contained in:
parent
7118ecf5a1
commit
8b39d7e3ec
@ -27,9 +27,9 @@ export default class miHoYoApi {
|
||||
this.userId = String(e.user_id)
|
||||
this.yuntoken = e.yuntoken
|
||||
this.devId = e.devId
|
||||
this.isOs=false;
|
||||
if(this.e?.uid){
|
||||
this.isOs=this.e?.uid[0] * 1 > 5
|
||||
this.isOs = false;
|
||||
if (this.e?.uid) {
|
||||
this.isOs = this.e?.uid[0] * 1 > 5
|
||||
}
|
||||
this.apiMap = {
|
||||
apiWeb: mys.web_api,
|
||||
@ -191,6 +191,10 @@ export default class miHoYoApi {
|
||||
query: `login_ticket=${data.loginTicket}&token_types=3&uid=${data.loginUid}`,
|
||||
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: {
|
||||
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/login`,
|
||||
types: 'cloud'
|
||||
@ -202,7 +206,9 @@ export default class miHoYoApi {
|
||||
},
|
||||
cloudGamer: {
|
||||
url: `${mys.cloud_api}/hk4e_cg_cn/gamer/api/ackNotification`,
|
||||
body: {id:data.reward_id},
|
||||
body: {
|
||||
id: data.reward_id
|
||||
},
|
||||
types: 'cloud'
|
||||
},
|
||||
cloudGet: {
|
||||
@ -315,7 +321,7 @@ export default class miHoYoApi {
|
||||
Referer: 'https://app.mihoyo.com',
|
||||
Origin: 'https://webstatic.mihoyo.com',
|
||||
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-channel': 'mihoyo',
|
||||
'x-rpc-device_id': DEVICE_ID,
|
||||
@ -325,16 +331,15 @@ export default class miHoYoApi {
|
||||
}
|
||||
if (this.isOs) {
|
||||
let os_Header = {
|
||||
'x-rpc-app_version':'2.9.0',
|
||||
app_version: '2.9.0',
|
||||
// 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`,
|
||||
'x-rpc-app_version': '2.18.1',
|
||||
app_version: '2.18.1',
|
||||
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',
|
||||
Referer: 'https://app.hoyolab.com',
|
||||
Host: 'api-os-takumi.mihoyo.com',
|
||||
'x-rpc-channel':'hoyolab'
|
||||
'x-rpc-channel': 'hoyolab'
|
||||
}
|
||||
header = Object.assign({}, header, os_Header)
|
||||
}
|
||||
|
@ -10,24 +10,30 @@ export async function sleepAsync(sleepms) {
|
||||
|
||||
|
||||
export async function randomSleepAsync(end) {
|
||||
let sleep = 3 * 1000 + _.random((end||5) * 1000);
|
||||
let sleep = 3 * 1000 + _.random((end || 5) * 1000);
|
||||
await sleepAsync(sleep);
|
||||
}
|
||||
export function randomString(length,os=false) {
|
||||
export function randomString(length, os = false) {
|
||||
let randomStr = '';
|
||||
for (let i = 0; i < length; i++) {
|
||||
randomStr += _.sample(os?'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz':'abcdefghijklmnopqrstuvwxyz0123456789');
|
||||
randomStr += _.sample(os ? '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' :
|
||||
'abcdefghijklmnopqrstuvwxyz0123456789');
|
||||
}
|
||||
return randomStr;
|
||||
}
|
||||
|
||||
export async function redisGet(userId,type='bbs'){
|
||||
await redis.get(`xiaoyao:${type}:${userId}`);
|
||||
export async function redisGet(userId, type = 'bbs') {
|
||||
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 new_date = (new Date(time).getTime() - new Date().getTime()) / 1000 //获取隔天凌晨的时间差
|
||||
await redis.set(`xiaoyao:${type}:${userId}`,JSON.stringify(data),{EX:parseInt(new_date)});
|
||||
var new_date = (new Date(time).getTime() - new Date().getTime()) / 1000 //获取隔天凌晨的时间差
|
||||
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
|
||||
})
|
||||
}
|
||||
if(e._reply){
|
||||
if (e._reply) {
|
||||
e._reply(await Bot.makeForwardMsg(msgList));
|
||||
}else {
|
||||
} else {
|
||||
e.reply(await Bot.makeForwardMsg(msgList));
|
||||
}
|
||||
}
|
||||
|
||||
export function getServer (uid) {
|
||||
export function getServer(uid) {
|
||||
switch (String(uid)[0]) {
|
||||
case '1':
|
||||
case '2':
|
||||
@ -94,13 +100,16 @@ export async function getCookieMap(cookie) {
|
||||
if (!entry[0]) continue;
|
||||
cookieMap.set(entry[0], entry[1]);
|
||||
}
|
||||
return cookieMap||{};
|
||||
return cookieMap || {};
|
||||
}
|
||||
export default {
|
||||
sleepAsync,getServer,
|
||||
sleepAsync,
|
||||
getServer,
|
||||
randomSleepAsync,
|
||||
replyMake,
|
||||
randomString,redisGet,redisSet,
|
||||
randomString,
|
||||
redisGet,
|
||||
redisSet,
|
||||
relpyPrivate,
|
||||
getCookieMap
|
||||
}
|
||||
|
@ -76,8 +76,8 @@ export default class user {
|
||||
}
|
||||
return sumData;
|
||||
}
|
||||
async getData(type, data = {},isck=true) {
|
||||
if(isck){
|
||||
async getData(type, data = {}, isck = true) {
|
||||
if (isck) {
|
||||
await this.cookie(this.e)
|
||||
}
|
||||
this.miHoYoApi = new miHoYoApi(this.e);
|
||||
@ -110,28 +110,45 @@ export default class user {
|
||||
if (res?.data?.is_sign) {
|
||||
message += `${item.nickname}-${item.game_uid}:今日已签到~\n`;
|
||||
} else {
|
||||
res = await this.getData("sign", data)
|
||||
if (res?.data?.gt) { //去除geetest
|
||||
// let validate = await geetest(res.data)
|
||||
// if (validate) {
|
||||
// let header = {}
|
||||
// header["x-rpc-challenge"] = res["data"]["challenge"]
|
||||
// header["x-rpc-validate"] = validate
|
||||
// header["x-rpc-seccode"] = `${validate}|jordan`
|
||||
// data.headers = header
|
||||
// res = await this.getData("sign", data)
|
||||
// if (!res?.data?.gt) {
|
||||
// message += `${item.nickname}-${item.game_uid}:验证码签到成功~`
|
||||
// } else {
|
||||
item.is_sign = false;
|
||||
message += `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
|
||||
// }
|
||||
// }
|
||||
} else {
|
||||
item.total_sign_day++;
|
||||
message +=
|
||||
`${item.nickname}-${item.game_uid}:${res.message=="OK"?"签到成功":res.message}\n`
|
||||
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)
|
||||
await utils.sleepAsync(2000)
|
||||
if (res?.data?.gt) { //进行3次验证码访问签到加高通过概率
|
||||
let validate = await this.geetest(res.data)
|
||||
if (validate) {
|
||||
let header = {}
|
||||
header["x-rpc-challenge"] = res["data"]["challenge"]
|
||||
header["x-rpc-validate"] = validate
|
||||
header["x-rpc-seccode"] = `${validate}|jordan`
|
||||
data.headers = header
|
||||
res = await this.getData("sign", data)
|
||||
if (!res?.data?.gt) {
|
||||
message += `${item.nickname}-${item.game_uid}:验证码签到成功~\n`
|
||||
break;
|
||||
} else {
|
||||
item.is_sign = false;
|
||||
message +=
|
||||
`${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
item.total_sign_day++;
|
||||
message +=
|
||||
`${item.nickname}-${item.game_uid}:${res.message=="OK"?"签到成功":res.message}\n`
|
||||
}
|
||||
}
|
||||
await utils.sleepAsync(2000)
|
||||
}
|
||||
//获取签到信息和奖励信息
|
||||
const SignInfo = await this.getData("home", data)
|
||||
@ -206,10 +223,10 @@ export default class user {
|
||||
challenge = '',
|
||||
res;
|
||||
try {
|
||||
res=await this.bbsSeachSign()
|
||||
if(res?.data?.can_get_points==0){
|
||||
res = await this.bbsSeachSign()
|
||||
if (res?.data?.can_get_points == 0) {
|
||||
return {
|
||||
message:`签到任务已完成,无需重复签到`
|
||||
message: `签到任务已完成,无需重复签到`
|
||||
}
|
||||
}
|
||||
for (let forum of forumData) {
|
||||
@ -344,7 +361,6 @@ export default class user {
|
||||
// let ck=`${dir}${qq*1}.yaml`
|
||||
// let cklis=fs.readFileSync(ck, 'utf-8')
|
||||
// cklist=YAML.parse(cklis)
|
||||
// console.log(cklist)
|
||||
// }else{
|
||||
// cklist=NoteCookie[qq*1]
|
||||
// }
|
||||
@ -539,6 +555,10 @@ export default class user {
|
||||
if (res?.data?.validate) {
|
||||
let validate = res?.data?.validate
|
||||
return validate
|
||||
} else if (res?.data?.result !== "slide") {
|
||||
await redis.set(`xiaoyao:sign`, 1, { //写入缓存 过不了了
|
||||
EX: 60 * 6 //等6分钟后再给用指令 避免ddos
|
||||
});
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -623,10 +643,6 @@ export default class user {
|
||||
loginUid,
|
||||
loginTicket
|
||||
})
|
||||
// this.getData("bbsStoken", {
|
||||
// loginUid,
|
||||
// loginTicket
|
||||
// })
|
||||
if (res?.data) {
|
||||
datalist[e.uid] = {
|
||||
stuid: map?.get("account_id"),
|
||||
|
Loading…
Reference in New Issue
Block a user