适配亚服新UID (#364)
This commit is contained in:
parent
7636951048
commit
14e58fc4ed
|
@ -46,19 +46,21 @@ export class gcLog extends plugin {
|
||||||
})
|
})
|
||||||
|
|
||||||
this.androidUrl = "https://docs.qq.com/doc/DUWpYaXlvSklmVXlX"
|
this.androidUrl = "https://docs.qq.com/doc/DUWpYaXlvSklmVXlX"
|
||||||
Object.defineProperty(this, "button", { get() {
|
Object.defineProperty(this, "button", {
|
||||||
|
get() {
|
||||||
this.prefix = this.e?.isSr ? "*" : "#"
|
this.prefix = this.e?.isSr ? "*" : "#"
|
||||||
return segment.button([
|
return segment.button([
|
||||||
{ text: "角色记录", callback: `${this.prefix}角色记录` },
|
{ text: "角色记录", callback: `${this.prefix}角色记录` },
|
||||||
{ text: "角色统计", callback: `${this.prefix}角色统计` },
|
{ text: "角色统计", callback: `${this.prefix}角色统计` },
|
||||||
],[
|
], [
|
||||||
{ text: "武器记录", callback: `${this.prefix}武器记录` },
|
{ text: "武器记录", callback: `${this.prefix}武器记录` },
|
||||||
{ text: "武器统计", callback: `${this.prefix}武器统计` },
|
{ text: "武器统计", callback: `${this.prefix}武器统计` },
|
||||||
],[
|
], [
|
||||||
{ text: "常驻记录", callback: `${this.prefix}常驻记录` },
|
{ text: "常驻记录", callback: `${this.prefix}常驻记录` },
|
||||||
{ text: "常驻统计", callback: `${this.prefix}常驻统计` },
|
{ text: "常驻统计", callback: `${this.prefix}常驻统计` },
|
||||||
])
|
])
|
||||||
}})
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
@ -73,7 +75,7 @@ export class gcLog extends plugin {
|
||||||
accept() {
|
accept() {
|
||||||
if (this.e.file) {
|
if (this.e.file) {
|
||||||
let name = this.e.file?.name
|
let name = this.e.file?.name
|
||||||
if (/(.*)[1-9][0-9]{8}(.*).json/ig.test(name)) {
|
if (/(.*)([1-9]|18)[0-9]{8}(.*).json/ig.test(name)) {
|
||||||
this.e.msg = "#json文件导入记录"
|
this.e.msg = "#json文件导入记录"
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,13 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getServer(uid) {
|
async getServer(uid) {
|
||||||
switch (String(uid)[0]) {
|
let uidPrefix = uid.toString()
|
||||||
|
if (uidPrefix.length == 10) {
|
||||||
|
uidPrefix = uidPrefix.slice(0, 2)
|
||||||
|
} else {
|
||||||
|
uidPrefix = uidPrefix.slice(0, 1)
|
||||||
|
}
|
||||||
|
switch (uidPrefix) {
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
return 'cn_gf01'
|
return 'cn_gf01'
|
||||||
|
@ -107,6 +113,7 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
case '7':
|
case '7':
|
||||||
return 'os_euro'
|
return 'os_euro'
|
||||||
case '8':
|
case '8':
|
||||||
|
case '18':
|
||||||
return 'os_asia'
|
return 'os_asia'
|
||||||
case '9':
|
case '9':
|
||||||
return 'os_cht'
|
return 'os_cht'
|
||||||
|
|
|
@ -4,7 +4,7 @@ import gsCfg from '../model/gsCfg.js'
|
||||||
import User from '../model/user.js'
|
import User from '../model/user.js'
|
||||||
|
|
||||||
export class user extends plugin {
|
export class user extends plugin {
|
||||||
constructor (e) {
|
constructor(e) {
|
||||||
super({
|
super({
|
||||||
name: '用户绑定',
|
name: '用户绑定',
|
||||||
dsc: '米游社ck绑定,游戏uid绑定',
|
dsc: '米游社ck绑定,游戏uid绑定',
|
||||||
|
@ -42,7 +42,7 @@ export class user extends plugin {
|
||||||
fnc: 'delUid'
|
fnc: 'delUid'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: '^#(原神|星铁)?绑定(uid|UID)?\\s*[1-9][0-9]{8}$',
|
reg: '^#(原神|星铁)?绑定(uid|UID)?\\s*([1-9]|18)[0-9]{8}$',
|
||||||
fnc: 'bingUid'
|
fnc: 'bingUid'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -66,13 +66,13 @@ export class user extends plugin {
|
||||||
this.User = new User(e)
|
this.User = new User(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
async init () {
|
async init() {
|
||||||
/** 加载旧的绑定ck json */
|
/** 加载旧的绑定ck json */
|
||||||
await this.loadOldData()
|
await this.loadOldData()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 接受到消息都会执行一次 */
|
/** 接受到消息都会执行一次 */
|
||||||
accept () {
|
accept() {
|
||||||
if (!this.e.msg) return
|
if (!this.e.msg) return
|
||||||
// 由于手机端米游社网页可能获取不到ltuid 可以尝试在通行证页面获取login_uid
|
// 由于手机端米游社网页可能获取不到ltuid 可以尝试在通行证页面获取login_uid
|
||||||
if (/(ltoken|ltoken_v2)/.test(this.e.msg) && /(ltuid|login_uid|ltmid_v2)/.test(this.e.msg)) {
|
if (/(ltoken|ltoken_v2)/.test(this.e.msg) && /(ltuid|login_uid|ltmid_v2)/.test(this.e.msg)) {
|
||||||
|
@ -93,9 +93,9 @@ export class user extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 绑定uid */
|
/** 绑定uid */
|
||||||
saveUid () {
|
saveUid() {
|
||||||
if (!this.e.msg) return
|
if (!this.e.msg) return
|
||||||
let uid = this.e.msg.match(/[1|2|3|5-9][0-9]{8}/g)
|
let uid = this.e.msg.match(/([1-9]|18)[0-9]{8}/g)
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
this.reply('uid输入错误', false, { at: true })
|
this.reply('uid输入错误', false, { at: true })
|
||||||
return
|
return
|
||||||
|
@ -106,23 +106,23 @@ export class user extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 未登录ck */
|
/** 未登录ck */
|
||||||
async noLogin () {
|
async noLogin() {
|
||||||
this.reply('绑定Cookie失败\n请先【登录米游社】或【登录通行证】再获取Cookie')
|
this.reply('绑定Cookie失败\n请先【登录米游社】或【登录通行证】再获取Cookie')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** #ck代码 */
|
/** #ck代码 */
|
||||||
async ckCode () {
|
async ckCode() {
|
||||||
await this.reply('javascript:(()=>{prompt(\'\',document.cookie)})();')
|
await this.reply('javascript:(()=>{prompt(\'\',document.cookie)})();')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ck帮助 */
|
/** ck帮助 */
|
||||||
async ckHelp () {
|
async ckHelp() {
|
||||||
let set = gsCfg.getConfig('mys', 'set')
|
let set = gsCfg.getConfig('mys', 'set')
|
||||||
await this.reply(`Cookie绑定配置教程:${set.cookieDoc}\n获取Cookie后【私聊发送】进行绑定`)
|
await this.reply(`Cookie绑定配置教程:${set.cookieDoc}\n获取Cookie后【私聊发送】进行绑定`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 绑定ck */
|
/** 绑定ck */
|
||||||
async bingCk () {
|
async bingCk() {
|
||||||
let set = gsCfg.getConfig('mys', 'set')
|
let set = gsCfg.getConfig('mys', 'set')
|
||||||
|
|
||||||
if (!this.e.ck) {
|
if (!this.e.ck) {
|
||||||
|
@ -134,18 +134,18 @@ export class user extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除ck */
|
/** 删除ck */
|
||||||
async delCk () {
|
async delCk() {
|
||||||
let msg = await this.User.delCk()
|
let msg = await this.User.delCk()
|
||||||
await this.reply(msg)
|
await this.reply(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 绑定uid */
|
/** 绑定uid */
|
||||||
async bingUid () {
|
async bingUid() {
|
||||||
await this.User.bingUid()
|
await this.User.bingUid()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** #uid */
|
/** #uid */
|
||||||
async showUid () {
|
async showUid() {
|
||||||
let index = this.e.msg.match(/[0-9]{1,2}/g)
|
let index = this.e.msg.match(/[0-9]{1,2}/g)
|
||||||
if (index && index[0]) {
|
if (index && index[0]) {
|
||||||
await this.User.toggleUid(index[0])
|
await this.User.toggleUid(index[0])
|
||||||
|
@ -154,7 +154,7 @@ export class user extends plugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async delUid () {
|
async delUid() {
|
||||||
let index = this.e.msg.match(/[0-9]{1,2}$/g)
|
let index = this.e.msg.match(/[0-9]{1,2}$/g)
|
||||||
let uidIdx = index && index[0]
|
let uidIdx = index && index[0]
|
||||||
let game = this.e
|
let game = this.e
|
||||||
|
@ -164,7 +164,7 @@ export class user extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 我的ck */
|
/** 我的ck */
|
||||||
async myCk () {
|
async myCk() {
|
||||||
if (this.e.isGroup) {
|
if (this.e.isGroup) {
|
||||||
await this.reply('请私聊查看')
|
await this.reply('请私聊查看')
|
||||||
return
|
return
|
||||||
|
@ -173,18 +173,18 @@ export class user extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载旧的绑定ck json */
|
/** 加载旧的绑定ck json */
|
||||||
async loadOldData () {
|
async loadOldData() {
|
||||||
await this.User.loadOldDataV2()
|
await this.User.loadOldDataV2()
|
||||||
await this.User.loadOldDataV3()
|
await this.User.loadOldDataV3()
|
||||||
await this.User.loadOldUid()
|
await this.User.loadOldUid()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 检查用户CK状态 **/
|
/** 检查用户CK状态 **/
|
||||||
async checkCkStatus () {
|
async checkCkStatus() {
|
||||||
await this.User.checkCkStatus()
|
await this.User.checkCkStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
async bindNoteUser () {
|
async bindNoteUser() {
|
||||||
await this.User.bindNoteUser()
|
await this.User.bindNoteUser()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -182,7 +182,7 @@ export default class ExportLog extends base {
|
||||||
|
|
||||||
/** json导入抽卡记录 */
|
/** json导入抽卡记录 */
|
||||||
async logJson() {
|
async logJson() {
|
||||||
let uid = /[1-9][0-9]{8}/g.exec(this.e.file.name)[0]
|
let uid = /([1-9]|18)[0-9]{8}/g.exec(this.e.file.name)[0]
|
||||||
let textPath = `${this.path}${this.e.file.name}`
|
let textPath = `${this.path}${this.e.file.name}`
|
||||||
/** 获取文件下载链接 */
|
/** 获取文件下载链接 */
|
||||||
let fileUrl = await this.e.friend.getFileUrl(this.e.file.fid)
|
let fileUrl = await this.e.friend.getFileUrl(this.e.file.fid)
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { Character, Weapon } from '#miao.models'
|
||||||
|
|
||||||
/** 配置文件 */
|
/** 配置文件 */
|
||||||
class GsCfg {
|
class GsCfg {
|
||||||
constructor () {
|
constructor() {
|
||||||
this.isSr = false
|
this.isSr = false
|
||||||
/** 默认设置 */
|
/** 默认设置 */
|
||||||
this.defSetPath = './plugins/genshin/defSet/'
|
this.defSetPath = './plugins/genshin/defSet/'
|
||||||
|
@ -24,7 +24,7 @@ class GsCfg {
|
||||||
this.ignore = ['mys.pubCk', 'gacha.set', 'bot.help', 'role.name']
|
this.ignore = ['mys.pubCk', 'gacha.set', 'bot.help', 'role.name']
|
||||||
}
|
}
|
||||||
|
|
||||||
get element () {
|
get element() {
|
||||||
return { ...this.getdefSet('element', 'role'), ...this.getdefSet('element', 'weapon') }
|
return { ...this.getdefSet('element', 'role'), ...this.getdefSet('element', 'weapon') }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,12 +32,12 @@ class GsCfg {
|
||||||
* @param app 功能
|
* @param app 功能
|
||||||
* @param name 配置文件名称
|
* @param name 配置文件名称
|
||||||
*/
|
*/
|
||||||
getdefSet (app, name) {
|
getdefSet(app, name) {
|
||||||
return this.getYaml(app, name, 'defSet')
|
return this.getYaml(app, name, 'defSet')
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 用户配置 */
|
/** 用户配置 */
|
||||||
getConfig (app, name) {
|
getConfig(app, name) {
|
||||||
if (this.ignore.includes(`${app}.${name}`)) {
|
if (this.ignore.includes(`${app}.${name}`)) {
|
||||||
return this.getYaml(app, name, 'config')
|
return this.getYaml(app, name, 'config')
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class GsCfg {
|
||||||
* @param name 名称
|
* @param name 名称
|
||||||
* @param type 默认跑配置-defSet,用户配置-config
|
* @param type 默认跑配置-defSet,用户配置-config
|
||||||
*/
|
*/
|
||||||
getYaml (app, name, type) {
|
getYaml(app, name, type) {
|
||||||
let file = this.getFilePath(app, name, type)
|
let file = this.getFilePath(app, name, type)
|
||||||
let key = `${app}.${name}`
|
let key = `${app}.${name}`
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class GsCfg {
|
||||||
return this[type][key]
|
return this[type][key]
|
||||||
}
|
}
|
||||||
|
|
||||||
getFilePath (app, name, type) {
|
getFilePath(app, name, type) {
|
||||||
if (type == 'defSet') {
|
if (type == 'defSet') {
|
||||||
return `${this.defSetPath}${app}/${name}.yaml`
|
return `${this.defSetPath}${app}/${name}.yaml`
|
||||||
} else {
|
} else {
|
||||||
|
@ -80,7 +80,7 @@ class GsCfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 监听配置文件 */
|
/** 监听配置文件 */
|
||||||
watch (file, app, name, type = 'defSet') {
|
watch(file, app, name, type = 'defSet') {
|
||||||
let key = `${app}.${name}`
|
let key = `${app}.${name}`
|
||||||
|
|
||||||
if (this.watcher[type][key]) return
|
if (this.watcher[type][key]) return
|
||||||
|
@ -98,7 +98,7 @@ class GsCfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 读取所有用户绑定的ck */
|
/** 读取所有用户绑定的ck */
|
||||||
async getBingCk (game = 'gs') {
|
async getBingCk(game = 'gs') {
|
||||||
let ck = {}
|
let ck = {}
|
||||||
let ckQQ = {}
|
let ckQQ = {}
|
||||||
let noteCk = {}
|
let noteCk = {}
|
||||||
|
@ -126,13 +126,13 @@ class GsCfg {
|
||||||
/**
|
/**
|
||||||
* 原神角色id转换角色名字
|
* 原神角色id转换角色名字
|
||||||
*/
|
*/
|
||||||
roleIdToName (id) {
|
roleIdToName(id) {
|
||||||
let char = Character.get(id)
|
let char = Character.get(id)
|
||||||
return char?.name || ''
|
return char?.name || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 原神角色别名转id */
|
/** 原神角色别名转id */
|
||||||
roleNameToID (keyword, isSr) {
|
roleNameToID(keyword, isSr) {
|
||||||
let char = Character.get(keyword, isSr ? 'sr' : 'gs')
|
let char = Character.get(keyword, isSr ? 'sr' : 'gs')
|
||||||
return char?.id || false
|
return char?.id || false
|
||||||
}
|
}
|
||||||
|
@ -143,18 +143,18 @@ class GsCfg {
|
||||||
* @param name 名称
|
* @param name 名称
|
||||||
* @param isWeapon 是否武器
|
* @param isWeapon 是否武器
|
||||||
*/
|
*/
|
||||||
shortName (name, isWeapon = false) {
|
shortName(name, isWeapon = false) {
|
||||||
let obj = (isWeapon ? Weapon : Character).get(name)
|
let obj = (isWeapon ? Weapon : Character).get(name)
|
||||||
return obj.abbr || obj.name || ''
|
return obj.abbr || obj.name || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 公共配置ck文件修改hook */
|
/** 公共配置ck文件修改hook */
|
||||||
async change_myspubCk () {
|
async change_myspubCk() {
|
||||||
await MysInfo.initCache()
|
await MysInfo.initCache()
|
||||||
await MysInfo.initPubCk()
|
await MysInfo.initPubCk()
|
||||||
}
|
}
|
||||||
|
|
||||||
getGachaSet (groupId = '') {
|
getGachaSet(groupId = '') {
|
||||||
let config = this.getYaml('gacha', 'set', 'config')
|
let config = this.getYaml('gacha', 'set', 'config')
|
||||||
let def = config.default
|
let def = config.default
|
||||||
if (config[groupId]) {
|
if (config[groupId]) {
|
||||||
|
@ -163,8 +163,8 @@ class GsCfg {
|
||||||
return def
|
return def
|
||||||
}
|
}
|
||||||
|
|
||||||
getMsgUid (msg) {
|
getMsgUid(msg) {
|
||||||
let ret = /[1|2|5-9][0-9]{8}/g.exec(msg)
|
let ret = /([1-9]|18)[0-9]{8}/g.exec(msg)
|
||||||
if (!ret) return false
|
if (!ret) return false
|
||||||
return ret[0]
|
return ret[0]
|
||||||
}
|
}
|
||||||
|
@ -178,8 +178,8 @@ class GsCfg {
|
||||||
* @return alias 当前别名
|
* @return alias 当前别名
|
||||||
* @return uid 游戏uid
|
* @return uid 游戏uid
|
||||||
*/
|
*/
|
||||||
getRole (msg, filterMsg = '', isSr = false) {
|
getRole(msg, filterMsg = '', isSr = false) {
|
||||||
let alias = msg.replace(/#|老婆|老公|[1|2|3|5-9][0-9]{8}/g, '').trim()
|
let alias = msg.replace(/#|老婆|老公|([1-9]|18)[0-9]{8}/g, '').trim()
|
||||||
if (filterMsg) {
|
if (filterMsg) {
|
||||||
alias = alias.replace(new RegExp(filterMsg, 'g'), '').trim()
|
alias = alias.replace(new RegExp(filterMsg, 'g'), '').trim()
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,7 @@ class GsCfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
cpCfg (app, name) {
|
cpCfg(app, name) {
|
||||||
if (!fs.existsSync('./plugins/genshin/config')) {
|
if (!fs.existsSync('./plugins/genshin/config')) {
|
||||||
fs.mkdirSync('./plugins/genshin/config')
|
fs.mkdirSync('./plugins/genshin/config')
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ class GsCfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 仅供内部调用
|
// 仅供内部调用
|
||||||
_getAbbr () {
|
_getAbbr() {
|
||||||
if (this[this.isSr ? 'sr_nameID' : 'nameID']) return
|
if (this[this.isSr ? 'sr_nameID' : 'nameID']) return
|
||||||
|
|
||||||
this.nameID = new Map()
|
this.nameID = new Map()
|
||||||
|
@ -250,7 +250,7 @@ class GsCfg {
|
||||||
|
|
||||||
|
|
||||||
// 仅供内部调用
|
// 仅供内部调用
|
||||||
_roleNameToID (keyword, isSr) {
|
_roleNameToID(keyword, isSr) {
|
||||||
if (isSr) this.isSr = isSr
|
if (isSr) this.isSr = isSr
|
||||||
if (!isNaN(keyword)) keyword = Number(keyword)
|
if (!isNaN(keyword)) keyword = Number(keyword)
|
||||||
this._getAbbr()
|
this._getAbbr()
|
||||||
|
@ -259,8 +259,8 @@ class GsCfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 仅供内部调用
|
// 仅供内部调用
|
||||||
_getRole (msg, filterMsg = '', isSr = false) {
|
_getRole(msg, filterMsg = '', isSr = false) {
|
||||||
let alias = msg.replace(/#|老婆|老公|[1|2|3|5-9][0-9]{8}/g, '').trim()
|
let alias = msg.replace(/#|老婆|老公|([1-9]|18)[0-9]{8}/g, '').trim()
|
||||||
if (filterMsg) {
|
if (filterMsg) {
|
||||||
alias = alias.replace(new RegExp(filterMsg, 'g'), '').trim()
|
alias = alias.replace(new RegExp(filterMsg, 'g'), '').trim()
|
||||||
}
|
}
|
||||||
|
@ -279,46 +279,46 @@ class GsCfg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getWeaponDataByWeaponHash (hash) {
|
getWeaponDataByWeaponHash(hash) {
|
||||||
console.log('gsCfg.getWeaponDataByWeaponHash() 已废弃')
|
console.log('gsCfg.getWeaponDataByWeaponHash() 已废弃')
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllAbbr () {
|
getAllAbbr() {
|
||||||
console.log('gsCfg.getAllAbbr() 已废弃')
|
console.log('gsCfg.getAllAbbr() 已废弃')
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
getBingCkSingle (userId) {
|
getBingCkSingle(userId) {
|
||||||
console.log('gsCfg.getBingCkSingle() 已废弃')
|
console.log('gsCfg.getBingCkSingle() 已废弃')
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
saveBingCk (userId, data) {
|
saveBingCk(userId, data) {
|
||||||
console.log('gsCfg.saveBingCk() 已废弃')
|
console.log('gsCfg.saveBingCk() 已废弃')
|
||||||
}
|
}
|
||||||
|
|
||||||
getElementByRoleName (roleName) {
|
getElementByRoleName(roleName) {
|
||||||
console.log('gsCfg.getElementByRoleName() 已废弃')
|
console.log('gsCfg.getElementByRoleName() 已废弃')
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
getSkillDataByskillId (skillId, roleName) {
|
getSkillDataByskillId(skillId, roleName) {
|
||||||
console.log('gsCfg.getSkillDataByskillId() 已废弃')
|
console.log('gsCfg.getSkillDataByskillId() 已废弃')
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fightPropIdToName (propId) {
|
fightPropIdToName(propId) {
|
||||||
console.log('gsCfg.fightPropIdToName() 已废弃')
|
console.log('gsCfg.fightPropIdToName() 已废弃')
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoleTalentByTalentId (talentId) {
|
getRoleTalentByTalentId(talentId) {
|
||||||
console.log('gsCfg.getRoleTalentByTalentId 已废弃')
|
console.log('gsCfg.getRoleTalentByTalentId 已废弃')
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
getAbbr () {
|
getAbbr() {
|
||||||
console.log('gsCfg.getAbbr() 已经废弃')
|
console.log('gsCfg.getAbbr() 已经废弃')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ const tables = {
|
||||||
|
|
||||||
export default class MysUser extends BaseModel {
|
export default class MysUser extends BaseModel {
|
||||||
|
|
||||||
constructor (ltuid) {
|
constructor(ltuid) {
|
||||||
super()
|
super()
|
||||||
if (!ltuid) {
|
if (!ltuid) {
|
||||||
return false
|
return false
|
||||||
|
@ -56,12 +56,12 @@ export default class MysUser extends BaseModel {
|
||||||
|
|
||||||
// 可传入ltuid、cookie、ck对象来创建MysUser实例
|
// 可传入ltuid、cookie、ck对象来创建MysUser实例
|
||||||
|
|
||||||
get uid () {
|
get uid() {
|
||||||
return this.uids?.gs?.[0] || ''
|
return this.uids?.gs?.[0] || ''
|
||||||
}
|
}
|
||||||
|
|
||||||
// 在仅传入ltuid时,必须是之前传入过的才能被识别
|
// 在仅传入ltuid时,必须是之前传入过的才能被识别
|
||||||
static async create (ltuid, db = false) {
|
static async create(ltuid, db = false) {
|
||||||
ltuid = MysUtil.getLtuid(ltuid)
|
ltuid = MysUtil.getLtuid(ltuid)
|
||||||
if (!ltuid) {
|
if (!ltuid) {
|
||||||
return false
|
return false
|
||||||
|
@ -71,7 +71,7 @@ export default class MysUser extends BaseModel {
|
||||||
return mys
|
return mys
|
||||||
}
|
}
|
||||||
|
|
||||||
static async forEach (fn) {
|
static async forEach(fn) {
|
||||||
let dbs = await MysUserDB.findAll()
|
let dbs = await MysUserDB.findAll()
|
||||||
await Data.forEach(dbs, async (db) => {
|
await Data.forEach(dbs, async (db) => {
|
||||||
let mys = await MysUser.create(db.ltuid, db)
|
let mys = await MysUser.create(db.ltuid, db)
|
||||||
|
@ -80,7 +80,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据uid获取查询MysUser
|
// 根据uid获取查询MysUser
|
||||||
static async getByQueryUid (uid, game = 'gs', onlySelfCk = false) {
|
static async getByQueryUid(uid, game = 'gs', onlySelfCk = false) {
|
||||||
let servCache = DailyCache.create(uid, game)
|
let servCache = DailyCache.create(uid, game)
|
||||||
// 查找已经查询过的ltuid || 分配最少查询的ltuid
|
// 查找已经查询过的ltuid || 分配最少查询的ltuid
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ export default class MysUser extends BaseModel {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
static async eachServ (fn) {
|
static async eachServ(fn) {
|
||||||
await MysUtil.eachServ(async (serv) => {
|
await MysUtil.eachServ(async (serv) => {
|
||||||
await MysUtil.eachGame(async (game) => {
|
await MysUtil.eachGame(async (game) => {
|
||||||
let servCache = DailyCache.create(serv, game)
|
let servCache = DailyCache.create(serv, game)
|
||||||
|
@ -132,7 +132,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清除当日缓存
|
// 清除当日缓存
|
||||||
static async clearCache () {
|
static async clearCache() {
|
||||||
await MysUser.eachServ(async function (servCache) {
|
await MysUser.eachServ(async function (servCache) {
|
||||||
await servCache.empty(tables.detail)
|
await servCache.empty(tables.detail)
|
||||||
})
|
})
|
||||||
|
@ -143,7 +143,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取用户统计数据
|
// 获取用户统计数据
|
||||||
static async getStatData () {
|
static async getStatData() {
|
||||||
let totalCount = {}
|
let totalCount = {}
|
||||||
let ret = { servs: {} }
|
let ret = { servs: {} }
|
||||||
await MysUser.eachServ(async function (servCache, serv) {
|
await MysUser.eachServ(async function (servCache, serv) {
|
||||||
|
@ -182,7 +182,7 @@ export default class MysUser extends BaseModel {
|
||||||
* 删除失效用户
|
* 删除失效用户
|
||||||
* @returns {Promise<number>} 删除用户的个数
|
* @returns {Promise<number>} 删除用户的个数
|
||||||
*/
|
*/
|
||||||
static async delDisable () {
|
static async delDisable() {
|
||||||
let count = 0
|
let count = 0
|
||||||
await MysUser.eachServ(async function (servCache) {
|
await MysUser.eachServ(async function (servCache) {
|
||||||
let cks = await servCache.zGetDisableKey(tables.detail)
|
let cks = await servCache.zGetDisableKey(tables.detail)
|
||||||
|
@ -204,7 +204,7 @@ export default class MysUser extends BaseModel {
|
||||||
* @param ck 需要检查的CK
|
* @param ck 需要检查的CK
|
||||||
* @returns {Promise<boolean|{msg: string, uids: *[], status: number}>}
|
* @returns {Promise<boolean|{msg: string, uids: *[], status: number}>}
|
||||||
*/
|
*/
|
||||||
static async checkCkStatus (ck) {
|
static async checkCkStatus(ck) {
|
||||||
let uids = []
|
let uids = []
|
||||||
let err = (msg, status = 2) => {
|
let err = (msg, status = 2) => {
|
||||||
msg = msg + '\n请退出米游社并重新登录后,再次获取CK'
|
msg = msg + '\n请退出米游社并重新登录后,再次获取CK'
|
||||||
|
@ -253,7 +253,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不建议使用,为了兼容老数据格式,后续废弃
|
// 不建议使用,为了兼容老数据格式,后续废弃
|
||||||
getCkInfo (game = 'gs') {
|
getCkInfo(game = 'gs') {
|
||||||
return {
|
return {
|
||||||
ck: this.ck,
|
ck: this.ck,
|
||||||
uid: this.getUid(game),
|
uid: this.getUid(game),
|
||||||
|
@ -262,7 +262,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getUidData (uid, game = 'gs') {
|
getUidData(uid, game = 'gs') {
|
||||||
game = this.gameKey(game)
|
game = this.gameKey(game)
|
||||||
if (!this.hasUid(uid, game)) {
|
if (!this.hasUid(uid, game)) {
|
||||||
return false
|
return false
|
||||||
|
@ -275,21 +275,21 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hasUid (uid, game = 'gs') {
|
hasUid(uid, game = 'gs') {
|
||||||
game = this.gameKey(game)
|
game = this.gameKey(game)
|
||||||
return this.uids[game].includes(uid + '')
|
return this.uids[game].includes(uid + '')
|
||||||
}
|
}
|
||||||
|
|
||||||
getUid (game = 'gs') {
|
getUid(game = 'gs') {
|
||||||
return this.getUids(game)[0]
|
return this.getUids(game)[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
getUids (game = 'gs') {
|
getUids(game = 'gs') {
|
||||||
let gameKey = this.gameKey(game)
|
let gameKey = this.gameKey(game)
|
||||||
return this.uids[gameKey] || []
|
return this.uids[gameKey] || []
|
||||||
}
|
}
|
||||||
|
|
||||||
getUidInfo () {
|
getUidInfo() {
|
||||||
let ret = []
|
let ret = []
|
||||||
MysUtil.eachGame((game, gameDs) => {
|
MysUtil.eachGame((game, gameDs) => {
|
||||||
let uids = this.getUids(game)
|
let uids = this.getUids(game)
|
||||||
|
@ -304,7 +304,7 @@ export default class MysUser extends BaseModel {
|
||||||
* 刷新mysUser的UID列表
|
* 刷新mysUser的UID列表
|
||||||
* @returns {Promise<{msg: string, status: number}>}
|
* @returns {Promise<{msg: string, status: number}>}
|
||||||
*/
|
*/
|
||||||
async reqMysUid () {
|
async reqMysUid() {
|
||||||
let err = (msg = 'error', status = 1) => {
|
let err = (msg = 'error', status = 1) => {
|
||||||
return { status, msg }
|
return { status, msg }
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ export default class MysUser extends BaseModel {
|
||||||
return { status: 0, msg: '' }
|
return { status: 0, msg: '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
async getGameRole (serv = 'mys') {
|
async getGameRole(serv = 'mys') {
|
||||||
let ck = this.ck
|
let ck = this.ck
|
||||||
let url = {
|
let url = {
|
||||||
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie',
|
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie',
|
||||||
|
@ -359,7 +359,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取米游社通行证id
|
// 获取米游社通行证id
|
||||||
async getUserFullInfo (serv = 'mys') {
|
async getUserFullInfo(serv = 'mys') {
|
||||||
let ck = this.ck
|
let ck = this.ck
|
||||||
let url = {
|
let url = {
|
||||||
mys: 'https://bbs-api.mihoyo.com/user/wapi/getUserFullInfo?gids=2',
|
mys: 'https://bbs-api.mihoyo.com/user/wapi/getUserFullInfo?gids=2',
|
||||||
|
@ -381,7 +381,7 @@ export default class MysUser extends BaseModel {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
getCache (game = 'gs') {
|
getCache(game = 'gs') {
|
||||||
if (!this.cache) {
|
if (!this.cache) {
|
||||||
this.cache = {}
|
this.cache = {}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@ export default class MysUser extends BaseModel {
|
||||||
|
|
||||||
|
|
||||||
// 初始化数据
|
// 初始化数据
|
||||||
async initDB (db = false) {
|
async initDB(db = false) {
|
||||||
if (this.db && !db) {
|
if (this.db && !db) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -407,7 +407,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置ck数据
|
// 设置ck数据
|
||||||
setCkData (data = {}) {
|
setCkData(data = {}) {
|
||||||
this.ck = data.ck || this.ck || ''
|
this.ck = data.ck || this.ck || ''
|
||||||
this.type = data.type || this.type || 'mys'
|
this.type = data.type || this.type || 'mys'
|
||||||
this.device = data.device || this.device || MysUtil.getDeviceGuid()
|
this.device = data.device || this.device || MysUtil.getDeviceGuid()
|
||||||
|
@ -418,12 +418,12 @@ export default class MysUser extends BaseModel {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async save () {
|
async save() {
|
||||||
await this.db.saveDB(this)
|
await this.db.saveDB(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为当前MysUser绑定uid
|
// 为当前MysUser绑定uid
|
||||||
addUid (uid, game = 'gs') {
|
addUid(uid, game = 'gs') {
|
||||||
if (lodash.isArray(uid)) {
|
if (lodash.isArray(uid)) {
|
||||||
for (let u of uid) {
|
for (let u of uid) {
|
||||||
this.addUid(u, game)
|
this.addUid(u, game)
|
||||||
|
@ -431,7 +431,7 @@ export default class MysUser extends BaseModel {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
uid = '' + uid
|
uid = '' + uid
|
||||||
if (/\d{9}/.test(uid)) {
|
if (/\d{9,10}/.test(uid)) {
|
||||||
let gameKey = this.gameKey(game)
|
let gameKey = this.gameKey(game)
|
||||||
let uids = this.uids[gameKey]
|
let uids = this.uids[gameKey]
|
||||||
if (!uids.includes(uid)) {
|
if (!uids.includes(uid)) {
|
||||||
|
@ -441,13 +441,13 @@ export default class MysUser extends BaseModel {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
hasGame (game = 'gs') {
|
hasGame(game = 'gs') {
|
||||||
game = this.gameKey(game)
|
game = this.gameKey(game)
|
||||||
return this.uids[game]?.length > 0
|
return this.uids[game]?.length > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化当前MysUser缓存记录
|
// 初始化当前MysUser缓存记录
|
||||||
async initCache () {
|
async initCache() {
|
||||||
if (!this.ltuid || !this.ck) {
|
if (!this.ltuid || !this.ck) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ export default class MysUser extends BaseModel {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async disable (game = 'gs') {
|
async disable(game = 'gs') {
|
||||||
let cache = this.getCache(game)
|
let cache = this.getCache(game)
|
||||||
await cache.zDel(tables.detail, this.ltuid)
|
await cache.zDel(tables.detail, this.ltuid)
|
||||||
logger.mark(`[标记无效ck][game:${game}, ltuid:${this.ltuid}`)
|
logger.mark(`[标记无效ck][game:${game}, ltuid:${this.ltuid}`)
|
||||||
|
@ -481,7 +481,7 @@ export default class MysUser extends BaseModel {
|
||||||
* 删除缓存, 供User解绑CK时调用
|
* 删除缓存, 供User解绑CK时调用
|
||||||
* @returns {Promise<boolean>}
|
* @returns {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
async del () {
|
async del() {
|
||||||
// TODO 检查一ltuid多绑定的情况
|
// TODO 检查一ltuid多绑定的情况
|
||||||
// 将查询过的uid缓存起来,以备后续重新绑定时恢复
|
// 将查询过的uid缓存起来,以备后续重新绑定时恢复
|
||||||
let self = this
|
let self = this
|
||||||
|
@ -498,7 +498,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除MysUser用户记录,会反向删除User中的记录及绑定关系
|
// 删除MysUser用户记录,会反向删除User中的记录及绑定关系
|
||||||
async delWithUser (game = 'gs') {
|
async delWithUser(game = 'gs') {
|
||||||
// 查找用户
|
// 查找用户
|
||||||
let cache = this.getCache(game)
|
let cache = this.getCache(game)
|
||||||
let qqArr = await cache.kGet(tables.qq, this.ltuid, true)
|
let qqArr = await cache.kGet(tables.qq, this.ltuid, true)
|
||||||
|
@ -515,7 +515,7 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 为当前用户添加uid查询记录
|
// 为当前用户添加uid查询记录
|
||||||
async addQueryUid (uid, game = 'gs') {
|
async addQueryUid(uid, game = 'gs') {
|
||||||
if (lodash.isArray(uid)) {
|
if (lodash.isArray(uid)) {
|
||||||
for (let u of uid) {
|
for (let u of uid) {
|
||||||
await this.addQueryUid(u, game)
|
await this.addQueryUid(u, game)
|
||||||
|
@ -529,19 +529,19 @@ export default class MysUser extends BaseModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前用户已查询uid列表
|
// 获取当前用户已查询uid列表
|
||||||
async getQueryUids (game = 'gs') {
|
async getQueryUids(game = 'gs') {
|
||||||
let cache = this.getCache(game)
|
let cache = this.getCache(game)
|
||||||
return await cache.zList(tables.detail, this.ltuid)
|
return await cache.zList(tables.detail, this.ltuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据uid获取查询ltuid
|
// 根据uid获取查询ltuid
|
||||||
async getQueryLtuid (uid, game = 'gs') {
|
async getQueryLtuid(uid, game = 'gs') {
|
||||||
let cache = this.getCache(game)
|
let cache = this.getCache(game)
|
||||||
return await cache.zKey(tables.detail, uid)
|
return await cache.zKey(tables.detail, uid)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查指定uid是否为当前MysUser所有
|
// 检查指定uid是否为当前MysUser所有
|
||||||
ownUid (uid, game = 'gs') {
|
ownUid(uid, game = 'gs') {
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default class MysApi {
|
||||||
* @param isSr 是否星铁
|
* @param isSr 是否星铁
|
||||||
* @param device 设备device_id
|
* @param device 设备device_id
|
||||||
*/
|
*/
|
||||||
constructor (uid, cookie, option = {}, isSr = false, device = '') {
|
constructor(uid, cookie, option = {}, isSr = false, device = '') {
|
||||||
this.uid = uid
|
this.uid = uid
|
||||||
this.cookie = cookie
|
this.cookie = cookie
|
||||||
this.isSr = isSr
|
this.isSr = isSr
|
||||||
|
@ -30,12 +30,12 @@ export default class MysApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable quotes */
|
/* eslint-disable quotes */
|
||||||
get device () {
|
get device() {
|
||||||
if (!this._device) this._device = `Yz-${md5(this.uid).substring(0, 5)}`
|
if (!this._device) this._device = `Yz-${md5(this.uid).substring(0, 5)}`
|
||||||
return this._device
|
return this._device
|
||||||
}
|
}
|
||||||
|
|
||||||
getUrl (type, data = {}) {
|
getUrl(type, data = {}) {
|
||||||
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
|
||||||
|
|
||||||
|
@ -49,9 +49,14 @@ export default class MysApi {
|
||||||
return { url, headers, body }
|
return { url, headers, body }
|
||||||
}
|
}
|
||||||
|
|
||||||
getServer () {
|
getServer() {
|
||||||
let uid = this.uid
|
let uidPrefix = this.uid.toString()
|
||||||
switch (String(uid)[0]) {
|
if (uidPrefix.length == 10) {
|
||||||
|
uidPrefix = uidPrefix.slice(0, 2)
|
||||||
|
} else {
|
||||||
|
uidPrefix = uidPrefix.slice(0, 1)
|
||||||
|
}
|
||||||
|
switch (uidPrefix) {
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
return this.isSr ? 'prod_gf_cn' : 'cn_gf01' // 官服
|
return this.isSr ? 'prod_gf_cn' : 'cn_gf01' // 官服
|
||||||
|
@ -62,6 +67,7 @@ export default class MysApi {
|
||||||
case '7':
|
case '7':
|
||||||
return this.isSr ? 'prod_official_euro' : 'os_euro' // 欧服
|
return this.isSr ? 'prod_official_euro' : 'os_euro' // 欧服
|
||||||
case '8':
|
case '8':
|
||||||
|
case '18':
|
||||||
return this.isSr ? 'prod_official_asia' : 'os_asia' // 亚服
|
return this.isSr ? 'prod_official_asia' : 'os_asia' // 亚服
|
||||||
case '9':
|
case '9':
|
||||||
return this.isSr ? 'prod_official_cht' : 'os_cht' // 港澳台服
|
return this.isSr ? 'prod_official_cht' : 'os_cht' // 港澳台服
|
||||||
|
@ -69,7 +75,7 @@ export default class MysApi {
|
||||||
return this.isSr ? 'prod_gf_cn' : 'cn_gf01'
|
return this.isSr ? 'prod_gf_cn' : 'cn_gf01'
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData (type, data = {}, cached = false) {
|
async getData(type, data = {}, cached = false) {
|
||||||
if (!this._device_fp && !data?.Getfp) {
|
if (!this._device_fp && !data?.Getfp) {
|
||||||
this._device_fp = await this.getData('getFp', {
|
this._device_fp = await this.getData('getFp', {
|
||||||
seed_id: this.generateSeed(16),
|
seed_id: this.generateSeed(16),
|
||||||
|
@ -137,7 +143,7 @@ export default class MysApi {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
getHeaders (query = '', body = '') {
|
getHeaders(query = '', body = '') {
|
||||||
const cn = {
|
const cn = {
|
||||||
app_version: '2.40.1',
|
app_version: '2.40.1',
|
||||||
User_Agent: `Mozilla/5.0 (Linux; Android 12; ${this.device}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/2.40.1`,
|
User_Agent: `Mozilla/5.0 (Linux; Android 12; ${this.device}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.73 Mobile Safari/537.36 miHoYoBBS/2.40.1`,
|
||||||
|
@ -169,7 +175,7 @@ export default class MysApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getDs (q = '', b = '') {
|
getDs(q = '', b = '') {
|
||||||
let n = ''
|
let n = ''
|
||||||
if (['cn_gf01', 'cn_qd01', 'prod_gf_cn', 'prod_qd_cn'].includes(this.server)) {
|
if (['cn_gf01', 'cn_qd01', 'prod_gf_cn', 'prod_qd_cn'].includes(this.server)) {
|
||||||
n = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
|
n = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs'
|
||||||
|
@ -182,24 +188,24 @@ export default class MysApi {
|
||||||
return `${t},${r},${DS}`
|
return `${t},${r},${DS}`
|
||||||
}
|
}
|
||||||
|
|
||||||
getGuid () {
|
getGuid() {
|
||||||
function S4 () {
|
function S4() {
|
||||||
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
|
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
|
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheKey (type, data) {
|
cacheKey(type, data) {
|
||||||
return 'Yz:genshin:mys:cache:' + md5(this.uid + type + JSON.stringify(data))
|
return 'Yz:genshin:mys:cache:' + md5(this.uid + type + JSON.stringify(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
async cache (res, cacheKey) {
|
async cache(res, cacheKey) {
|
||||||
if (!res || res.retcode !== 0) return
|
if (!res || res.retcode !== 0) return
|
||||||
redis.setEx(cacheKey, this.cacheCd, JSON.stringify(res))
|
redis.setEx(cacheKey, this.cacheCd, JSON.stringify(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAgent () {
|
async getAgent() {
|
||||||
let proxyAddress = cfg.bot.proxyAddress
|
let proxyAddress = cfg.bot.proxyAddress
|
||||||
if (!proxyAddress) return null
|
if (!proxyAddress) return null
|
||||||
if (proxyAddress === 'http://0.0.0.0:0') return null
|
if (proxyAddress === 'http://0.0.0.0:0') return null
|
||||||
|
@ -221,7 +227,7 @@ export default class MysApi {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
generateSeed (length = 16) {
|
generateSeed(length = 16) {
|
||||||
const characters = '0123456789abcdef'
|
const characters = '0123456789abcdef'
|
||||||
let result = ''
|
let result = ''
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import DailyCache from './DailyCache.js'
|
||||||
export default class MysInfo {
|
export default class MysInfo {
|
||||||
static tips = '请先#绑定Cookie\n发送【Cookie帮助】查看配置教程'
|
static tips = '请先#绑定Cookie\n发送【Cookie帮助】查看配置教程'
|
||||||
|
|
||||||
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)
|
||||||
|
@ -33,7 +33,7 @@ export default class MysInfo {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -55,11 +55,18 @@ export default class MysInfo {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!['1', '2', '3', '5', '6', '7', '8', '9'].includes(String(mysInfo.uid)[0])) {
|
let uidPrefix = mysInfo.uid.toString()
|
||||||
|
if (uidPrefix.length == 10) {
|
||||||
|
uidPrefix = uidPrefix.slice(0, 2)
|
||||||
|
} else {
|
||||||
|
uidPrefix = uidPrefix.slice(0, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!['1', '2', '3', '5', '6', '7', '8', '18', '9'].includes(uidPrefix)) {
|
||||||
// e.reply('只支持查询国服uid')
|
// e.reply('只支持查询国服uid')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (!['6', '7', '8', '9'].includes(String(mysInfo.uid)[0]) && api === 'useCdk') {
|
if (!['6', '7', '8', '18', '9'].includes(uidPrefix) && api === 'useCdk') {
|
||||||
e.reply('兑换码使用只支持国际服uid')
|
e.reply('兑换码使用只支持国际服uid')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -80,7 +87,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) {
|
||||||
/** 没有绑定的自动绑定 */
|
/** 没有绑定的自动绑定 */
|
||||||
|
@ -103,7 +110,7 @@ export default class MysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
let matchUid = (msg = '') => {
|
let matchUid = (msg = '') => {
|
||||||
let ret = /[1235-9][0-9]{8}/g.exec(msg)
|
let ret = /([1-9]|18)[0-9]{8}/g.exec(msg)
|
||||||
if (!ret) return false
|
if (!ret) return false
|
||||||
return ret[0]
|
return ret[0]
|
||||||
}
|
}
|
||||||
|
@ -128,7 +135,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
|
||||||
|
|
||||||
|
@ -163,7 +170,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
|
||||||
|
@ -209,7 +216,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') || []
|
||||||
|
@ -233,7 +240,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) => {
|
||||||
|
@ -251,7 +258,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')) {
|
||||||
|
@ -274,13 +281,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
|
||||||
|
@ -288,12 +295,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
|
||||||
}
|
}
|
||||||
|
@ -309,7 +316,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) {
|
||||||
|
@ -334,7 +341,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)
|
||||||
|
@ -353,7 +360,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(['米游社接口请求失败,暂时无法查询', this.mysButton])
|
if (!isTask) this.e.reply(['米游社接口请求失败,暂时无法查询', this.mysButton])
|
||||||
return false
|
return false
|
||||||
|
@ -440,7 +447,7 @@ export default class MysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除失效ck */
|
/** 删除失效ck */
|
||||||
async delCk () {
|
async delCk() {
|
||||||
if (!this.ckUser) {
|
if (!this.ckUser) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -450,7 +457,7 @@ export default class MysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询次数满,今日内标记失效 */
|
/** 查询次数满,今日内标记失效 */
|
||||||
async disableToday (game = 'gs') {
|
async disableToday(game = 'gs') {
|
||||||
/** 统计次数设为超限 */
|
/** 统计次数设为超限 */
|
||||||
await this.ckUser.disable(game)
|
await this.ckUser.disable(game)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import { Player } from '#miao.models'
|
||||||
import { UserGameDB, sequelize } from './db/index.js'
|
import { UserGameDB, sequelize } from './db/index.js'
|
||||||
|
|
||||||
export default class User extends base {
|
export default class User extends base {
|
||||||
constructor (e) {
|
constructor(e) {
|
||||||
super(e)
|
super(e)
|
||||||
this.model = 'bingCk'
|
this.model = 'bingCk'
|
||||||
/** 绑定的uid */
|
/** 绑定的uid */
|
||||||
|
@ -28,17 +28,17 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前user实例
|
// 获取当前user实例
|
||||||
async user () {
|
async user() {
|
||||||
return await NoteUser.create(this.e)
|
return await NoteUser.create(this.e)
|
||||||
}
|
}
|
||||||
|
|
||||||
async resetCk () {
|
async resetCk() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
await user.initCache()
|
await user.initCache()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 绑定ck */
|
/** 绑定ck */
|
||||||
async bing () {
|
async bing() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
let set = gsCfg.getConfig('mys', 'set')
|
let set = gsCfg.getConfig('mys', 'set')
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 删除绑定ck */
|
/** 删除绑定ck */
|
||||||
async delCk () {
|
async delCk() {
|
||||||
let game
|
let game
|
||||||
if (this.e.game) {
|
if (this.e.game) {
|
||||||
game = this.e.game
|
game = this.e.game
|
||||||
|
@ -196,8 +196,8 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 绑定uid,若有ck的话优先使用ck-uid */
|
/** 绑定uid,若有ck的话优先使用ck-uid */
|
||||||
async bingUid () {
|
async bingUid() {
|
||||||
let uid = this.e.msg.match(/[1|2|3|5-9][0-9]{8}/g)
|
let uid = this.e.msg.match(/([1-9]|18)[0-9]{8}/g)
|
||||||
if (!uid) return
|
if (!uid) return
|
||||||
uid = uid[0]
|
uid = uid[0]
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
|
@ -205,7 +205,7 @@ export default class User extends base {
|
||||||
return await this.showUid()
|
return await this.showUid()
|
||||||
}
|
}
|
||||||
|
|
||||||
async delUid (index) {
|
async delUid(index) {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
let game = this.e
|
let game = this.e
|
||||||
let uidList = user.getUidList(game)
|
let uidList = user.getUidList(game)
|
||||||
|
@ -226,7 +226,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** #uid */
|
/** #uid */
|
||||||
async showUid_bak () {
|
async showUid_bak() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
let msg = []
|
let msg = []
|
||||||
let typeMap = { ck: 'CK Uid', reg: '绑定 Uid' }
|
let typeMap = { ck: 'CK Uid', reg: '绑定 Uid' }
|
||||||
|
@ -251,7 +251,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** #uid */
|
/** #uid */
|
||||||
async showUid () {
|
async showUid() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
let uids = [{
|
let uids = [{
|
||||||
key: 'gs',
|
key: 'gs',
|
||||||
|
@ -297,7 +297,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 切换uid */
|
/** 切换uid */
|
||||||
async toggleUid (index) {
|
async toggleUid(index) {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
let game = this.e
|
let game = this.e
|
||||||
let uidList = user.getUidList(game)
|
let uidList = user.getUidList(game)
|
||||||
|
@ -313,7 +313,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载V2ck */
|
/** 加载V2ck */
|
||||||
async loadOldDataV2 () {
|
async loadOldDataV2() {
|
||||||
let file = [
|
let file = [
|
||||||
'./data/MysCookie/NoteCookie.json',
|
'./data/MysCookie/NoteCookie.json',
|
||||||
'./data/NoteCookie/NoteCookie.json',
|
'./data/NoteCookie/NoteCookie.json',
|
||||||
|
@ -363,7 +363,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 加载V3ck */
|
/** 加载V3ck */
|
||||||
async loadOldDataV3 () {
|
async loadOldDataV3() {
|
||||||
let dir = './data/MysCookie/'
|
let dir = './data/MysCookie/'
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
return false
|
return false
|
||||||
|
@ -395,7 +395,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadOldUid () {
|
async loadOldUid() {
|
||||||
// 从DB中导入
|
// 从DB中导入
|
||||||
await sequelize.query('delete from UserGames where userId is null or data is null', {})
|
await sequelize.query('delete from UserGames where userId is null or data is null', {})
|
||||||
let games = await UserGameDB.findAll()
|
let games = await UserGameDB.findAll()
|
||||||
|
@ -437,7 +437,7 @@ export default class User extends base {
|
||||||
console.log('load Uid Data Done...')
|
console.log('load Uid Data Done...')
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadOldData (data) {
|
async loadOldData(data) {
|
||||||
let count = 0
|
let count = 0
|
||||||
if (!lodash.isPlainObject(data)) {
|
if (!lodash.isPlainObject(data)) {
|
||||||
return
|
return
|
||||||
|
@ -496,7 +496,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 我的ck */
|
/** 我的ck */
|
||||||
async myCk () {
|
async myCk() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
if (!user.hasCk) {
|
if (!user.hasCk) {
|
||||||
this.e.reply(['当前尚未绑定Cookie', segment.button([
|
this.e.reply(['当前尚未绑定Cookie', segment.button([
|
||||||
|
@ -510,7 +510,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkCkStatus () {
|
async checkCkStatus() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
if (!user.hasCk) {
|
if (!user.hasCk) {
|
||||||
await this.e.reply(`\n未绑定CK,当前绑定uid:${user.uid || '无'}`, false, { at: true })
|
await this.e.reply(`\n未绑定CK,当前绑定uid:${user.uid || '无'}`, false, { at: true })
|
||||||
|
@ -546,7 +546,7 @@ export default class User extends base {
|
||||||
])], false, { at: true })
|
])], false, { at: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
async userAdmin () {
|
async userAdmin() {
|
||||||
this.model = 'userAdmin'
|
this.model = 'userAdmin'
|
||||||
await MysInfo.initCache()
|
await MysInfo.initCache()
|
||||||
let stat = await MysUser.getStatData()
|
let stat = await MysUser.getStatData()
|
||||||
|
@ -558,7 +558,7 @@ export default class User extends base {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async bindNoteUser () {
|
async bindNoteUser() {
|
||||||
let user = await this.user()
|
let user = await this.user()
|
||||||
let id = user.qq
|
let id = user.qq
|
||||||
let { e } = this
|
let { e } = this
|
||||||
|
|
Loading…
Reference in New Issue