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-10-12 21:16:44 +08:00
parent 51ba81f6b0
commit 3f26e8f807
4 changed files with 115 additions and 60 deletions

View File

@ -285,7 +285,7 @@ async function dateTime_(time) {
"深夜";
}
async function getDailyNote(uid, cookie) {
let mysApi = new MysApi(uid, cookie)
let mysApi = (await import(`file://${_path}/lib/app/mysApi.js`))
let {
url,
headers,
@ -294,8 +294,7 @@ async function getDailyNote(uid, cookie) {
} = mysApi.getUrl("dailyNote", uid);
headers.Cookie = cookie;
const response = await fetch(url, {
method: "get",
headers
method: "get", headers
});
return response;
}

View File

@ -62,7 +62,7 @@ export async function signTask(e){
}
export async function cookiesDocHelp(e){
let user = new User(e);
e.reply(`${e.msg.replace(/帮助|教程|绑定/g,"")}帮助】${await user.docHelp(e.msg)}\ncookies必须包含login_ticket获取后请私发机器人`);
e.reply(`${e.msg.replace(/帮助|教程|绑定/g,"")}帮助】${await user.docHelp(e.msg)}`);
return true;
}
export async function seach(e){
@ -82,8 +82,9 @@ export async function bbsSign(e) {
START = moment().unix();
let res = await user.bbsSeachSign()
if(res.isOk&&res?.data?.can_get_points!==0){
let forumData = await user.getDataList(e.msg);
e.reply(`开始尝试${e.msg}社区签到预计${e.msg=='全部'?"10-20":"1-3"}分钟~`)
let msg=e.msg.replace(/(米游社|mys|社区|签到|#)/g,"")
let forumData = await user.getDataList(msg);
e.reply(`开始尝试${msg}社区签到预计${msg=='全部'?"10-20":"1-3"}分钟~`)
res=await user.getbbsSign(forumData)
}
await replyMsg(e, res.message);

View File

@ -13,21 +13,9 @@ import {
import fetch from "node-fetch"
import mys from "./mysTool.js"
const _path = process.cwd();
// const APP_VERSION = "2.37.1";
// const mhyVersion = "2.11.1";
// const salt = "6J1hde1Wu02eF1DFlLpMjeg2dMloAytL";
// const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v";
// const saltWeb = "Qqx8cyv7kuyD8fTw11SmvXSFHp7iZD29";
// const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9";
// const osSaltWeb = ''; //os 浏览帖子需要用到的salt
const DEVICE_ID = utils.randomString(32).toUpperCase();
const DEVICE_NAME = utils.randomString(_.random(1, 10));
const yamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
// const web_api = `https://api-takumi.mihoyo.com`
// const os_web_api = `https://api-os-takumi.mihoyo.com`
// const os_hk4_api = `https://hk4e-api-os.hoyoverse.com`;
// const hk4_api = `https://hk4e-api.mihoyo.com`;
// const bbs_api = `https://bbs-api.mihoyo.com`;
let HttpsProxyAgent = ''
// 米游社的版块
@ -39,17 +27,17 @@ export default class miHoYoApi {
this.userId = String(e.user_id)
this.yuntoken = e.yuntoken
this.devId = e.devId
this.isOs= this.e?.uid[0]*1>5
this.apiMap={
apiWeb:mys.web_api,
saltweb:mys.saltWeb,
saltSign:mys.salt
this.isOs = this.e?.uid[0] * 1 > 5
this.apiMap = {
apiWeb: mys.web_api,
saltweb: mys.saltWeb,
saltSign: mys.salt
}
if(this.isOs){
this.apiMap={
apiWeb:mys.os_web_api,
saltweb:mys.saltWeb, //os websalt待定中
saltSign:mys.salt
if (this.isOs) {
this.apiMap = {
apiWeb: mys.os_web_api,
saltweb: mys.saltWeb, //os websalt待定中
saltSign: mys.salt
}
}
// //初始化配置文件
@ -109,8 +97,13 @@ export default class miHoYoApi {
Bot.logger.error(`[接口][${type}][${this.e.uid}] ${response.status} ${response.statusText}`)
return false
}
Bot.logger.mark(`[接口][${type}][${this.e.uid}] ${Date.now() - start}ms`)
const res = await response.json()
// Bot.logger.mark(`[接口][${type}][${this.e.uid}] ${Date.now() - start}ms`)
let res = await response.text();
if (res.startsWith('(')) {
res = JSON.parse((res).replace(/\(|\)/g, ""))
} else {
res = JSON.parse(res)
}
if (!res) {
Bot.logger.mark('mys接口没有返回')
return false
@ -129,9 +122,9 @@ export default class miHoYoApi {
query: `game_biz=${board?.biz}`,
types: 'sign'
},
isSign: board?.signUrl(data, "isSign",this.apiMap.apiWeb)||{},
sign: board?.signUrl(data, "sign",this.apiMap.apiWeb)||{},
home: board?.signUrl(data, "home",this.apiMap.apiWeb)||{},
isSign: board?.signUrl(data, "isSign", this.apiMap.apiWeb) || {},
sign: board?.signUrl(data, "sign", this.apiMap.apiWeb) || {},
home: board?.signUrl(data, "home", this.apiMap.apiWeb) || {},
//bbs接口 hoyolab那边不是很需要 这边不进行优化处理
bbsisSign: { //bbs 签到 (状态查询 米游币查询)
url: `${mys.bbs_api}/apihub/sapi/getUserMissionsState`,
@ -140,24 +133,27 @@ export default class miHoYoApi {
bbsSign: { //bbs讨论区签到
url: `${mys.bbs_api}/apihub/app/api/signIn`,
body: {
gids: data.forumId*1
gids: data.forumId * 1
},
sign: true,
types: 'bbs'
},
//人啊不能总想着跳脸 ~~这块给你们留个念想
bbsGetCaptcha:{
url:`???????????????????????????????????????????????????`,
bbsGetCaptcha: {
url: `${mys.bbs_api}/misc/api/createVerification`,
query: `is_high=true`,
types: 'bbs'
},
bbsValidate:{
url:`???????????????????????????????????????????????????`,
bbsValidate: {
url: `https://apiv6.geetest.com/ajax.php`,
query: `gt=${data.gt}&challenge=${data.challenge}&lang=zh-cn&pt=3&client_type=web_mobile`,
},
bbsCaptchaVerify:{
url:`???????????????????????????????????????????????????`
bbsCaptchaVerify: {
url: `${mys.bbs_api}/misc/api/verifyVerification`
},
bbs_Businesses_url:{
url:`${mys.bbs_api}/user/api/getUserBusinesses`,
query:`uid={}` //????
//待定接口 用于获取用户米游社顶部的模块栏
bbs_Businesses_url: {
url: `${mys.bbs_api}/user/api/getUserBusinesses`,
query: `uid={}` //????
},
bbsPostList: { //bbs讨论区签到
url: `${mys.bbs_api}/post/api/getForumPostList`,
@ -212,9 +208,9 @@ export default class miHoYoApi {
},
authKey: {
url: `${this.apiMap.apiWeb}/binding/api/genAuthKey`,
body:{
body: {
'auth_appid': 'webview_gacha',
'game_biz': this.isOs?'hk4e_global':'hk4e_cn',
'game_biz': this.isOs ? 'hk4e_global' : 'hk4e_cn',
'game_uid': this.e.uid * 1,
'region': this.e.region,
},
@ -225,7 +221,7 @@ export default class miHoYoApi {
let {
url,
query = '',
body ='',
body = '',
types = '',
sign = ''
} = urlMap[type]
@ -253,7 +249,7 @@ export default class miHoYoApi {
'x-rpc-device_name': DEVICE_NAME,
'x-rpc-client_type': '2', // 1 - iOS, 2 - Android, 4 - Web
'DS': (sign ? this.getDs2("", JSON.stringify({
gids: board.forumid*1
gids: board.forumid * 1
}), mys.salt2) : this.getDs(mys.salt)),
"Referer": "https://app.mihoyo.com",
"x-rpc-sys_version": "12",
@ -277,8 +273,8 @@ export default class miHoYoApi {
DS: this.getDs(),
'Cookie': this.cookie
}
if(this.isOs){
let os_Header={
if (this.isOs) {
let os_Header = {
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`,
client_type: '2',
@ -286,7 +282,7 @@ export default class miHoYoApi {
X_Requested_With: 'com.mihoyo.hoyolab',
Referer: 'https://webstatic-sea.hoyolab.com'
}
header=Object.assign({},header,os_Header)
header = Object.assign({}, header, os_Header)
}
break;
case "cloud":

View File

@ -58,7 +58,6 @@ export default class user {
}
let resSign = await this.multiSign(this.ForumData);
if (resSign?.upData) {
// console.log(resSign?.upData)
for (let item of resSign?.upData) {
let num = lodash.random(0, 9999);
item.upName = item.upName == "原神" ? "ys" : item.upName == "崩坏3" ? "bh3" : item.upName ==
@ -108,9 +107,22 @@ export default class user {
message += `${item.nickname}-${item.game_uid}:今日已签到~\n`;
} else {
res = await this.getData("sign", data)
if (res?.data?.gt) {
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 +=
@ -169,6 +181,7 @@ export default class user {
}
async getbbsSign(forumData) {
let message = '',
challenge = '',
res;
try {
if (bbsTask) {
@ -184,6 +197,13 @@ export default class user {
res = await this.getData("bbsSign", forum)
if (res?.retcode == 1034) {
message += `社区签到: 验证码失败\n`;
challenge = await this.bbsGeetest()
if (challenge) {
forum["headers"] = {
"x-rpc-challenge": challenge
}
await this.getData("bbsSign", forum)
}
} else {
message += `社区签到: ${res.message}\n`;
}
@ -202,12 +222,30 @@ export default class user {
if (res?.message && res?.retcode == 0) {
trueDetail++;
}
if (res?.retcode == 1034) {
challenge = await this.bbsGeetest()
if (challenge) {
forum["headers"] = {
"x-rpc-challenge": challenge
}
await this.getData("bbsSign", forum)
}
}
res = await this.getData("bbsVotePost", {
postId
})
if (res?.message && res?.retcode == 0) {
Vote++;
}
if (res?.retcode == 1034) {
challenge = await this.bbsGeetest()
if (challenge) {
forum["headers"] = {
"x-rpc-challenge": challenge
}
await this.getData("bbsSign", forum)
}
}
await utils.randomSleepAsync(2);
}
let sharePost = postList[0].post;
@ -447,8 +485,30 @@ export default class user {
}
bbsTask = false;
}
async bbsGeetest(){
let res=await this.getData('bbsGetCaptcha')//?????????????????????????????
async bbsGeetest() {
let res = await this.getData('bbsGetCaptcha') //?????????????????????????????
let challenge = res.data["challenge"]
res = await this.getData("bbsValidate", res.data)
if (res?.data?.validate) {
let validate = res?.data?.validate
res = await this.getData("bbsCaptchaVerify", {
headers: {
"geetest_challenge": challenge,
"geetest_seccode": validate + "|jordan",
"geetest_validate": validate
}
})
return res["data"]["challenge"]
}
return ""
}
async geetest(data) {
let res = await this.getData("validate", data)
if (res?.data?.validate) {
let validate = res?.data?.validate
return validate
}
return ""
}
getyunToken(e) {
let file = `${this.yunPath}${e.user_id}.yaml`
@ -482,8 +542,7 @@ export default class user {
// e.reply("米游社登录cookie不完整请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
return false;
}
// let flot = (await miHoYoApi.stoken(cookie, e));
// console.log(flot)
let flot = this.stoken(cookie, e)
await utils.sleepAsync(1000); //延迟加载防止文件未生成
if (!flot) {
e.reply("登录失效请重新登录获取cookie发送机器人~")