Pre Merge pull request !115 from hbj白夜/master
This commit is contained in:
commit
a0b5cfe363
|
@ -1,10 +1,22 @@
|
||||||
# 公共查询是否使用用户ck 0-不使用 1-使用
|
# 公共查询是否使用用户ck 0-不使用 1-使用
|
||||||
allowUseCookie: 1
|
allowUseCookie: 0
|
||||||
# 默认cookie帮助文档链接地址
|
# 默认cookie帮助文档链接地址
|
||||||
cookieDoc: https://docs.qq.com/doc/DUWNVQVFTU3liTVlO
|
cookieDoc: docs.qq.com/doc/DUWNVQVFTU3liTVlO
|
||||||
|
|
||||||
|
|
||||||
|
# 是否开启米游社原神自动签到 1-开启 0-关闭
|
||||||
|
isAutoSign: 0
|
||||||
|
# 自动签到失败超过该次数后停止自动签到,0-无限制,默认5
|
||||||
|
failSignCountCfg: 5
|
||||||
|
# 修改需要重启,米游社原神签到定时任务,Cron表达式,默认00:02开始执行,每6s签到一个
|
||||||
|
signTime: 0 2 0 * * ?
|
||||||
|
|
||||||
# 别名设置权限 0-所有群员都可以添加 1-群管理员才能添加 2-主人才能添加
|
# 别名设置权限 0-所有群员都可以添加 1-群管理员才能添加 2-主人才能添加
|
||||||
abbrSetAuth: 0
|
abbrSetAuth: 0
|
||||||
# 米游社攻略图默认来源设置 1-西风驿站 2-原神观测枢 3-派蒙喵喵屋 4-OH是姜姜呀
|
# 米游社攻略图默认来源设置 1-西风驿站 2-原神观测枢 3-派蒙喵喵屋 4-OH是姜姜呀
|
||||||
defaultSource: 1
|
defaultSource: 1
|
||||||
|
|
||||||
|
# 米游社手动验证 0-关闭 1-开启
|
||||||
|
verify: 1
|
||||||
|
# 米游社手动验证API
|
||||||
|
verifyAddr: 'https://hlhs-nb.cn/GeeTest/register'
|
|
@ -107,6 +107,16 @@ export default class apiTool {
|
||||||
url: 'PLACE_HOLDER',
|
url: 'PLACE_HOLDER',
|
||||||
query: null
|
query: null
|
||||||
},
|
},
|
||||||
|
/** 米游社验证 */
|
||||||
|
createVerification: {
|
||||||
|
url: `${hostRecord}game_record/app/card/wapi/createVerification`,
|
||||||
|
query: 'is_high=true'
|
||||||
|
},
|
||||||
|
/** 米游社验证 */
|
||||||
|
verifyVerification: {
|
||||||
|
url: `${hostRecord}game_record/app/card/wapi/verifyVerification`,
|
||||||
|
body: data
|
||||||
|
},
|
||||||
/** 体力接口fp参数用于避开验证码 */
|
/** 体力接口fp参数用于避开验证码 */
|
||||||
getFp: {
|
getFp: {
|
||||||
url: `https://public-data-api.mihoyo.com/device-fp/api/getFp`,
|
url: `https://public-data-api.mihoyo.com/device-fp/api/getFp`,
|
||||||
|
@ -180,6 +190,17 @@ export default class apiTool {
|
||||||
query:`game=hkrpg`,
|
query:`game=hkrpg`,
|
||||||
body: data
|
body: data
|
||||||
},
|
},
|
||||||
|
/** 米游社验证 */
|
||||||
|
createVerification: {
|
||||||
|
url: 'https://bbs-api.mihoyo.com/misc/api/createVerification',
|
||||||
|
query: 'is_high=true',
|
||||||
|
sign: true
|
||||||
|
},
|
||||||
|
/** 米游社验证 */
|
||||||
|
verifyVerification: {
|
||||||
|
url: 'https://bbs-api.mihoyo.com/misc/api/verifyVerification',
|
||||||
|
body: data
|
||||||
|
},
|
||||||
/** 详情 */
|
/** 详情 */
|
||||||
detail: {
|
detail: {
|
||||||
url: `${host}event/rpgcalc/avatar/detail`,
|
url: `${host}event/rpgcalc/avatar/detail`,
|
||||||
|
@ -189,7 +210,13 @@ export default class apiTool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.server.startsWith('os')) {
|
if (this.server.startsWith('os')) {
|
||||||
urlMap.genshin.detail.url = 'https://sg-public-api.hoyolab.com/event/calculateos/sync/avatar/detail'// 角色天赋详情
|
urlMap.genshin.bbs_sign_info.url = 'https://hk4e-api-os.hoyoverse.com/event/sol/info'
|
||||||
|
urlMap.genshin.bbs_sign_info.query = `act_id=e202102251931481®ion=${this.server}&uid=${this.uid}`
|
||||||
|
urlMap.genshin.bbs_sign_home.url = 'https://hk4e-api-os.hoyoverse.com/event/sol/home'
|
||||||
|
urlMap.genshin.bbs_sign_home.query = `act_id=e202102251931481®ion=${this.server}&uid=${this.uid}`
|
||||||
|
urlMap.genshin.bbs_sign.url = 'https://hk4e-api-os.hoyoverse.com/event/sol/sign'
|
||||||
|
urlMap.genshin.bbs_sign.body = { act_id: 'e202102251931481', region: this.server, uid: this.uid }
|
||||||
|
urlMap.genshin.detail.url = 'https://sg-public-api.hoyolab.com/event/calculateos/sync/avatar/detail' // 角色天赋详情
|
||||||
urlMap.genshin.detail.query = `lang=zh-cn&uid=${this.uid}®ion=${this.server}&avatar_id=${data.avatar_id}`
|
urlMap.genshin.detail.query = `lang=zh-cn&uid=${this.uid}®ion=${this.server}&avatar_id=${data.avatar_id}`
|
||||||
urlMap.genshin.avatarSkill.url = 'https://sg-public-api.hoyolab.com/event/calculateos/avatar/skill_list'// 查询未持有的角色天赋
|
urlMap.genshin.avatarSkill.url = 'https://sg-public-api.hoyolab.com/event/calculateos/avatar/skill_list'// 查询未持有的角色天赋
|
||||||
urlMap.genshin.avatarSkill.query = `lang=zh-cn&avatar_id=${data.avatar_id}`
|
urlMap.genshin.avatarSkill.query = `lang=zh-cn&avatar_id=${data.avatar_id}`
|
||||||
|
@ -203,6 +230,15 @@ export default class apiTool {
|
||||||
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'
|
||||||
urlMap.genshin.useCdk.query = `uid=${this.uid}®ion=${this.server}&lang=zh-cn&cdkey=${data.cdk}&game_biz=hk4e_global`
|
urlMap.genshin.useCdk.query = `uid=${this.uid}®ion=${this.server}&lang=zh-cn&cdkey=${data.cdk}&game_biz=hk4e_global`
|
||||||
}
|
}
|
||||||
|
if (this.isSr && this.server.includes('official')) {
|
||||||
|
urlMap.honkaisr.bbs_sign.url = 'https://sg-public-api.hoyolab.com/event/luna/os/sign'
|
||||||
|
urlMap.honkaisr.bbs_sign.body = { act_id: 'e202303301540311', lang: 'zh-cn' }
|
||||||
|
urlMap.honkaisr.bbs_sign_home.url = 'https://sg-public-api.hoyolab.com/event/luna/os/home'
|
||||||
|
urlMap.honkaisr.bbs_sign_home.query = `act_id=e202303301540311®ion=${this.server}&uid=${this.uid}&lang=zh-cn`
|
||||||
|
|
||||||
|
urlMap.honkaisr.bbs_sign_info.url = 'https://sg-public-api.hoyolab.com/event/luna/os/info'
|
||||||
|
urlMap.honkaisr.bbs_sign_info.query = `act_id=e202303301540311®ion=${this.server}&uid=${this.uid}&lang=zh-cn`
|
||||||
|
}
|
||||||
return urlMap[this.game]
|
return urlMap[this.game]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import MysApi from './mysApi.js'
|
import MysApi from './mysApi.js'
|
||||||
import GsCfg from '../gsCfg.js'
|
import GsCfg from '../gsCfg.js'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
|
import fetch from 'node-fetch'
|
||||||
import NoteUser from './NoteUser.js'
|
import NoteUser from './NoteUser.js'
|
||||||
import MysUser from './MysUser.js'
|
import MysUser from './MysUser.js'
|
||||||
import DailyCache from './DailyCache.js'
|
import DailyCache from './DailyCache.js'
|
||||||
|
import common from '../../../../lib/common/common.js'
|
||||||
|
|
||||||
export default class MysInfo {
|
export default class MysInfo {
|
||||||
static tips = '请先#绑定cookie\n发送【体力帮助】查看配置教程'
|
static tips = '请先#绑定cookie\n发送【体力帮助】查看配置教程'
|
||||||
|
@ -69,6 +71,17 @@ export default class MysInfo {
|
||||||
return mysInfo
|
return mysInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getNoteUser(e) {
|
||||||
|
await MysInfo.initCache()
|
||||||
|
let user = await NoteUser.create(e)
|
||||||
|
if (user) {
|
||||||
|
// 强制读取一次ck,防止一些问题
|
||||||
|
user._getCkData()
|
||||||
|
return user
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取UID
|
* 获取UID
|
||||||
* @param e
|
* @param e
|
||||||
|
@ -134,6 +147,23 @@ export default class MysInfo {
|
||||||
return selfUser.getUid(e)
|
return selfUser.getUid(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 判断绑定ck才能查询 */
|
||||||
|
checkAuth(api) {
|
||||||
|
if (api === 'cookie') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (lodash.isObject(api)) {
|
||||||
|
for (let i in api) {
|
||||||
|
if (this.auth.includes(i)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (this.auth.includes(api)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param e
|
* @param e
|
||||||
* @param e.apiSync 多个请求时是否同步请求
|
* @param e.apiSync 多个请求时是否同步请求
|
||||||
|
@ -187,10 +217,52 @@ export default class MysInfo {
|
||||||
} else {
|
} else {
|
||||||
res = await mysApi.getData(api, data)
|
res = await mysApi.getData(api, data)
|
||||||
res = await mysInfo.checkCode(res, api, mysApi, data)
|
res = await mysInfo.checkCode(res, api, mysApi, data)
|
||||||
|
if (res === 'repeat') {
|
||||||
|
res = await mysApi.getData(api, data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
async checkReply() {
|
||||||
|
if (this.e.noTips === true) return
|
||||||
|
|
||||||
|
if (!this.uid) {
|
||||||
|
this.e.reply('请先#绑定uid')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.ckInfo.ck) {
|
||||||
|
this.e.reply('暂无可用CK,请绑定更多用户或设置公共ck..')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.e.noTips = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 获取请求所需ck */
|
||||||
|
/**
|
||||||
|
* 获取请求所需CK
|
||||||
|
* @param game 游戏
|
||||||
|
* @param onlySelfCk 是否只获取uid自己对应的ck。为true则只获取uid对应ck,若无则返回为空
|
||||||
|
* @returns {Promise<string|string|*>} 查询ck,获取失败则返回空
|
||||||
|
*/
|
||||||
|
async getCookie(game = 'gs', onlySelfCk = false) {
|
||||||
|
if (this.ckUser?.ck) return this.ckUser?.ck
|
||||||
|
|
||||||
|
let mysUser = await MysUser.getByQueryUid(this.uid, game, onlySelfCk)
|
||||||
|
if (mysUser) {
|
||||||
|
if (mysUser.ck) {
|
||||||
|
this.ckInfo = mysUser.getCkInfo()
|
||||||
|
this.ckUser = mysUser
|
||||||
|
// 暂时直接记录请求uid,后期优化分析MysApi请求结果分状态记录结果
|
||||||
|
await mysUser.addQueryUid(this.uid, game)
|
||||||
|
} else {
|
||||||
|
// 重新分配
|
||||||
|
await mysUser.disable(game)
|
||||||
|
return onlySelfCk ? '' : await this.getCookie(game)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.ckUser?.ck
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化公共CK
|
* 初始化公共CK
|
||||||
|
@ -261,81 +333,6 @@ export default class MysInfo {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getBingCkUid() {
|
|
||||||
let res = await GsCfg.getBingCk()
|
|
||||||
return { ...res.ck }
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取uid绑定的ck信息
|
|
||||||
static async checkUidBing(uid, game = 'gs') {
|
|
||||||
let ckUser = await MysUser.getByQueryUid(uid, game, true)
|
|
||||||
if (ckUser && ckUser.ck) {
|
|
||||||
return ckUser
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
static async delDisable() {
|
|
||||||
return await MysUser.delDisable()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 判断绑定ck才能查询 */
|
|
||||||
checkAuth(api) {
|
|
||||||
if (api === 'cookie') {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (lodash.isObject(api)) {
|
|
||||||
for (let i in api) {
|
|
||||||
if (this.auth.includes(i)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (this.auth.includes(api)) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
async checkReply() {
|
|
||||||
if (this.e.noTips === true) return
|
|
||||||
|
|
||||||
if (!this.uid) {
|
|
||||||
this.e.reply('请先#绑定uid')
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.ckInfo.ck) {
|
|
||||||
this.e.reply('暂无可用CK,请绑定更多用户或设置公共ck..')
|
|
||||||
}
|
|
||||||
|
|
||||||
this.e.noTips = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 获取请求所需ck */
|
|
||||||
/**
|
|
||||||
* 获取请求所需CK
|
|
||||||
* @param game 游戏
|
|
||||||
* @param onlySelfCk 是否只获取uid自己对应的ck。为true则只获取uid对应ck,若无则返回为空
|
|
||||||
* @returns {Promise<string|string|*>} 查询ck,获取失败则返回空
|
|
||||||
*/
|
|
||||||
async getCookie(game = 'gs', onlySelfCk = false) {
|
|
||||||
if (this.ckUser?.ck) return this.ckUser?.ck
|
|
||||||
|
|
||||||
let mysUser = await MysUser.getByQueryUid(this.uid, game, onlySelfCk)
|
|
||||||
if (mysUser) {
|
|
||||||
if (mysUser.ck) {
|
|
||||||
this.ckInfo = mysUser.getCkInfo()
|
|
||||||
this.ckUser = mysUser
|
|
||||||
// 暂时直接记录请求uid,后期优化分析MysApi请求结果分状态记录结果
|
|
||||||
await mysUser.addQueryUid(this.uid, game)
|
|
||||||
} else {
|
|
||||||
// 重新分配
|
|
||||||
await mysUser.disable(game)
|
|
||||||
return onlySelfCk ? '' : await this.getCookie(game)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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('米游社接口请求失败,暂时无法查询')
|
||||||
|
@ -391,6 +388,9 @@ export default class MysInfo {
|
||||||
if (res.api === 'detail') res.retcode = 0
|
if (res.api === 'detail') res.retcode = 0
|
||||||
break
|
break
|
||||||
case 1034:
|
case 1034:
|
||||||
|
if (await this.bbsVerification()) {
|
||||||
|
return 'repeat'
|
||||||
|
}
|
||||||
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
|
||||||
|
@ -406,6 +406,47 @@ export default class MysInfo {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 刷新米游社验证 */
|
||||||
|
async bbsVerification () {
|
||||||
|
let create = await MysInfo.get(this.e, 'createVerification')
|
||||||
|
if (!create || create.retcode !== 0) return false
|
||||||
|
|
||||||
|
let verify = await MysInfo.verify(this.e, { uid: this.uid, ...create.data })
|
||||||
|
if (!verify) return false
|
||||||
|
|
||||||
|
let submit = await MysInfo.get(this.e, 'verifyVerification', verify)
|
||||||
|
if (!submit || submit.retcode !== 0) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 手动验证 */
|
||||||
|
static async verify (e, data) {
|
||||||
|
if (!data.gt || !data.challenge || !e?.reply) return false
|
||||||
|
let cfg = { ...GsCfg.getdefSet('mys', 'set'), ...GsCfg.getYaml('mys', 'set', 'config') }
|
||||||
|
if (!cfg.verify || !cfg.verifyAddr) return false
|
||||||
|
|
||||||
|
/** 传递gt、challenge参数,返回link、result地址 */
|
||||||
|
let res = await fetch(cfg.verifyAddr, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify(data)
|
||||||
|
})
|
||||||
|
res = await res.json()
|
||||||
|
if (!res.data) return false
|
||||||
|
|
||||||
|
await e.reply(`请打开地址并完成验证\n${res.data.link}`, true)
|
||||||
|
for (let i = 0; i < 60; i++) {
|
||||||
|
let validate = await fetch(res.data.result)
|
||||||
|
validate = await validate.json()
|
||||||
|
if (validate.data) {
|
||||||
|
logger.mark(`[米游社验证成功][uid:${e.uid || data.uid}][qq:${e.user_id}]`)
|
||||||
|
return validate.data
|
||||||
|
}
|
||||||
|
await common.sleep(2000)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
/** 删除失效ck */
|
/** 删除失效ck */
|
||||||
async delCk() {
|
async delCk() {
|
||||||
if (!this.ckUser) {
|
if (!this.ckUser) {
|
||||||
|
@ -421,4 +462,22 @@ export default class MysInfo {
|
||||||
/** 统计次数设为超限 */
|
/** 统计次数设为超限 */
|
||||||
await this.ckUser.disable(game)
|
await this.ckUser.disable(game)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static async getBingCkUid() {
|
||||||
|
let res = await GsCfg.getBingCk()
|
||||||
|
return { ...res.ck }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取uid绑定的ck信息
|
||||||
|
static async checkUidBing(uid, game = 'gs') {
|
||||||
|
let ckUser = await MysUser.getByQueryUid(uid, game, true)
|
||||||
|
if (ckUser && ckUser.ck) {
|
||||||
|
return ckUser
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
static async delDisable() {
|
||||||
|
return await MysUser.delDisable()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue