一些已知问题修正
This commit is contained in:
parent
26051e1f89
commit
8d0b1642c6
|
@ -13,6 +13,8 @@ import MysApi from '../../plugins/genshin/model/mys/mysApi.js'
|
||||||
import MysInfo from '../../plugins/genshin/model/mys/mysInfo.js'
|
import MysInfo from '../../plugins/genshin/model/mys/mysInfo.js'
|
||||||
import puppeteer from '../puppeteer/puppeteer.js'
|
import puppeteer from '../puppeteer/puppeteer.js'
|
||||||
import { Version } from '#miao'
|
import { Version } from '#miao'
|
||||||
|
import NoteUser from '../../plugins/genshin/model/mys/NoteUser.js'
|
||||||
|
import MysUser from '../../plugins/genshin/model/mys/MysUser.js'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常用的处理方法
|
* 常用的处理方法
|
||||||
|
@ -56,6 +58,14 @@ export default class Runtime {
|
||||||
return MysInfo
|
return MysInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get NoteUser () {
|
||||||
|
return NoteUser
|
||||||
|
}
|
||||||
|
|
||||||
|
get MysUser () {
|
||||||
|
return MysUser
|
||||||
|
}
|
||||||
|
|
||||||
static async init (e) {
|
static async init (e) {
|
||||||
e.runtime = new Runtime(e)
|
e.runtime = new Runtime(e)
|
||||||
e.user = await MysInfo.getNoteUser(e)
|
e.user = await MysInfo.getNoteUser(e)
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
import plugin from '../../../lib/plugins/plugin.js'
|
import plugin from '../../../lib/plugins/plugin.js'
|
||||||
import { PayData, renderImg } from '../model/payLogData.js'
|
import { PayData, renderImg } from '../model/payLogData.js'
|
||||||
|
import NoteUser from '../model/mys/NoteUser.js'
|
||||||
import url from 'url'
|
import url from 'url'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import yaml from 'yaml'
|
import yaml from 'yaml'
|
||||||
|
|
||||||
export class payLog extends plugin {
|
export class payLog extends plugin {
|
||||||
|
dirPath = path.resolve('./data/payLog/')
|
||||||
|
authKey = ''
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
super({
|
super({
|
||||||
name: '充值记录',
|
name: '充值记录',
|
||||||
|
@ -34,9 +38,6 @@ export class payLog extends plugin {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
dirPath = path.resolve('./data/payLog/')
|
|
||||||
authKey = ''
|
|
||||||
|
|
||||||
async payLog (e) {
|
async payLog (e) {
|
||||||
// 判断是否存有已经生成的数据
|
// 判断是否存有已经生成的数据
|
||||||
if (!fs.readdirSync(this.dirPath, 'utf-8').includes(e.user_id + '.yaml')) {
|
if (!fs.readdirSync(this.dirPath, 'utf-8').includes(e.user_id + '.yaml')) {
|
||||||
|
@ -146,17 +147,9 @@ export class payLog extends plugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 判断主uid,若没有则返回false,有则返回主uid */
|
/** 判断主uid,若没有则返回false,有则返回主uid */
|
||||||
async isMain (id) {
|
async isMain (id, game = 'gs') {
|
||||||
const ckPath = path.resolve('./data/MysCookie')
|
let user = await NoteUser.create(id)
|
||||||
if (fs.readdirSync(ckPath, 'utf-8').includes(id + '.yaml')) {
|
return user.getSelfUid(game)
|
||||||
let ck = fs.readFileSync(ckPath + `/${id}.yaml`, 'utf-8')
|
|
||||||
ck = yaml.parse(ck)
|
|
||||||
for (let k in ck) {
|
|
||||||
if (ck[k].isMain) return k
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 存储数据 */
|
/** 存储数据 */
|
||||||
|
|
|
@ -58,10 +58,6 @@ export class role extends plugin {
|
||||||
|
|
||||||
/** 初始化配置文件 */
|
/** 初始化配置文件 */
|
||||||
async init () {
|
async init () {
|
||||||
let file = './data/MysCookie'
|
|
||||||
if (!fs.existsSync(file)) {
|
|
||||||
fs.mkdirSync(file)
|
|
||||||
}
|
|
||||||
|
|
||||||
let pubCk = './plugins/genshin/config/mys.pubCk.yaml'
|
let pubCk = './plugins/genshin/config/mys.pubCk.yaml'
|
||||||
if (!fs.existsSync(pubCk)) {
|
if (!fs.existsSync(pubCk)) {
|
||||||
|
|
|
@ -4,6 +4,8 @@ import fs from 'node:fs'
|
||||||
import { promisify } from 'node:util'
|
import { promisify } from 'node:util'
|
||||||
import lodash from 'lodash'
|
import lodash from 'lodash'
|
||||||
import MysInfo from './mys/mysInfo.js'
|
import MysInfo from './mys/mysInfo.js'
|
||||||
|
import NoteUser from './mys/NoteUser.js'
|
||||||
|
import MysUser from './mys/MysUser.js'
|
||||||
|
|
||||||
/** 配置文件 */
|
/** 配置文件 */
|
||||||
class GsCfg {
|
class GsCfg {
|
||||||
|
@ -22,6 +24,10 @@ class GsCfg {
|
||||||
this.ignore = ['mys.pubCk', 'gacha.set', 'bot.help', 'role.name']
|
this.ignore = ['mys.pubCk', 'gacha.set', 'bot.help', 'role.name']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get element () {
|
||||||
|
return { ...this.getdefSet('element', 'role'), ...this.getdefSet('element', 'weapon') }
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param app 功能
|
* @param app 功能
|
||||||
* @param name 配置文件名称
|
* @param name 配置文件名称
|
||||||
|
@ -88,65 +94,40 @@ class GsCfg {
|
||||||
this.watcher[type][key] = watcher
|
this.watcher[type][key] = watcher
|
||||||
}
|
}
|
||||||
|
|
||||||
get element () {
|
|
||||||
return { ...this.getdefSet('element', 'role'), ...this.getdefSet('element', 'weapon') }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 读取所有用户绑定的ck */
|
/** 读取所有用户绑定的ck */
|
||||||
async getBingCk () {
|
async getBingCk (game = 'gs') {
|
||||||
let ck = {}
|
let ck = {}
|
||||||
let ckQQ = {}
|
let ckQQ = {}
|
||||||
let noteCk = {}
|
let noteCk = {}
|
||||||
let dir = './data/MysCookie/'
|
|
||||||
let files = fs.readdirSync(dir).filter(file => file.endsWith('.yaml'))
|
|
||||||
|
|
||||||
const readFile = promisify(fs.readFile)
|
await NoteUser.forEach(async function (user) {
|
||||||
|
let qq = user.qq + ''
|
||||||
let promises = []
|
let tmp = {}
|
||||||
|
lodash.forEach(user.mysUsers, (mys) => {
|
||||||
files.forEach((v) => promises.push(readFile(`${dir}${v}`, 'utf8')))
|
let uids = mys.getUids(game)
|
||||||
|
lodash.forEach(uids, (uid) => {
|
||||||
const res = await Promise.all(promises)
|
let ckData = mys.getCkInfo(game)
|
||||||
|
ckData.qq = qq
|
||||||
res.forEach((v) => {
|
if (!ck[uid]) {
|
||||||
let tmp = YAML.parse(v)
|
ck[uid] = ckData
|
||||||
let qq
|
ckQQ[qq] = ckData
|
||||||
lodash.forEach(tmp, (item, uid) => {
|
|
||||||
qq = item.qq
|
|
||||||
ck[String(uid)] = item
|
|
||||||
if (item.isMain && !ckQQ[String(item.qq)]) {
|
|
||||||
ckQQ[String(item.qq)] = item
|
|
||||||
}
|
}
|
||||||
|
tmp[uid] = ckData
|
||||||
})
|
})
|
||||||
if (qq && !ckQQ[String(qq)]) {
|
|
||||||
ckQQ[String(qq)] = Object.values(tmp)[0]
|
|
||||||
}
|
|
||||||
noteCk[String(qq)] = tmp
|
|
||||||
})
|
})
|
||||||
|
noteCk[qq] = tmp
|
||||||
|
})
|
||||||
return { ck, ckQQ, noteCk }
|
return { ck, ckQQ, noteCk }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 获取qq号绑定ck */
|
/** 获取qq号绑定ck */
|
||||||
getBingCkSingle (userId) {
|
getBingCkSingle (userId) {
|
||||||
let file = `./data/MysCookie/${userId}.yaml`
|
console.log('gsCfg.getBingCkSingle() 即将废弃')
|
||||||
try {
|
|
||||||
let ck = fs.readFileSync(file, 'utf-8')
|
|
||||||
ck = YAML.parse(ck)
|
|
||||||
return ck
|
|
||||||
} catch (error) {
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
saveBingCk (userId, data) {
|
saveBingCk (userId, data) {
|
||||||
let file = `./data/MysCookie/${userId}.yaml`
|
console.log('gsCfg.saveBingCk() 即将废弃')
|
||||||
if (lodash.isEmpty(data)) {
|
|
||||||
fs.existsSync(file) && fs.unlinkSync(file)
|
|
||||||
} else {
|
|
||||||
let yaml = YAML.stringify(data)
|
|
||||||
fs.writeFileSync(file, yaml, 'utf8')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -249,7 +249,6 @@ export default class MysUser extends BaseModel {
|
||||||
|
|
||||||
// 不建议使用,为了兼容老数据格式,后续废弃
|
// 不建议使用,为了兼容老数据格式,后续废弃
|
||||||
getCkInfo (game = 'gs') {
|
getCkInfo (game = 'gs') {
|
||||||
let gameKey = this.gameKey(game)
|
|
||||||
return {
|
return {
|
||||||
ck: this.ck,
|
ck: this.ck,
|
||||||
uid: this.getUid(game),
|
uid: this.getUid(game),
|
||||||
|
|
|
@ -97,7 +97,7 @@ export default class NoteUser extends BaseModel {
|
||||||
|
|
||||||
static async forEach (fn) {
|
static async forEach (fn) {
|
||||||
let dbs = await UserDB.findAll()
|
let dbs = await UserDB.findAll()
|
||||||
await Data.forEach(users, async (db) => {
|
await Data.forEach(dbs, async (db) => {
|
||||||
let user = await NoteUser.create(db.id, db)
|
let user = await NoteUser.create(db.id, db)
|
||||||
return await fn(user)
|
return await fn(user)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import md5 from 'md5'
|
import md5 from 'md5'
|
||||||
import lodash from 'lodash'
|
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import cfg from '../../../../lib/config/config.js'
|
import cfg from '../../../../lib/config/config.js'
|
||||||
import apiTool from './apiTool.js'
|
import apiTool from './apiTool.js'
|
||||||
|
|
||||||
let HttpsProxyAgent = ''
|
let HttpsProxyAgent = ''
|
||||||
export default class MysApi {
|
export default class MysApi {
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +26,12 @@ export default class MysApi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable quotes */
|
||||||
|
get device () {
|
||||||
|
if (!this._device) this._device = `Yz-${md5(this.uid).substring(0, 5)}`
|
||||||
|
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
|
||||||
|
@ -183,12 +189,6 @@ export default class MysApi {
|
||||||
redis.setEx(cacheKey, this.cacheCd, JSON.stringify(res))
|
redis.setEx(cacheKey, this.cacheCd, JSON.stringify(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* eslint-disable quotes */
|
|
||||||
get device() {
|
|
||||||
if (!this._device) this._device = `Yz-${md5(this.uid).substring(0, 5)}`
|
|
||||||
return this._device
|
|
||||||
}
|
|
||||||
|
|
||||||
async getAgent () {
|
async getAgent () {
|
||||||
let proxyAddress = cfg.bot.proxyAddress
|
let proxyAddress = cfg.bot.proxyAddress
|
||||||
if (!proxyAddress) return null
|
if (!proxyAddress) return null
|
||||||
|
|
|
@ -20,9 +20,11 @@ export default class Note extends base {
|
||||||
let device_fp = await MysInfo.get(this.e, 'getFp', {
|
let device_fp = await MysInfo.get(this.e, 'getFp', {
|
||||||
seed_id
|
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
|
'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
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 501 KiB |
Binary file not shown.
After Width: | Height: | Size: 135 KiB |
Binary file not shown.
After Width: | Height: | Size: 107 KiB |
Binary file not shown.
After Width: | Height: | Size: 19 KiB |
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
Loading…
Reference in New Issue