mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-23 03:20:52 +08:00
修正部分问题
This commit is contained in:
parent
51ba81f6b0
commit
3f26e8f807
@ -285,7 +285,7 @@ async function dateTime_(time) {
|
|||||||
"深夜";
|
"深夜";
|
||||||
}
|
}
|
||||||
async function getDailyNote(uid, cookie) {
|
async function getDailyNote(uid, cookie) {
|
||||||
let mysApi = new MysApi(uid, cookie)
|
let mysApi = (await import(`file://${_path}/lib/app/mysApi.js`))
|
||||||
let {
|
let {
|
||||||
url,
|
url,
|
||||||
headers,
|
headers,
|
||||||
@ -294,8 +294,7 @@ async function getDailyNote(uid, cookie) {
|
|||||||
} = mysApi.getUrl("dailyNote", uid);
|
} = mysApi.getUrl("dailyNote", uid);
|
||||||
headers.Cookie = cookie;
|
headers.Cookie = cookie;
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: "get",
|
method: "get", headers
|
||||||
headers
|
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ export async function signTask(e){
|
|||||||
}
|
}
|
||||||
export async function cookiesDocHelp(e){
|
export async function cookiesDocHelp(e){
|
||||||
let user = new User(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;
|
return true;
|
||||||
}
|
}
|
||||||
export async function seach(e){
|
export async function seach(e){
|
||||||
@ -82,8 +82,9 @@ export async function bbsSign(e) {
|
|||||||
START = moment().unix();
|
START = moment().unix();
|
||||||
let res = await user.bbsSeachSign()
|
let res = await user.bbsSeachSign()
|
||||||
if(res.isOk&&res?.data?.can_get_points!==0){
|
if(res.isOk&&res?.data?.can_get_points!==0){
|
||||||
let forumData = await user.getDataList(e.msg);
|
let msg=e.msg.replace(/(米游社|mys|社区|签到|#)/g,"")
|
||||||
e.reply(`开始尝试${e.msg}社区签到预计${e.msg=='全部'?"10-20":"1-3"}分钟~`)
|
let forumData = await user.getDataList(msg);
|
||||||
|
e.reply(`开始尝试${msg}社区签到预计${msg=='全部'?"10-20":"1-3"}分钟~`)
|
||||||
res=await user.getbbsSign(forumData)
|
res=await user.getbbsSign(forumData)
|
||||||
}
|
}
|
||||||
await replyMsg(e, res.message);
|
await replyMsg(e, res.message);
|
||||||
|
@ -13,21 +13,9 @@ import {
|
|||||||
import fetch from "node-fetch"
|
import fetch from "node-fetch"
|
||||||
import mys from "./mysTool.js"
|
import mys from "./mysTool.js"
|
||||||
const _path = process.cwd();
|
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_ID = utils.randomString(32).toUpperCase();
|
||||||
const DEVICE_NAME = utils.randomString(_.random(1, 10));
|
const DEVICE_NAME = utils.randomString(_.random(1, 10));
|
||||||
const yamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
|
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 = ''
|
let HttpsProxyAgent = ''
|
||||||
// 米游社的版块
|
// 米游社的版块
|
||||||
|
|
||||||
@ -39,17 +27,17 @@ 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= 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,
|
||||||
saltweb:mys.saltWeb,
|
saltweb: mys.saltWeb,
|
||||||
saltSign:mys.salt
|
saltSign: mys.salt
|
||||||
}
|
}
|
||||||
if(this.isOs){
|
if (this.isOs) {
|
||||||
this.apiMap={
|
this.apiMap = {
|
||||||
apiWeb:mys.os_web_api,
|
apiWeb: mys.os_web_api,
|
||||||
saltweb:mys.saltWeb, //os websalt待定中
|
saltweb: mys.saltWeb, //os websalt待定中
|
||||||
saltSign:mys.salt
|
saltSign: mys.salt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// //初始化配置文件
|
// //初始化配置文件
|
||||||
@ -109,8 +97,13 @@ export default class miHoYoApi {
|
|||||||
Bot.logger.error(`[接口][${type}][${this.e.uid}] ${response.status} ${response.statusText}`)
|
Bot.logger.error(`[接口][${type}][${this.e.uid}] ${response.status} ${response.statusText}`)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
Bot.logger.mark(`[接口][${type}][${this.e.uid}] ${Date.now() - start}ms`)
|
// Bot.logger.mark(`[接口][${type}][${this.e.uid}] ${Date.now() - start}ms`)
|
||||||
const res = await response.json()
|
let res = await response.text();
|
||||||
|
if (res.startsWith('(')) {
|
||||||
|
res = JSON.parse((res).replace(/\(|\)/g, ""))
|
||||||
|
} else {
|
||||||
|
res = JSON.parse(res)
|
||||||
|
}
|
||||||
if (!res) {
|
if (!res) {
|
||||||
Bot.logger.mark('mys接口没有返回')
|
Bot.logger.mark('mys接口没有返回')
|
||||||
return false
|
return false
|
||||||
@ -129,9 +122,9 @@ export default class miHoYoApi {
|
|||||||
query: `game_biz=${board?.biz}`,
|
query: `game_biz=${board?.biz}`,
|
||||||
types: 'sign'
|
types: 'sign'
|
||||||
},
|
},
|
||||||
isSign: board?.signUrl(data, "isSign",this.apiMap.apiWeb)||{},
|
isSign: board?.signUrl(data, "isSign", this.apiMap.apiWeb) || {},
|
||||||
sign: board?.signUrl(data, "sign",this.apiMap.apiWeb)||{},
|
sign: board?.signUrl(data, "sign", this.apiMap.apiWeb) || {},
|
||||||
home: board?.signUrl(data, "home",this.apiMap.apiWeb)||{},
|
home: board?.signUrl(data, "home", this.apiMap.apiWeb) || {},
|
||||||
//bbs接口 hoyolab那边不是很需要 这边不进行优化处理
|
//bbs接口 hoyolab那边不是很需要 这边不进行优化处理
|
||||||
bbsisSign: { //bbs 签到 (状态查询 米游币查询)
|
bbsisSign: { //bbs 签到 (状态查询 米游币查询)
|
||||||
url: `${mys.bbs_api}/apihub/sapi/getUserMissionsState`,
|
url: `${mys.bbs_api}/apihub/sapi/getUserMissionsState`,
|
||||||
@ -140,24 +133,27 @@ export default class miHoYoApi {
|
|||||||
bbsSign: { //bbs讨论区签到
|
bbsSign: { //bbs讨论区签到
|
||||||
url: `${mys.bbs_api}/apihub/app/api/signIn`,
|
url: `${mys.bbs_api}/apihub/app/api/signIn`,
|
||||||
body: {
|
body: {
|
||||||
gids: data.forumId*1
|
gids: data.forumId * 1
|
||||||
},
|
},
|
||||||
sign: true,
|
sign: true,
|
||||||
types: 'bbs'
|
types: 'bbs'
|
||||||
},
|
},
|
||||||
//人啊不能总想着跳脸 ~~这块给你们留个念想
|
bbsGetCaptcha: {
|
||||||
bbsGetCaptcha:{
|
url: `${mys.bbs_api}/misc/api/createVerification`,
|
||||||
url:`???????????????????????????????????????????????????`,
|
query: `is_high=true`,
|
||||||
|
types: 'bbs'
|
||||||
},
|
},
|
||||||
bbsValidate:{
|
bbsValidate: {
|
||||||
url:`???????????????????????????????????????????????????`,
|
url: `https://apiv6.geetest.com/ajax.php`,
|
||||||
|
query: `gt=${data.gt}&challenge=${data.challenge}&lang=zh-cn&pt=3&client_type=web_mobile`,
|
||||||
},
|
},
|
||||||
bbsCaptchaVerify:{
|
bbsCaptchaVerify: {
|
||||||
url:`???????????????????????????????????????????????????`
|
url: `${mys.bbs_api}/misc/api/verifyVerification`
|
||||||
},
|
},
|
||||||
bbs_Businesses_url:{
|
//待定接口 用于获取用户米游社顶部的模块栏
|
||||||
url:`${mys.bbs_api}/user/api/getUserBusinesses`,
|
bbs_Businesses_url: {
|
||||||
query:`uid={}` //????
|
url: `${mys.bbs_api}/user/api/getUserBusinesses`,
|
||||||
|
query: `uid={}` //????
|
||||||
},
|
},
|
||||||
bbsPostList: { //bbs讨论区签到
|
bbsPostList: { //bbs讨论区签到
|
||||||
url: `${mys.bbs_api}/post/api/getForumPostList`,
|
url: `${mys.bbs_api}/post/api/getForumPostList`,
|
||||||
@ -212,9 +208,9 @@ export default class miHoYoApi {
|
|||||||
},
|
},
|
||||||
authKey: {
|
authKey: {
|
||||||
url: `${this.apiMap.apiWeb}/binding/api/genAuthKey`,
|
url: `${this.apiMap.apiWeb}/binding/api/genAuthKey`,
|
||||||
body:{
|
body: {
|
||||||
'auth_appid': 'webview_gacha',
|
'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,
|
'game_uid': this.e.uid * 1,
|
||||||
'region': this.e.region,
|
'region': this.e.region,
|
||||||
},
|
},
|
||||||
@ -225,7 +221,7 @@ export default class miHoYoApi {
|
|||||||
let {
|
let {
|
||||||
url,
|
url,
|
||||||
query = '',
|
query = '',
|
||||||
body ='',
|
body = '',
|
||||||
types = '',
|
types = '',
|
||||||
sign = ''
|
sign = ''
|
||||||
} = urlMap[type]
|
} = urlMap[type]
|
||||||
@ -253,7 +249,7 @@ export default class miHoYoApi {
|
|||||||
'x-rpc-device_name': DEVICE_NAME,
|
'x-rpc-device_name': DEVICE_NAME,
|
||||||
'x-rpc-client_type': '2', // 1 - iOS, 2 - Android, 4 - Web
|
'x-rpc-client_type': '2', // 1 - iOS, 2 - Android, 4 - Web
|
||||||
'DS': (sign ? this.getDs2("", JSON.stringify({
|
'DS': (sign ? this.getDs2("", JSON.stringify({
|
||||||
gids: board.forumid*1
|
gids: board.forumid * 1
|
||||||
}), mys.salt2) : this.getDs(mys.salt)),
|
}), mys.salt2) : this.getDs(mys.salt)),
|
||||||
"Referer": "https://app.mihoyo.com",
|
"Referer": "https://app.mihoyo.com",
|
||||||
"x-rpc-sys_version": "12",
|
"x-rpc-sys_version": "12",
|
||||||
@ -277,8 +273,8 @@ export default class miHoYoApi {
|
|||||||
DS: this.getDs(),
|
DS: this.getDs(),
|
||||||
'Cookie': this.cookie
|
'Cookie': this.cookie
|
||||||
}
|
}
|
||||||
if(this.isOs){
|
if (this.isOs) {
|
||||||
let os_Header={
|
let os_Header = {
|
||||||
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`,
|
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',
|
||||||
@ -286,7 +282,7 @@ export default class miHoYoApi {
|
|||||||
X_Requested_With: 'com.mihoyo.hoyolab',
|
X_Requested_With: 'com.mihoyo.hoyolab',
|
||||||
Referer: 'https://webstatic-sea.hoyolab.com'
|
Referer: 'https://webstatic-sea.hoyolab.com'
|
||||||
}
|
}
|
||||||
header=Object.assign({},header,os_Header)
|
header = Object.assign({}, header, os_Header)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "cloud":
|
case "cloud":
|
||||||
|
@ -58,7 +58,6 @@ export default class user {
|
|||||||
}
|
}
|
||||||
let resSign = await this.multiSign(this.ForumData);
|
let resSign = await this.multiSign(this.ForumData);
|
||||||
if (resSign?.upData) {
|
if (resSign?.upData) {
|
||||||
// console.log(resSign?.upData)
|
|
||||||
for (let item of resSign?.upData) {
|
for (let item of resSign?.upData) {
|
||||||
let num = lodash.random(0, 9999);
|
let num = lodash.random(0, 9999);
|
||||||
item.upName = item.upName == "原神" ? "ys" : item.upName == "崩坏3" ? "bh3" : item.upName ==
|
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`;
|
message += `${item.nickname}-${item.game_uid}:今日已签到~\n`;
|
||||||
} else {
|
} else {
|
||||||
res = await this.getData("sign", data)
|
res = await this.getData("sign", data)
|
||||||
if (res?.data?.gt) {
|
if (res?.data?.gt) { //去除geetest
|
||||||
item.is_sign = false;
|
// let validate = await geetest(res.data)
|
||||||
message += `${item.nickname}-${item.game_uid}:签到出现验证码~\n请晚点后重试,或者手动上米游社签到\n`;
|
// 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 {
|
} else {
|
||||||
item.total_sign_day++;
|
item.total_sign_day++;
|
||||||
message +=
|
message +=
|
||||||
@ -169,6 +181,7 @@ export default class user {
|
|||||||
}
|
}
|
||||||
async getbbsSign(forumData) {
|
async getbbsSign(forumData) {
|
||||||
let message = '',
|
let message = '',
|
||||||
|
challenge = '',
|
||||||
res;
|
res;
|
||||||
try {
|
try {
|
||||||
if (bbsTask) {
|
if (bbsTask) {
|
||||||
@ -184,6 +197,13 @@ export default class user {
|
|||||||
res = await this.getData("bbsSign", forum)
|
res = await this.getData("bbsSign", forum)
|
||||||
if (res?.retcode == 1034) {
|
if (res?.retcode == 1034) {
|
||||||
message += `社区签到: 验证码失败\n`;
|
message += `社区签到: 验证码失败\n`;
|
||||||
|
challenge = await this.bbsGeetest()
|
||||||
|
if (challenge) {
|
||||||
|
forum["headers"] = {
|
||||||
|
"x-rpc-challenge": challenge
|
||||||
|
}
|
||||||
|
await this.getData("bbsSign", forum)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message += `社区签到: ${res.message}\n`;
|
message += `社区签到: ${res.message}\n`;
|
||||||
}
|
}
|
||||||
@ -202,12 +222,30 @@ export default class user {
|
|||||||
if (res?.message && res?.retcode == 0) {
|
if (res?.message && res?.retcode == 0) {
|
||||||
trueDetail++;
|
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", {
|
res = await this.getData("bbsVotePost", {
|
||||||
postId
|
postId
|
||||||
})
|
})
|
||||||
if (res?.message && res?.retcode == 0) {
|
if (res?.message && res?.retcode == 0) {
|
||||||
Vote++;
|
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);
|
await utils.randomSleepAsync(2);
|
||||||
}
|
}
|
||||||
let sharePost = postList[0].post;
|
let sharePost = postList[0].post;
|
||||||
@ -447,8 +485,30 @@ export default class user {
|
|||||||
}
|
}
|
||||||
bbsTask = false;
|
bbsTask = false;
|
||||||
}
|
}
|
||||||
async bbsGeetest(){
|
async bbsGeetest() {
|
||||||
let res=await this.getData('bbsGetCaptcha')//?????????????????????????????
|
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) {
|
getyunToken(e) {
|
||||||
let file = `${this.yunPath}${e.user_id}.yaml`
|
let file = `${this.yunPath}${e.user_id}.yaml`
|
||||||
@ -482,8 +542,7 @@ export default class user {
|
|||||||
// e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
|
// e.reply("米游社登录cookie不完整,请前往米游社通行证处重新获取cookie~\ncookies必须包含login_ticket【教程】 " + cookiesDoc)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// let flot = (await miHoYoApi.stoken(cookie, e));
|
let flot = this.stoken(cookie, e)
|
||||||
// console.log(flot)
|
|
||||||
await utils.sleepAsync(1000); //延迟加载防止文件未生成
|
await utils.sleepAsync(1000); //延迟加载防止文件未生成
|
||||||
if (!flot) {
|
if (!flot) {
|
||||||
e.reply("登录失效请重新登录获取cookie发送机器人~")
|
e.reply("登录失效请重新登录获取cookie发送机器人~")
|
||||||
|
Loading…
Reference in New Issue
Block a user