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-08-31 23:26:24 +08:00
parent 16cb65184a
commit 36a300bb28
5 changed files with 181 additions and 86 deletions

View File

@ -1,25 +1,14 @@
# 1.1.8
# 1.1.9
* 优化部分代码以及配置
* 新增指令`#更新抽卡记录`
*必须绑定stoken
* 默认配置文件位于****xiaoyao-cvs-plugin/defSet/config/config.yaml****
*后续叠加配置数据会在此文件中增加
# 1.1.2~1.1.8
* 新增指令`#ck查询`
* 可查询当前cookie绑定状态的签到信息以及米游币信息数据
# 1.1.7
* 新增指令`#米币查询`
* 新增`道具图鉴`图鉴数据
* 修正米游币签到逻辑
* 补充指令`原神签到`
* 由于原神签到有提示验证码问题可能导致签到不了
* 补充指令 `原神签到`以及`米社原神全部签到`进行二次签到避免漏签
# 1.1.6
* 通过发送token以及devId给机器人实现绑定
* 格式支持`ai=*;ci=*;oi=*;ct=***********;si=**************;bi=***********;devId=***********`
* 新增指令`#云原神签到`可进行云原神签到
* 新增指令`#云原神查询`可查询当前绑定token的剩余时间
* 新增云原神自动签到
* 新增`云原神帮助`
# 1.1.5
* 体力模板列表更改为转发形式更具体呈现效果
* 新增自动签到配置
*可在`xiaoyao-cvs-plugin/config/config.yaml`中修改是否启用自动签到
# 1.1.2~1.1.4
* 新增指令`#米游币全部签到`
*为所有存在的stoken进行社区米游币签到
* 新增指令`#米社全部签到`

View File

@ -24,7 +24,7 @@ import {
} from "../components/Changelog.js";
import {
rule as userRule,
userInfo
userInfo,gclog
} from "./user.js"
import {
rule as signRule,
@ -33,11 +33,11 @@ import {
cookiesDocHelp,
signlist,yunSignlist,yunAllSign,
allMysSign,yunSign,sendyunTime,yuntoken,yunHelp,
allSign,bbsSeach
allSign,bbsSeach,delSign
} from "./sign.js"
export {
updateRes,yunSignlist,
signlist,
updateRes,yunSignlist,delSign,
signlist,gclog,
updateMiaoPlugin,userInfo,
sign,bbsSeach,
versionInfo,yunAllSign,

View File

@ -6,7 +6,7 @@ import {
Data
} from "../components/index.js";
import moment from 'moment';
import lodash from 'lodash';
import Common from "../components/Common.js";
import {
isV3
@ -23,8 +23,15 @@ export const rule = {
reg: "^#*(ck|stoken|cookie|cookies|签到)查询$",
describe: "用户个人信息查询"
},
gclog: {
reg: "^#*更新抽卡记录$",
describe: "更新抽卡记录"
}
export async function userInfo(e,{render}){
}
const _path = process.cwd();
export async function userInfo(e, {
render
}) {
let user = new User(e);
e.reply("正在获取角色信息请稍等...")
let sumData = await user.getCkData()
@ -51,3 +58,54 @@ export async function userInfo(e,{render}){
})
return true;
}
export async function gclog(e) {
let user = new User(e);
await user.cookie(e)
if(!e.cookies){
e.reply("暂未绑定stoken\n请先绑定stoken")
return true;
}
let miHoYoApi = new MihoYoApi(e);
let kkbody = await miHoYoApi.getbody("原神");
const objData = await miHoYoApi.getUserInfo(kkbody)
let data = objData.data
e.region = e.uid[0] == 5 ? "cn_qd01" : "cn_gf01"
let authkeyrow = await miHoYoApi.authkey(data);
let authkey=authkeyrow.data["authkey"]
let postdata = {
'authkey_ver': '1',
'sign_type': '2',
'auth_appid': 'webview_gacha',
'init_type': '301',
'gacha_id': 'fecafa7b6560db5f3182222395d88aaa6aaac1bc',
'timestamp': Math.floor(Date.now() / 1000), //当前时间搓
'lang': 'zh-cn',
'device_type': 'mobile',
'plat_type': 'ios',
'region': e.region,
'authkey': encodeURIComponent(authkey),
'game_biz': 'hk4e_cn',
'gacha_type': "301",
'page': 1,
'size': 5,
'end_id': 0,
}
let url = `https://hk4e-api.mihoyo.com/event/gacha_info/api/getGachaLog?`
for (let item of Object.keys(postdata)) {
url += `${item}=${postdata[item]}&`
}
let plyurl = url.substring(0, url.length - 1);
e.msg=plyurl
if(isV3){
let gclog= (await import(`file:///${_path}/plugins/genshin/model/gachaLog.js`)).default
await (new gclog(e)).logUrl()
} else {
let {
bing
} = (await import(`file:///${_path}/lib/app/gachaLog.js`))
e.isPrivate = true;
await bing(e)
}
return true;
}

View File

@ -12,15 +12,20 @@ import {
isV3
} from '../../components/Changelog.js';
import fetch from "node-fetch"
const APP_VERSION = "2.35.2";
const mhyVersion = "2.11.1";
const salt = "ZSHlXeQUBis52qD1kEgKt5lUYed4b7Bb";
const salt2 = "t0qEgfub6cvueAPgR5m9aQWWVciEer7v";
const saltWeb = "N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep";
const oldsalt = "z8DRIUjNDT7IT5IZXvrUAxyupA1peND9";
//b253c83ab2609b1b600eddfe974df47b
const DEVICE_ID = utils.randomString(32).toUpperCase();
const DEVICE_NAME = utils.randomString(_.random(1, 10));
const _path = process.cwd();
let YamlDataUrl = `${_path}/plugins/xiaoyao-cvs-plugin/data/yaml`;
let web_api = `https://api-takumi.mihoyo.com`
let hk4_api = `https://hk4e-api.mihoyo.com`;
// 米游社的版块
const boards = {
honkai3rd: {
@ -82,7 +87,7 @@ const boards = {
url: "https://bbs.mihoyo.com/zzz/"
}
}
let web_api = `https://api-takumi.mihoyo.com`
export default class MihoYoApi {
constructor(e) {
if (e) {
@ -137,7 +142,8 @@ export default class MihoYoApi {
} else {
item.total_sign_day++;
item.is_sign = true;
message += `游戏id${item.nickname}-${item.game_uid}${objshuj.message=="OK"?"签到成功":objshuj.message}\n`
message +=
`游戏id${item.nickname}-${item.game_uid}${objshuj.message=="OK"?"签到成功":objshuj.message}\n`
}
}
//获取签到信息和奖励信息
@ -151,7 +157,8 @@ export default class MihoYoApi {
}
// 签到操作
return {
message,upData
message,
upData
}
} catch (error) {
Bot.logger.mark(`error.message`, error.message)
@ -160,7 +167,9 @@ export default class MihoYoApi {
async forumSign(forumId) {
const url = `https://bbs-api.mihoyo.com/apihub/app/api/signIn`;
this.forumId = forumId;
let res = await superagent.post(url).set(this._getHeader()).send(JSON.stringify({gids:forumId*1})).timeout(10000);
let res = await superagent.post(url).set(this._getHeader()).send(JSON.stringify({
gids: forumId * 1
})).timeout(10000);
let resObj = JSON.parse(res.text);
// Bot.logger.mark(`ForumSign: ${res.text}`);
return resObj;
@ -244,14 +253,11 @@ export default class MihoYoApi {
let reward_msg = item.msg;
url = `https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/ackNotification?id=${reward_id}`;
res = await superagent.post(url).set(this.getyunHeader()).timeout(10000);
let log_msg = `\n领取奖励,ID:${reward_id},Msg:${reward_msg.msg}`;
let log_msg = `\n领取奖励,ID:${reward_id},Msg:${reward_msg}`;
Bot.logger.info(log_msg)
sendMSg += log_msg
}
// log_msg="\n\n"+(await this.logyunGenshen()).log_msg
// sendMSg += log_msg
resObj.sendMSg = sendMSg;
// Bot.logger.info(log_msg)
return resObj;
}
@ -356,7 +362,9 @@ export default class MihoYoApi {
let sign = md5(`salt=${salt}&t=${timestamp}&r=${randomStr}`);
let ds = `${timestamp},${randomStr},${sign}`
if (this.forumId) {
ds = this.get_ds2("",JSON.stringify({gids:this.forumId*1}));
ds = this.get_ds2("", JSON.stringify({
gids: this.forumId * 1
}));
this.forumId = "";
}
return {
@ -395,7 +403,48 @@ export default class MihoYoApi {
"User-Agent": "okhttp/3.14.9"
}
}
//一个奇怪的请求头
getHeader() {
return {
'x-rpc-app_version': mhyVersion,
'User-Agent': `Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/2.11.1`,
'x-rpc-client_type': '5',
'Referer': 'https://webstatic.mihoyo.com/',
'Origin': 'https://webstatic.mihoyo.com',
}
}
old_version_get_ds_token() {
let n = 'N50pqm7FSy2AkFz2B3TqtuZMJ5TOl3Ep'
let i = Math.floor(Date.now() / 1000)
let r = utils.randomString(6)
let c = md5('salt=' + n + '&t=' + i + '&r=' + r)
return i + ',' + r + ',' + c
}
async authkey(e) {
let url = `${web_api}/binding/api/genAuthKey`;
let HEADER = this.getHeader();
HEADER['Cookie'] = this.cookies
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-sys_version'] = '12'
HEADER['x-rpc-client_type'] = '5'
HEADER['x-rpc-channel'] = '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'
let data = {
'auth_appid': 'webview_gacha',
'game_biz': '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);
return resObj
}
getCookieMap(cookie) {
let cookiePattern = /^(\S+)=(\S+)$/;
let cookieArray = cookie.replace(/\s*/g, "").split(";");

View File

@ -18,7 +18,6 @@ export function randomString(length){
let randomStr = '';
for (let i = 0; i < length; i++) {
randomStr += _.sample('abcdefghijklmnopqrstuvwxyz0123456789');
// randomStr += _.sample('dWCcD2FsOUXEstC5f9xubswZxEeoBOTc');
}
return randomStr;
}