!114 外置插件解决1034
* 优化 * fix * 改一下 * 删除多余的fp * fix * 不重复生成fp * fix * 删log * 外置插件解决1034
This commit is contained in:
parent
444eb45cfc
commit
5c5bf0b69e
|
@ -53,7 +53,7 @@ export default class blueprint extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
async computes (body) {
|
async computes (body) {
|
||||||
let computes = await this.mysApi.getData('blueprintCompute', body)
|
let computes = await this.mysApi.getData('blueprintCompute', { body })
|
||||||
if (!computes || computes.retcode !== 0) return false
|
if (!computes || computes.retcode !== 0) return false
|
||||||
computes = computes.data?.list
|
computes = computes.data?.list
|
||||||
return computes
|
return computes
|
||||||
|
|
|
@ -26,17 +26,14 @@ export default class Calculator extends base {
|
||||||
|
|
||||||
this.mysApi = new MysApi(uid, ck.ck, { log: true })
|
this.mysApi = new MysApi(uid, ck.ck, { log: true })
|
||||||
|
|
||||||
let seed_id = lodash.sample('abcdefghijklmnopqrstuvwxyz0123456789', 16).replace(/,/g, '')
|
let device_fp = await MysInfo.get(this.e, 'getFp')
|
||||||
let device_fp = await MysInfo.get(this.e, 'getFp', {
|
|
||||||
seed_id
|
|
||||||
})
|
|
||||||
this.headers = {
|
this.headers = {
|
||||||
'x-rpc-device_fp': device_fp?.data?.device_fp
|
'x-rpc-device_fp': device_fp?.data?.device_fp
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取角色数据 */
|
/** 获取角色数据 */
|
||||||
let character = await MysInfo.get(this.e, this.e.isSr ? 'avatarInfo' : 'character', {
|
let character = await MysInfo.get(this.e, this.e.isSr ? 'avatarInfo' : 'character', {
|
||||||
headers: this.headers,
|
headers: this.headers
|
||||||
})
|
})
|
||||||
if (!character || character.retcode !== 0) return false
|
if (!character || character.retcode !== 0) return false
|
||||||
character = character.data
|
character = character.data
|
||||||
|
@ -156,7 +153,7 @@ export default class Calculator extends base {
|
||||||
avatar: {
|
avatar: {
|
||||||
item_id: Number(this.role.roleId),
|
item_id: Number(this.role.roleId),
|
||||||
cur_level: Number(this.dataCharacter.level),
|
cur_level: Number(this.dataCharacter.level),
|
||||||
target_level: Number(this.setSkill[0]),
|
target_level: Number(this.setSkill[0])
|
||||||
},
|
},
|
||||||
skill_list: []
|
skill_list: []
|
||||||
}
|
}
|
||||||
|
@ -168,7 +165,6 @@ export default class Calculator extends base {
|
||||||
}
|
}
|
||||||
if (Number(this.setSkill[0]) >= data.min_level_limit) body.skill_list.push(skill)
|
if (Number(this.setSkill[0]) >= data.min_level_limit) body.skill_list.push(skill)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
skillList = skillList.filter((item) => item.max_level != 1)
|
skillList = skillList.filter((item) => item.max_level != 1)
|
||||||
|
|
||||||
|
@ -197,7 +193,7 @@ export default class Calculator extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mysApi.getServer().startsWith('os')) {
|
if (this.mysApi.getServer().startsWith('os')) {
|
||||||
body.lang = "zh-cn"
|
body.lang = 'zh-cn'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.e.isSr) {
|
if (this.e.isSr) {
|
||||||
|
@ -219,7 +215,6 @@ export default class Calculator extends base {
|
||||||
level_current: Number(this.dataCharacter.weapon.level),
|
level_current: Number(this.dataCharacter.weapon.level),
|
||||||
level_target: Number(this.setSkill[1])
|
level_target: Number(this.setSkill[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +238,10 @@ export default class Calculator extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
async computes (body) {
|
async computes (body) {
|
||||||
let computes = await MysInfo.get(this.e, 'compute', body)
|
let computes = await MysInfo.get(this.e, 'compute', {
|
||||||
|
body,
|
||||||
|
headers: this.headers
|
||||||
|
})
|
||||||
if (!computes || computes.retcode !== 0) return false
|
if (!computes || computes.retcode !== 0) return false
|
||||||
computes = computes.data
|
computes = computes.data
|
||||||
|
|
||||||
|
|
|
@ -66,11 +66,11 @@ export default class apiTool {
|
||||||
/** 养成计算器 */
|
/** 养成计算器 */
|
||||||
compute: {
|
compute: {
|
||||||
url: `${host}event/e20200928calculate/v2/compute`,
|
url: `${host}event/e20200928calculate/v2/compute`,
|
||||||
body: data
|
body: data.body
|
||||||
},
|
},
|
||||||
blueprintCompute: {
|
blueprintCompute: {
|
||||||
url: `${host}event/e20200928calculate/v1/furniture/compute`,
|
url: `${host}event/e20200928calculate/v1/furniture/compute`,
|
||||||
body: data
|
body: data.body
|
||||||
},
|
},
|
||||||
/** 养成计算器 */
|
/** 养成计算器 */
|
||||||
blueprint: {
|
blueprint: {
|
||||||
|
@ -178,7 +178,7 @@ export default class apiTool {
|
||||||
compute: {
|
compute: {
|
||||||
url: `${host}event/rpgcalc/compute?`,
|
url: `${host}event/rpgcalc/compute?`,
|
||||||
query:`game=hkrpg`,
|
query:`game=hkrpg`,
|
||||||
body: data
|
body: data.body
|
||||||
},
|
},
|
||||||
/** 详情 */
|
/** 详情 */
|
||||||
detail: {
|
detail: {
|
||||||
|
@ -197,7 +197,7 @@ export default class apiTool {
|
||||||
urlMap.genshin.blueprint.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/blueprint'
|
urlMap.genshin.blueprint.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/blueprint'
|
||||||
urlMap.genshin.blueprint.query = `share_code=${data.share_code}®ion=${this.server}&lang=zh-cn`
|
urlMap.genshin.blueprint.query = `share_code=${data.share_code}®ion=${this.server}&lang=zh-cn`
|
||||||
urlMap.genshin.blueprintCompute.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/compute'
|
urlMap.genshin.blueprintCompute.url = 'https://sg-public-api.hoyolab.com/event/calculateos/furniture/compute'
|
||||||
urlMap.genshin.blueprintCompute.body = { lang: 'zh-cn', ...data }
|
urlMap.genshin.blueprintCompute.body = { lang: 'zh-cn', ...data.body }
|
||||||
urlMap.genshin.ys_ledger.url = 'https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info'// 支持了国际服札记
|
urlMap.genshin.ys_ledger.url = 'https://hk4e-api-os.mihoyo.com/event/ysledgeros/month_info'// 支持了国际服札记
|
||||||
urlMap.genshin.ys_ledger.query = `lang=zh-cn&month=${data.month}&uid=${this.uid}®ion=${this.server}`
|
urlMap.genshin.ys_ledger.query = `lang=zh-cn&month=${data.month}&uid=${this.uid}®ion=${this.server}`
|
||||||
urlMap.genshin.useCdk.url = 'https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey'
|
urlMap.genshin.useCdk.url = 'https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey'
|
||||||
|
|
|
@ -10,6 +10,8 @@ export default class MysApi {
|
||||||
* @param cookie 米游社cookie
|
* @param cookie 米游社cookie
|
||||||
* @param option 其他参数
|
* @param option 其他参数
|
||||||
* @param option.log 是否显示日志
|
* @param option.log 是否显示日志
|
||||||
|
* @param isSr 是否星铁
|
||||||
|
* @param device 设备device_id
|
||||||
*/
|
*/
|
||||||
constructor (uid, cookie, option = {}, isSr = false, device = '') {
|
constructor (uid, cookie, option = {}, isSr = false, device = '') {
|
||||||
this.uid = uid
|
this.uid = uid
|
||||||
|
@ -37,12 +39,12 @@ export default class MysApi {
|
||||||
let urlMap = this.apiTool.getUrlMap({ ...data, deviceId: this.device })
|
let urlMap = this.apiTool.getUrlMap({ ...data, deviceId: this.device })
|
||||||
if (!urlMap[type]) return false
|
if (!urlMap[type]) return false
|
||||||
|
|
||||||
let { url, query = '', body = '', sign = '' } = urlMap[type]
|
let { url, query = '', body = '' } = urlMap[type]
|
||||||
|
|
||||||
if (query) url += `?${query}`
|
if (query) url += `?${query}`
|
||||||
if (body) body = JSON.stringify(body)
|
if (body) body = JSON.stringify(body)
|
||||||
|
|
||||||
let headers = this.getHeaders(query, body, sign)
|
let headers = this.getHeaders(query, body)
|
||||||
|
|
||||||
return { url, headers, body }
|
return { url, headers, body }
|
||||||
}
|
}
|
||||||
|
@ -64,26 +66,11 @@ export default class MysApi {
|
||||||
case '9':
|
case '9':
|
||||||
return this.isSr ? 'prod_official_cht' : 'os_cht' // 港澳台服
|
return this.isSr ? 'prod_official_cht' : 'os_cht' // 港澳台服
|
||||||
}
|
}
|
||||||
return 'cn_gf01'
|
return this.isSr ? 'prod_gf_cn' : 'cn_gf01'
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData (type, data = {}, cached = false, isGetFP = false) {
|
async getData (type, data = {}, cached = false) {
|
||||||
if (!isGetFP && !data.device_fp) {
|
if (type == 'getFp') data = { seed_id: this.generateSeed(16) }
|
||||||
let seed_id = this.generateSeed(16)
|
|
||||||
let device_fp = await this.getData('getFp', {
|
|
||||||
seed_id
|
|
||||||
}, false, true)
|
|
||||||
if (!data) {
|
|
||||||
data = {}
|
|
||||||
}
|
|
||||||
if (data?.headers) {
|
|
||||||
data.headers['x-rpc-device_fp'] = device_fp?.data?.device_fp
|
|
||||||
} else {
|
|
||||||
data.headers = {
|
|
||||||
'x-rpc-device_fp': device_fp?.data?.device_fp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let { url, headers, body } = this.getUrl(type, data)
|
let { url, headers, body } = this.getUrl(type, data)
|
||||||
|
|
||||||
if (!url) return false
|
if (!url) return false
|
||||||
|
@ -96,7 +83,6 @@ export default class MysApi {
|
||||||
|
|
||||||
if (data.headers) {
|
if (data.headers) {
|
||||||
headers = { ...headers, ...data.headers }
|
headers = { ...headers, ...data.headers }
|
||||||
delete data.headers
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let param = {
|
let param = {
|
||||||
|
@ -237,4 +223,3 @@ export default class MysApi {
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,8 @@ export default class MysInfo {
|
||||||
// ck对应MysUser对象
|
// ck对应MysUser对象
|
||||||
this.ckUser = null
|
this.ckUser = null
|
||||||
this.auth = ['dailyNote', 'bbs_sign_info', 'bbs_sign_home', 'bbs_sign', 'ys_ledger', 'compute', 'avatarSkill', 'detail', 'blueprint', 'UserGame', 'deckList', 'avatar_cardList', 'action_cardList', 'avatarInfo']
|
this.auth = ['dailyNote', 'bbs_sign_info', 'bbs_sign_home', 'bbs_sign', 'ys_ledger', 'compute', 'avatarSkill', 'detail', 'blueprint', 'UserGame', 'deckList', 'avatar_cardList', 'action_cardList', 'avatarInfo']
|
||||||
|
|
||||||
|
this.gtest = false
|
||||||
}
|
}
|
||||||
|
|
||||||
static async init (e, api) {
|
static async init (e, api) {
|
||||||
|
@ -161,10 +163,35 @@ export default class MysInfo {
|
||||||
let user = e.user?.getMysUser()
|
let user = e.user?.getMysUser()
|
||||||
let mysApi = new MysApi(mysInfo.uid, mysInfo.ckInfo.ck, option, e.isSr, user.device)
|
let mysApi = new MysApi(mysInfo.uid, mysInfo.ckInfo.ck, option, e.isSr, user.device)
|
||||||
|
|
||||||
|
let devicefp = ''
|
||||||
|
if (!data?.headers?.['x-rpc-device_fp'] && api !== 'getFp') {
|
||||||
|
devicefp = (await mysApi.getData('getFp')).data?.device_fp
|
||||||
|
if (data?.headers) {
|
||||||
|
data.headers['x-rpc-device_fp'] = devicefp
|
||||||
|
} else {
|
||||||
|
if (!data) data = {}
|
||||||
|
data.headers = {
|
||||||
|
'x-rpc-device_fp': devicefp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let res
|
let res
|
||||||
if (lodash.isObject(api)) {
|
if (lodash.isObject(api)) {
|
||||||
let all = []
|
let all = []
|
||||||
/** 同步请求 */
|
/** 同步请求 */
|
||||||
|
for (let i in api) {
|
||||||
|
if (!api[i]?.headers?.['x-rpc-device_fp']) {
|
||||||
|
if (api[i]?.headers) {
|
||||||
|
api[i].headers['x-rpc-device_fp'] = devicefp
|
||||||
|
} else {
|
||||||
|
if (!api[i]) api[i] = {}
|
||||||
|
api[i].headers = {
|
||||||
|
'x-rpc-device_fp': devicefp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (e.apiSync) {
|
if (e.apiSync) {
|
||||||
res = []
|
res = []
|
||||||
for (let i in api) {
|
for (let i in api) {
|
||||||
|
@ -179,6 +206,7 @@ export default class MysInfo {
|
||||||
|
|
||||||
for (let i in res) {
|
for (let i in res) {
|
||||||
res[i] = await mysInfo.checkCode(res[i], res[i].api, mysApi, api[res[i].api])
|
res[i] = await mysInfo.checkCode(res[i], res[i].api, mysApi, api[res[i].api])
|
||||||
|
mysInfo.gtest = true
|
||||||
|
|
||||||
if (res[i]?.retcode === 0) continue
|
if (res[i]?.retcode === 0) continue
|
||||||
|
|
||||||
|
@ -391,8 +419,14 @@ export default class MysInfo {
|
||||||
if (res.api === 'detail') res.retcode = 0
|
if (res.api === 'detail') res.retcode = 0
|
||||||
break
|
break
|
||||||
case 1034:
|
case 1034:
|
||||||
|
try {
|
||||||
|
res = await Gtest.getvali(mysApi, type, data, this.gtest)
|
||||||
|
} catch (error) { }
|
||||||
|
|
||||||
|
if (!res || res?.retcode == 1034) {
|
||||||
logger.mark(`[米游社查询失败][uid:${this.uid}][qq:${this.userId}] 遇到验证码`)
|
logger.mark(`[米游社查询失败][uid:${this.uid}][qq:${this.userId}] 遇到验证码`)
|
||||||
if (!isTask) this.e.reply('米游社查询遇到验证码,请稍后再试')
|
if (!isTask) this.e.reply('米游社查询遇到验证码,请稍后再试')
|
||||||
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
if (!isTask) this.e.reply(`米游社接口报错,暂时无法查询:${res.message || 'error'}`)
|
if (!isTask) this.e.reply(`米游社接口报错,暂时无法查询:${res.message || 'error'}`)
|
||||||
|
|
|
@ -16,15 +16,10 @@ export default class Note extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData () {
|
async getData () {
|
||||||
let seed_id = lodash.sample('abcdefghijklmnopqrstuvwxyz0123456789', 16).replace(/,/g, '')
|
let device_fp = await MysInfo.get(this.e, 'getFp')
|
||||||
let device_fp = await MysInfo.get(this.e, 'getFp', {
|
let headers = { 'x-rpc-device_fp': device_fp?.data?.device_fp }
|
||||||
seed_id
|
|
||||||
})
|
let res = await MysInfo.get(this.e, 'dailyNote', { headers })
|
||||||
let res = await MysInfo.get(this.e, 'dailyNote', {
|
|
||||||
headers: {
|
|
||||||
'x-rpc-device_fp': device_fp?.data?.device_fp
|
|
||||||
}
|
|
||||||
})
|
|
||||||
let resUser
|
let resUser
|
||||||
if (!res || res.retcode !== 0) return false
|
if (!res || res.retcode !== 0) return false
|
||||||
|
|
||||||
|
@ -33,7 +28,7 @@ export default class Note extends base {
|
||||||
|
|
||||||
let screenData = this.screenData
|
let screenData = this.screenData
|
||||||
if (this.e.isSr) {
|
if (this.e.isSr) {
|
||||||
resUser = await MysInfo.get(this.e, 'UserGame')
|
resUser = await MysInfo.get(this.e, 'UserGame', { headers })
|
||||||
resUser.data?.list?.forEach(v => this.e.uid.includes(v.game_biz))
|
resUser.data?.list?.forEach(v => this.e.uid.includes(v.game_biz))
|
||||||
if (!resUser || resUser.retcode !== 0) return false
|
if (!resUser || resUser.retcode !== 0) return false
|
||||||
}
|
}
|
||||||
|
@ -41,7 +36,8 @@ export default class Note extends base {
|
||||||
name: this.e.sender.card,
|
name: this.e.sender.card,
|
||||||
quality: 80,
|
quality: 80,
|
||||||
...screenData,
|
...screenData,
|
||||||
...data, ...resUser?.data?.list[0]
|
...data,
|
||||||
|
...resUser?.data?.list[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +106,11 @@ export default class Note extends base {
|
||||||
let day = `${week[moment().day()]}`
|
let day = `${week[moment().day()]}`
|
||||||
return {
|
return {
|
||||||
uid: this.e.uid,
|
uid: this.e.uid,
|
||||||
saveId: this.e.uid, icon, day,
|
saveId: this.e.uid,
|
||||||
resinMaxTime, nowDay: moment(new Date()).format('YYYY年MM月DD日'),
|
icon,
|
||||||
|
day,
|
||||||
|
resinMaxTime,
|
||||||
|
nowDay: moment(new Date()).format('YYYY年MM月DD日'),
|
||||||
...data
|
...data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue