mirror of
https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git
synced 2024-12-22 19:10:53 +08:00
修改日志输出
This commit is contained in:
parent
aadcf2c9a2
commit
272381fd2f
@ -18,7 +18,8 @@ export class atlas extends plugin {
|
||||
rule: [rule],
|
||||
})
|
||||
Object.defineProperty(rule, 'log', {
|
||||
get: () => !!this.isDispatch
|
||||
// get: () => !!this.isDispatch
|
||||
get: () =>true
|
||||
})
|
||||
}
|
||||
accept () {
|
||||
|
20
apps/sign.js
20
apps/sign.js
@ -71,6 +71,7 @@ export const rule = {
|
||||
}
|
||||
};
|
||||
init()
|
||||
|
||||
function init() {
|
||||
Data.createDir("", yunpath, false);
|
||||
}
|
||||
@ -128,6 +129,10 @@ export async function mysSign(e) {
|
||||
e.reply("未读取到stoken\n请发送【stoken帮助】查看配置教程配置~")
|
||||
return true;
|
||||
}
|
||||
if (e.uid[0] * 1 > 5) {
|
||||
e.reply("暂不支持hoyolab社区签到~")
|
||||
return true;
|
||||
}
|
||||
START = moment().unix();
|
||||
let resultMessage = "";
|
||||
let resObj=await mysSeach(e)
|
||||
@ -160,7 +165,7 @@ export async function mysSign(e) {
|
||||
return retry(e);
|
||||
});
|
||||
}, RETRY_OPTIONS);
|
||||
Bot.logger.mark(`${e.user_id}:${forum.name} 签到结果: [${resObj.message}]`);
|
||||
Bot.logger.mark(`${e.user_id}:${e.uid}:${forum.name} 签到结果: [${resObj.message}]`);
|
||||
resultMessage += `签到: [${resObj.message}]\n`;
|
||||
} catch (e) {
|
||||
Bot.logger.error(`${forum.name} 签到失败 [${e.message}]`);
|
||||
@ -168,11 +173,11 @@ export async function mysSign(e) {
|
||||
}
|
||||
await utils.randomSleepAsync();
|
||||
}
|
||||
for (let forum of ForumData) {
|
||||
let trueDetail = 0;
|
||||
let Vote = 0;
|
||||
let Share = 0;
|
||||
let sumcount = 0;
|
||||
for (let forum of ForumData) {
|
||||
resultMessage += `\n**${forum.name}**\n`
|
||||
try {
|
||||
// 2 BBS list post
|
||||
@ -234,7 +239,7 @@ export async function mysSign(e) {
|
||||
resultMessage += `共读取帖子记录${20*sumcount}\n浏览成功:${trueDetail}\n点赞成功:${Vote}\n分享成功:${Share}`;
|
||||
await utils.randomSleepAsync();
|
||||
}
|
||||
Bot.logger.mark(`用户qq${e.user_id}${resultMessage}`);
|
||||
Bot.logger.mark(`用户qq${e.user_id}:${e.uid}:${resultMessage}`);
|
||||
await replyMsg(e, resultMessage);
|
||||
return true
|
||||
}
|
||||
@ -298,7 +303,8 @@ async function getDataList(name) {
|
||||
async function cookie(e) {
|
||||
let {
|
||||
cookie,
|
||||
uid,skuid
|
||||
uid,
|
||||
skuid
|
||||
} = await getCookie(e);
|
||||
let miHoYoApi = new MihoYoApi(e);
|
||||
let cookiesDoc = await getcookiesDoc();
|
||||
@ -360,9 +366,13 @@ export async function allMysSign() {
|
||||
Bot.logger.mark(`开始米社米币签到任务`);
|
||||
let stoken = await gsCfg.getBingStoken();
|
||||
let isPushSign = await gsCfg.getfileYaml(`${_path}/plugins/xiaoyao-cvs-plugin/config/`, "config").isPushSign
|
||||
|
||||
//获取需要签到的用户
|
||||
for (let dataUid of stoken) {
|
||||
for (let uuId in dataUid) {
|
||||
if (uuId[0] * 1 > 5) {
|
||||
continue;
|
||||
}
|
||||
let data = dataUid[uuId]
|
||||
let user_id = data.userId * 1;
|
||||
let e = {
|
||||
@ -370,7 +380,7 @@ export async function allMysSign() {
|
||||
isTask: true
|
||||
};
|
||||
e.cookie = `stuid=${data.stuid};stoken=${data.stoken};ltoken=${data.ltoken};`;
|
||||
Bot.logger.mark(`正在为qq${user_id}进行米游币签到中...`);
|
||||
Bot.logger.mark(`正在为qq${user_id}:uid:${uuId}进行米游币签到中...`);
|
||||
e.msg = "全部"
|
||||
e.reply = (msg) => {
|
||||
//关闭签到消息推送
|
||||
|
30
apps/user.js
30
apps/user.js
@ -93,10 +93,11 @@ export async function gclog(e) {
|
||||
return true;
|
||||
}
|
||||
let kkbody = await miHoYoApi.getbody("原神");
|
||||
const objData = await miHoYoApi.getUserInfo(kkbody)
|
||||
let data = objData.data
|
||||
e.region = e.uid[0] * 1 == 5 ? "cn_qd01" : "cn_gf01"
|
||||
let authkeyrow = await miHoYoApi.authkey(data);
|
||||
e.region = getServer(e.uid)
|
||||
// const objData = await miHoYoApi.getUserInfo(kkbody)
|
||||
// let data = objData.data
|
||||
// console.log(data)
|
||||
let authkeyrow = await miHoYoApi.authkey(e);
|
||||
if (!authkeyrow?.data) {
|
||||
e.reply("authkey获取失败:" + authkeyrow.message)
|
||||
return true;
|
||||
@ -125,6 +126,7 @@ export async function gclog(e) {
|
||||
url += `${item}=${postdata[item]}&`
|
||||
}
|
||||
e.msg = url.substring(0, url.length - 1);
|
||||
// e.reply(e.msg)
|
||||
let sendMsg = [];
|
||||
e.reply("抽卡记录获取中请稍等...")
|
||||
e._reply = e.reply;
|
||||
@ -228,6 +230,7 @@ export async function updCookie(e) {
|
||||
sendMsg.push(msg)
|
||||
}
|
||||
for(let item of Object.keys(stoken)){
|
||||
e.region = getServer(stoken[item].uid)
|
||||
miHoYoApi.cookies= `stuid=${stoken[item].stuid};stoken=${stoken[item].stoken};ltoken=${stoken[item].ltoken};`;
|
||||
let resObj = await miHoYoApi.updCookie();
|
||||
if (!resObj?.data) {
|
||||
@ -252,3 +255,22 @@ export async function updCookie(e) {
|
||||
await utils.replyMake(e, sendMsg, 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
function getServer (uid) {
|
||||
switch (String(uid)[0]) {
|
||||
case '1':
|
||||
case '2':
|
||||
return 'cn_gf01' // 官服
|
||||
case '5':
|
||||
return 'cn_qd01' // B服
|
||||
case '6':
|
||||
return 'os_usa' // 美服
|
||||
case '7':
|
||||
return 'os_euro' // 欧服
|
||||
case '8':
|
||||
return 'os_asia' // 亚服
|
||||
case '9':
|
||||
return 'os_cht' // 港澳台服
|
||||
}
|
||||
return 'cn_gf01'
|
||||
}
|
1
index.js
1
index.js
@ -10,6 +10,7 @@ let index = {
|
||||
atlas: {}
|
||||
}
|
||||
if (isV3) {
|
||||
Bot.logger=logger
|
||||
index = await Data.importModule('/plugins/xiaoyao-cvs-plugin/adapter', 'index.js')
|
||||
}
|
||||
export const atlas = index.atlas || {}
|
||||
|
@ -19,6 +19,7 @@ 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));
|
||||
@ -26,8 +27,11 @@ const _path = process.cwd();
|
||||
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 = ''
|
||||
// 米游社的版块
|
||||
const boards = {
|
||||
honkai3rd: {
|
||||
@ -274,15 +278,18 @@ export default class MihoYoApi {
|
||||
}
|
||||
async updCookie() {
|
||||
let url = `${web_api}/auth/api/getCookieAccountInfoBySToken?game_biz=hk4e_cn`;
|
||||
// if(this.e.region.includes("os")){
|
||||
//os接口暂时先不接入
|
||||
// url=`${os_web_api}/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global`;
|
||||
// }
|
||||
// console.log(url)
|
||||
if (this.e.region.includes("os")) {
|
||||
url = `${os_web_api}/auth/api/getCookieAccountInfoBySToken?game_biz=hk4e_global`;
|
||||
}
|
||||
let map = this.getCookieMap(this.cookies)
|
||||
url += `&stoken=${map.get("stoken")}&uid=${map.get("stuid")}`;
|
||||
let res = await superagent.get(url);
|
||||
let resObj = JSON.parse(res.text);
|
||||
let param = {
|
||||
agent: await this.getAgent(),
|
||||
timeout: 10000,
|
||||
method:'get'
|
||||
}
|
||||
let res = await fetch(url, param);
|
||||
let resObj = await res.json()
|
||||
return resObj;
|
||||
}
|
||||
async stoken(cookie, e) {
|
||||
@ -362,10 +369,12 @@ export default class MihoYoApi {
|
||||
//社区签到ds
|
||||
get_ds2(q = "", b) {
|
||||
let n = salt2
|
||||
// n ="6cqshh5dhw73bzxn20oexa9k516chk7s"
|
||||
let i = Math.floor(Date.now() / 1000)
|
||||
let r = _.random(100001, 200000)
|
||||
let add = `&b=${b}&q=${q}`
|
||||
let c = md5("salt=" + n + "&t=" + i + "&r=" + r + add)
|
||||
// this.e.reply("md5"+c)
|
||||
return `${i},${r},${c}`
|
||||
}
|
||||
|
||||
@ -428,35 +437,63 @@ export default class MihoYoApi {
|
||||
}
|
||||
}
|
||||
old_version_get_ds_token() {
|
||||
let n = 'N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep'
|
||||
// 1 测试过的salt很显然都不是 也可能是header参数错误导致无法使用的 另外一个salt加密方法 get_ds
|
||||
// xV8v4Qu44lUKrEYFZkJhB8cuOh9Asafs
|
||||
// 2
|
||||
// t0qEgfub6cvueAPgR5m9aQWWVciEer7v
|
||||
// 3
|
||||
// 599uqkwc0dlqu3h6epzjzfhgyyrd44PR
|
||||
// 4
|
||||
// rk4xg2hakoi26nljpr099fv9fck1ah10
|
||||
// 5 6cqshh5dhw73bzxn20oexa9k516chk7s 签到salt?? 6s25p5ox5y14umn1p61aqyyvbvvl3lrt
|
||||
let n = this.e.region.startsWith('os')?osSaltWeb:'N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep'
|
||||
let i = Math.floor(Date.now() / 1000)
|
||||
let r =utils.randomString(6)
|
||||
let c = md5('salt=' + n + '&t=' + i + '&r=' + r )
|
||||
// this.e.reply("md5"+c)
|
||||
return i + ',' + r + ',' + c
|
||||
}
|
||||
async authkey(e) {
|
||||
let url = `${web_api}/binding/api/genAuthKey`;
|
||||
let isos=this.e.region.startsWith('os')?true:false;
|
||||
let url = `${(isos?os_web_api:web_api)}/binding/api/genAuthKey`;
|
||||
let HEADER = this.getHeader();
|
||||
HEADER['Cookie'] = this.cookies
|
||||
// HEADER['DS'] = this.get_ds2("", JSON.stringify({
|
||||
// gids: 26
|
||||
// }));
|
||||
HEADER['DS'] =this.old_version_get_ds_token()
|
||||
HEADER['User-Agent'] = 'okhttp/4.8.0'
|
||||
HEADER['x-rpc-app_version'] = '2.35.2'
|
||||
HEADER['x-rpc-app_version'] =isos? '2.18.1':'2.35.2'
|
||||
HEADER['x-rpc-sys_version'] = '12'
|
||||
HEADER['x-rpc-client_type'] = '5'
|
||||
HEADER['x-rpc-channel'] = 'mihoyo'
|
||||
HEADER['x-rpc-channel'] =isos?'hoyolab':'mihoyo'
|
||||
HEADER['x-rpc-device_id'] = utils.randomString(32).toUpperCase();
|
||||
HEADER['x-rpc-device_name'] = utils.randomString(_.random(1, 10));
|
||||
HEADER['x-rpc-device_model'] = 'Mi 10'
|
||||
HEADER['Referer'] = 'https://app.mihoyo.com'
|
||||
HEADER['Host'] = 'api-takumi.mihoyo.com'
|
||||
// HEADER['Referer'] = 'https://app.mihoyo.com'
|
||||
// HEADER['Host'] = 'api-takumi.mihoyo.com'
|
||||
HEADER['Referer'] = isos?'https://app.hoyolab.com':'https://app.mihoyo.com'
|
||||
HEADER['Host'] = (isos?os_web_api:web_api).replace(/https:\/\//,"")
|
||||
HEADER['Origin']=(isos?'https://webstatic-sea.hoyolab.com':'https://webstatic.mihoyo.com')
|
||||
let data = {
|
||||
'auth_appid': 'webview_gacha',
|
||||
'game_biz': 'hk4e_cn',
|
||||
'game_biz': isos?'hk4e_global':'hk4e_cn',
|
||||
'game_uid': this.e.uid * 1,
|
||||
'region': this.e.region,
|
||||
}
|
||||
let res = await superagent.post(url).set(HEADER).send(JSON.stringify(data));
|
||||
let resObj = JSON.parse(res.text);
|
||||
let param = {
|
||||
headers:HEADER,
|
||||
agent: await this.getAgent(),
|
||||
timeout: 10000,
|
||||
body:JSON.stringify(data),
|
||||
method:'post'
|
||||
}
|
||||
let res = await fetch(url, param);
|
||||
// console.log(res)
|
||||
let resObj = await res.json()
|
||||
// headers
|
||||
// let res = await superagent.post(url).set(HEADER).send(JSON.stringify(data));
|
||||
// let resObj = JSON.parse(res.text);
|
||||
return resObj
|
||||
}
|
||||
getCookieMap(cookie) {
|
||||
@ -494,14 +531,14 @@ export default class MihoYoApi {
|
||||
async getUserInfo(board) {
|
||||
let url = `${web_api}/binding/api/getUserGameRolesByCookie?game_biz=${board.biz}`
|
||||
// if(this.e.region.includes("os")){
|
||||
//os接口暂时先不接入
|
||||
// 暂时先不接入
|
||||
// url=`${os_web_api}/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global`;
|
||||
// }
|
||||
let res = await superagent.get(url)
|
||||
.set(this
|
||||
.getpubHeaders(board)).timeout(10000);
|
||||
let resObj = JSON.parse(res.text);
|
||||
let data = resObj.data
|
||||
// console.log(resObj)
|
||||
if (resObj.retcode != 0) {
|
||||
return resObj
|
||||
}
|
||||
@ -541,5 +578,26 @@ export default class MihoYoApi {
|
||||
return resObj
|
||||
}
|
||||
|
||||
async getAgent() {
|
||||
if (isV3) {
|
||||
let cfg = await import(`file://${_path}/lib/config/config.js`);
|
||||
let proxyAddress = cfg.default.bot.proxyAddress
|
||||
if (!proxyAddress) return null
|
||||
if (proxyAddress === 'http://0.0.0.0:0') return null
|
||||
|
||||
if (!this.e.region.startsWith('os')) return null
|
||||
|
||||
if (HttpsProxyAgent === '') {
|
||||
HttpsProxyAgent = await import('https-proxy-agent').catch((err) => {
|
||||
logger.error(err)
|
||||
})
|
||||
|
||||
HttpsProxyAgent = HttpsProxyAgent ? HttpsProxyAgent.default : undefined
|
||||
}
|
||||
if (HttpsProxyAgent) {
|
||||
return new HttpsProxyAgent(proxyAddress)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user