!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
|
||||||
|
|
|
@ -5,13 +5,13 @@ import lodash from 'lodash'
|
||||||
import gsCfg from './gsCfg.js'
|
import gsCfg from './gsCfg.js'
|
||||||
|
|
||||||
export default class Calculator extends base {
|
export default class Calculator extends base {
|
||||||
constructor(e) {
|
constructor (e) {
|
||||||
super(e)
|
super(e)
|
||||||
this.model = 'calculator'
|
this.model = 'calculator'
|
||||||
this.checkMsg = `设置角色、武器、技能等级有误\n指令:${e.isSr ? '*克拉拉养成\n示例:*克拉拉养成75 80 6 9 9 9\n参数为角色、武器、普攻、战技、终结技、天赋' : '#刻晴养成\n示例:#刻晴养成81 90 9 9 9\n参数为角色、武器、技能等级'}`
|
this.checkMsg = `设置角色、武器、技能等级有误\n指令:${e.isSr ? '*克拉拉养成\n示例:*克拉拉养成75 80 6 9 9 9\n参数为角色、武器、普攻、战技、终结技、天赋' : '#刻晴养成\n示例:#刻晴养成81 90 9 9 9\n参数为角色、武器、技能等级'}`
|
||||||
}
|
}
|
||||||
|
|
||||||
async get(role) {
|
async get (role) {
|
||||||
this.role = role
|
this.role = role
|
||||||
/** 获取绑定uid */
|
/** 获取绑定uid */
|
||||||
let uid = await MysInfo.getUid(this.e)
|
let uid = await MysInfo.getUid(this.e)
|
||||||
|
@ -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
|
||||||
|
@ -66,7 +63,7 @@ export default class Calculator extends base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSet() {
|
async getSet () {
|
||||||
let defSetSkill = this.e.isSr ? '80,80,6,10,10,10'.split(',') : '90,90,10,10,10'.split(',')
|
let defSetSkill = this.e.isSr ? '80,80,6,10,10,10'.split(',') : '90,90,10,10,10'.split(',')
|
||||||
|
|
||||||
let set = this.e.msg.replace(/#|#|星铁|养成|计算/g, '').trim()
|
let set = this.e.msg.replace(/#|#|星铁|养成|计算/g, '').trim()
|
||||||
|
@ -104,7 +101,7 @@ export default class Calculator extends base {
|
||||||
this.setSkill = setSkill
|
this.setSkill = setSkill
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBody() {
|
async getBody () {
|
||||||
// 技能
|
// 技能
|
||||||
let skillList = []
|
let skillList = []
|
||||||
if (this.dataCharacter) {
|
if (this.dataCharacter) {
|
||||||
|
@ -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])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +223,7 @@ export default class Calculator extends base {
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSkillId(roleId) {
|
async getSkillId (roleId) {
|
||||||
let avatarSkill = await MysInfo.get(this.e, 'avatarSkill', {
|
let avatarSkill = await MysInfo.get(this.e, 'avatarSkill', {
|
||||||
headers: this.headers,
|
headers: this.headers,
|
||||||
avatar_id: roleId
|
avatar_id: roleId
|
||||||
|
@ -242,8 +237,11 @@ export default class Calculator extends base {
|
||||||
return avatarSkill.list
|
return avatarSkill.list
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import DailyCache from './DailyCache.js'
|
||||||
export default class MysInfo {
|
export default class MysInfo {
|
||||||
static tips = '请先#绑定cookie\n发送【体力帮助】查看配置教程'
|
static tips = '请先#绑定cookie\n发送【体力帮助】查看配置教程'
|
||||||
|
|
||||||
constructor(e) {
|
constructor (e) {
|
||||||
if (e) {
|
if (e) {
|
||||||
this.e = e
|
this.e = e
|
||||||
this.userId = String(e.user_id)
|
this.userId = String(e.user_id)
|
||||||
|
@ -26,9 +26,11 @@ 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) {
|
||||||
await MysInfo.initCache()
|
await MysInfo.initCache()
|
||||||
|
|
||||||
let mysInfo = new MysInfo(e)
|
let mysInfo = new MysInfo(e)
|
||||||
|
@ -75,7 +77,7 @@ export default class MysInfo {
|
||||||
* @param matchMsgUid 用于判断消息是否为uid数据
|
* @param matchMsgUid 用于判断消息是否为uid数据
|
||||||
* @returns {Promise<string|boolean|*|string>}
|
* @returns {Promise<string|boolean|*|string>}
|
||||||
*/
|
*/
|
||||||
static async getUid(e, matchMsgUid = true) {
|
static async getUid (e, matchMsgUid = true) {
|
||||||
let user = await NoteUser.create(e)
|
let user = await NoteUser.create(e)
|
||||||
if (e.uid && matchMsgUid) {
|
if (e.uid && matchMsgUid) {
|
||||||
/** 没有绑定的自动绑定 */
|
/** 没有绑定的自动绑定 */
|
||||||
|
@ -119,7 +121,7 @@ export default class MysInfo {
|
||||||
* @param e
|
* @param e
|
||||||
* @returns {Promise<boolean|*>}
|
* @returns {Promise<boolean|*>}
|
||||||
*/
|
*/
|
||||||
static async getSelfUid(e) {
|
static async getSelfUid (e) {
|
||||||
let { msg = '', at = '' } = e
|
let { msg = '', at = '' } = e
|
||||||
if (!msg) return false
|
if (!msg) return false
|
||||||
|
|
||||||
|
@ -152,7 +154,7 @@ export default class MysInfo {
|
||||||
* @param option 配置
|
* @param option 配置
|
||||||
* @param option.log 是否显示请求日志
|
* @param option.log 是否显示请求日志
|
||||||
*/
|
*/
|
||||||
static async get(e, api, data = {}, option = {}) {
|
static async get (e, api, data = {}, option = {}) {
|
||||||
let mysInfo = await MysInfo.init(e, api)
|
let mysInfo = await MysInfo.init(e, api)
|
||||||
|
|
||||||
if (!mysInfo.uid || !mysInfo.ckInfo.ck) return false
|
if (!mysInfo.uid || !mysInfo.ckInfo.ck) return false
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -196,7 +224,7 @@ export default class MysInfo {
|
||||||
* 初始化公共CK
|
* 初始化公共CK
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
static async initPubCk() {
|
static async initPubCk () {
|
||||||
// 初始化公共CK
|
// 初始化公共CK
|
||||||
let pubCount = 0
|
let pubCount = 0
|
||||||
let pubCks = GsCfg.getConfig('mys', 'pubCk') || []
|
let pubCks = GsCfg.getConfig('mys', 'pubCk') || []
|
||||||
|
@ -220,7 +248,7 @@ export default class MysInfo {
|
||||||
* 默认会将用户CK加入查询池
|
* 默认会将用户CK加入查询池
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
static async initUserCk() {
|
static async initUserCk () {
|
||||||
// 初始化用户缓存
|
// 初始化用户缓存
|
||||||
let userCount = 0
|
let userCount = 0
|
||||||
await MysUser.forEach(async (mys) => {
|
await MysUser.forEach(async (mys) => {
|
||||||
|
@ -238,7 +266,7 @@ export default class MysInfo {
|
||||||
* @param clearData 强制初始化时是否清除已有数据 (刷新/重置)
|
* @param clearData 强制初始化时是否清除已有数据 (刷新/重置)
|
||||||
* @returns {Promise<boolean>}
|
* @returns {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
static async initCache(force = false, clearData = false) {
|
static async initCache (force = false, clearData = false) {
|
||||||
// 检查缓存标记
|
// 检查缓存标记
|
||||||
let cache = DailyCache.create()
|
let cache = DailyCache.create()
|
||||||
if (!force && await cache.get('cache-ready')) {
|
if (!force && await cache.get('cache-ready')) {
|
||||||
|
@ -261,13 +289,13 @@ export default class MysInfo {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getBingCkUid() {
|
static async getBingCkUid () {
|
||||||
let res = await GsCfg.getBingCk()
|
let res = await GsCfg.getBingCk()
|
||||||
return { ...res.ck }
|
return { ...res.ck }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取uid绑定的ck信息
|
// 获取uid绑定的ck信息
|
||||||
static async checkUidBing(uid, game = 'gs') {
|
static async checkUidBing (uid, game = 'gs') {
|
||||||
let ckUser = await MysUser.getByQueryUid(uid, game, true)
|
let ckUser = await MysUser.getByQueryUid(uid, game, true)
|
||||||
if (ckUser && ckUser.ck) {
|
if (ckUser && ckUser.ck) {
|
||||||
return ckUser
|
return ckUser
|
||||||
|
@ -275,12 +303,12 @@ export default class MysInfo {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
static async delDisable() {
|
static async delDisable () {
|
||||||
return await MysUser.delDisable()
|
return await MysUser.delDisable()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 判断绑定ck才能查询 */
|
/** 判断绑定ck才能查询 */
|
||||||
checkAuth(api) {
|
checkAuth (api) {
|
||||||
if (api === 'cookie') {
|
if (api === 'cookie') {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -296,7 +324,7 @@ export default class MysInfo {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkReply() {
|
async checkReply () {
|
||||||
if (this.e.noTips === true) return
|
if (this.e.noTips === true) return
|
||||||
|
|
||||||
if (!this.uid) {
|
if (!this.uid) {
|
||||||
|
@ -317,7 +345,7 @@ export default class MysInfo {
|
||||||
* @param onlySelfCk 是否只获取uid自己对应的ck。为true则只获取uid对应ck,若无则返回为空
|
* @param onlySelfCk 是否只获取uid自己对应的ck。为true则只获取uid对应ck,若无则返回为空
|
||||||
* @returns {Promise<string|string|*>} 查询ck,获取失败则返回空
|
* @returns {Promise<string|string|*>} 查询ck,获取失败则返回空
|
||||||
*/
|
*/
|
||||||
async getCookie(game = 'gs', onlySelfCk = false) {
|
async getCookie (game = 'gs', onlySelfCk = false) {
|
||||||
if (this.ckUser?.ck) return this.ckUser?.ck
|
if (this.ckUser?.ck) return this.ckUser?.ck
|
||||||
|
|
||||||
let mysUser = await MysUser.getByQueryUid(this.uid, game, onlySelfCk)
|
let mysUser = await MysUser.getByQueryUid(this.uid, game, onlySelfCk)
|
||||||
|
@ -336,7 +364,7 @@ export default class MysInfo {
|
||||||
return this.ckUser?.ck
|
return this.ckUser?.ck
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkCode(res, type, mysApi = {}, data = {}, isTask = false) {
|
async checkCode (res, type, mysApi = {}, data = {}, isTask = false) {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
if (!isTask) this.e.reply('米游社接口请求失败,暂时无法查询')
|
if (!isTask) this.e.reply('米游社接口请求失败,暂时无法查询')
|
||||||
return false
|
return false
|
||||||
|
@ -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'}`)
|
||||||
|
@ -407,7 +441,7 @@ export default class MysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除失效ck */
|
/** 删除失效ck */
|
||||||
async delCk() {
|
async delCk () {
|
||||||
if (!this.ckUser) {
|
if (!this.ckUser) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -417,7 +451,7 @@ export default class MysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询次数满,今日内标记失效 */
|
/** 查询次数满,今日内标记失效 */
|
||||||
async disableToday(game = 'gs') {
|
async disableToday (game = 'gs') {
|
||||||
/** 统计次数设为超限 */
|
/** 统计次数设为超限 */
|
||||||
await this.ckUser.disable(game)
|
await this.ckUser.disable(game)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +54,7 @@ export default class Note extends base {
|
||||||
let minutes = d.minutes()
|
let minutes = d.minutes()
|
||||||
let seconds = d.seconds()
|
let seconds = d.seconds()
|
||||||
resinMaxTime = hours + '小时' + minutes + '分钟' + seconds + '秒'
|
resinMaxTime = hours + '小时' + minutes + '分钟' + seconds + '秒'
|
||||||
//精确到秒。。。。
|
// 精确到秒。。。。
|
||||||
if (day > 0) {
|
if (day > 0) {
|
||||||
resinMaxTime = day + '天' + hours + '小时' + minutes + '分钟' + seconds + '秒'
|
resinMaxTime = day + '天' + hours + '小时' + minutes + '分钟' + seconds + '秒'
|
||||||
} else if (hours > 0) {
|
} else if (hours > 0) {
|
||||||
|
@ -69,7 +65,7 @@ export default class Note extends base {
|
||||||
resinMaxTime = seconds + '秒'
|
resinMaxTime = seconds + '秒'
|
||||||
}
|
}
|
||||||
if ((day > 0) || (hours > 0) || (seconds > 0)) {
|
if ((day > 0) || (hours > 0) || (seconds > 0)) {
|
||||||
let total_seconds = 3600*hours + 60*minutes + seconds
|
let total_seconds = 3600 * hours + 60 * minutes + seconds
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const dateTimes = now.getTime() + total_seconds * 1000
|
const dateTimes = now.getTime() + total_seconds * 1000
|
||||||
const date = new Date(dateTimes)
|
const date = new Date(dateTimes)
|
||||||
|
@ -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