fix: 补充类型
This commit is contained in:
parent
7cb7fbdd6d
commit
cf8e08c312
|
@ -1,5 +1,5 @@
|
||||||
import cfg from "./config.js"
|
import cfg from "./config.js"
|
||||||
import { sleep } from "../utils/common.js"
|
import { execAsync, sleep } from "../utils/common.js"
|
||||||
import { createClient } from "redis"
|
import { createClient } from "redis"
|
||||||
import { exec } from "node:child_process"
|
import { exec } from "node:child_process"
|
||||||
|
|
||||||
|
@ -46,7 +46,8 @@ export default async function redisInit() {
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 全局变量 redis */
|
/** 全局变量 redis */
|
||||||
global.redis = client
|
global.redis = client as any
|
||||||
|
|
||||||
logger.info("Redis 连接成功")
|
logger.info("Redis 连接成功")
|
||||||
return client
|
return client
|
||||||
}
|
}
|
||||||
|
@ -56,21 +57,23 @@ export default async function redisInit() {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function aarch64() {
|
export async function aarch64() {
|
||||||
if (process.platform == "win32")
|
if (process.platform == "win32"){
|
||||||
return ""
|
return ""
|
||||||
/** 判断arch */
|
|
||||||
const arch = await execSync("uname -m")
|
|
||||||
if (arch.stdout && arch.stdout.includes("aarch64")) {
|
|
||||||
/** 判断redis版本 */
|
|
||||||
let v = await execSync("redis-server -v")
|
|
||||||
if (v.stdout) {
|
|
||||||
v = v.stdout.match(/v=(\d)./)
|
|
||||||
/** 忽略arm警告 */
|
|
||||||
if (v && v[1] >= 6)
|
|
||||||
return " --ignore-warnings ARM64-COW-BUG"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return ""
|
return await execAsync("uname -m").then( async arch=>{
|
||||||
|
if (arch.stdout && arch.stdout.includes("aarch64")) {
|
||||||
|
/** 判断redis版本 */
|
||||||
|
let v = await execAsync("redis-server -v")
|
||||||
|
if (v.stdout) {
|
||||||
|
const data = v.stdout.match(/v=(\d)./)
|
||||||
|
/** 忽略arm警告 */
|
||||||
|
if (data && Number(data[1]) >= 6){
|
||||||
|
return " --ignore-warnings ARM64-COW-BUG"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ''
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,6 +44,11 @@ const COLUMNS = {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class MysUserDB extends BaseModel {
|
class MysUserDB extends BaseModel {
|
||||||
|
ck = null
|
||||||
|
type = null
|
||||||
|
device = null
|
||||||
|
uids = null
|
||||||
|
|
||||||
static async find(ltuid = '', create = false) {
|
static async find(ltuid = '', create = false) {
|
||||||
// DB查询
|
// DB查询
|
||||||
let mys = await MysUserDB.findByPk(ltuid)
|
let mys = await MysUserDB.findByPk(ltuid)
|
||||||
|
|
|
@ -81,13 +81,16 @@ class UserDB extends BaseModel {
|
||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
|
games = null
|
||||||
|
ltuids = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param user
|
* @param user
|
||||||
*/
|
*/
|
||||||
async saveDB(user) {
|
async saveDB(user) {
|
||||||
let db = this
|
const db = this
|
||||||
let ltuids = []
|
const ltuids = []
|
||||||
lodash.forEach(user.mysUsers, mys => {
|
lodash.forEach(user.mysUsers, mys => {
|
||||||
if (mys.ck && mys.ltuid) {
|
if (mys.ck && mys.ltuid) {
|
||||||
ltuids.push(mys.ltuid)
|
ltuids.push(mys.ltuid)
|
||||||
|
|
|
@ -14,6 +14,9 @@ let inSlider = false
|
||||||
*/
|
*/
|
||||||
export default class loginEvent extends EventListener {
|
export default class loginEvent extends EventListener {
|
||||||
|
|
||||||
|
|
||||||
|
client = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -64,8 +67,10 @@ export default class loginEvent extends EventListener {
|
||||||
}
|
}
|
||||||
}, 2000)
|
}, 2000)
|
||||||
|
|
||||||
/** 刷新二维码 */
|
/**
|
||||||
inquirer.prompt({ type: 'Input', message: '回车刷新二维码,等待扫码中...\n', name: 'enter' }).then(async () => {
|
* 刷新二维码
|
||||||
|
*/
|
||||||
|
inquirer.prompt({ type: 'input', message: '回车刷新二维码,等待扫码中...\n', name: 'enter' }).then(async () => {
|
||||||
if (!inSlider) {
|
if (!inSlider) {
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
console.log(' 重新刷新二维码...\n\n')
|
console.log(' 重新刷新二维码...\n\n')
|
||||||
|
@ -113,7 +118,7 @@ export default class loginEvent extends EventListener {
|
||||||
|
|
||||||
if (!ticket) {
|
if (!ticket) {
|
||||||
let res = await inquirer.prompt({
|
let res = await inquirer.prompt({
|
||||||
type: 'Input',
|
type: 'input',
|
||||||
message: '请输入ticket:',
|
message: '请输入ticket:',
|
||||||
name: 'ticket',
|
name: 'ticket',
|
||||||
validate(value) {
|
validate(value) {
|
||||||
|
@ -145,11 +150,10 @@ export default class loginEvent extends EventListener {
|
||||||
console.log(`${logger.green(req)}\n----完成后将自动进行登录----`)
|
console.log(`${logger.green(req)}\n----完成后将自动进行登录----`)
|
||||||
|
|
||||||
for (let i = 0; i < 40; i++) {
|
for (let i = 0; i < 40; i++) {
|
||||||
let res = await fetch(req, {
|
const res = await fetch(req, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({ submit: Bot.uin })
|
body: JSON.stringify({ submit: Bot.uin })
|
||||||
})
|
}).then(res => res.json())
|
||||||
res = await res.json()
|
|
||||||
if (res.data?.ticket) return res.data.ticket
|
if (res.data?.ticket) return res.data.ticket
|
||||||
await sleep(3000)
|
await sleep(3000)
|
||||||
}
|
}
|
||||||
|
@ -162,6 +166,9 @@ export default class loginEvent extends EventListener {
|
||||||
*/
|
*/
|
||||||
async requestCode(url) {
|
async requestCode(url) {
|
||||||
let txhelper = {
|
let txhelper = {
|
||||||
|
req: null,
|
||||||
|
res: null,
|
||||||
|
code: null,
|
||||||
url: url.replace('ssl.captcha.qq.com', 'txhelper.glitch.me')
|
url: url.replace('ssl.captcha.qq.com', 'txhelper.glitch.me')
|
||||||
}
|
}
|
||||||
txhelper.req = await fetch(txhelper.url).catch((err) => console.log(err.toString()))
|
txhelper.req = await fetch(txhelper.url).catch((err) => console.log(err.toString()))
|
||||||
|
@ -177,14 +184,21 @@ export default class loginEvent extends EventListener {
|
||||||
console.log(`\n请打开滑动验证app,输入请求码${logger.green('【' + txhelper.code + '】')},然后完成滑动验证\n`)
|
console.log(`\n请打开滑动验证app,输入请求码${logger.green('【' + txhelper.code + '】')},然后完成滑动验证\n`)
|
||||||
|
|
||||||
await sleep(200)
|
await sleep(200)
|
||||||
|
|
||||||
|
//
|
||||||
await inquirer.prompt({
|
await inquirer.prompt({
|
||||||
type: 'Input',
|
type: 'input',
|
||||||
message: '验证完成后按回车确认,等待在操作中...',
|
message: '验证完成后按回车确认,等待在操作中...',
|
||||||
name: 'enter'
|
name: 'enter'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
//
|
||||||
txhelper.res = await fetch(txhelper.url).catch((err) => console.log(err.toString()))
|
txhelper.res = await fetch(txhelper.url).catch((err) => console.log(err.toString()))
|
||||||
|
|
||||||
|
//
|
||||||
if (!txhelper.res) return false
|
if (!txhelper.res) return false
|
||||||
|
|
||||||
|
//
|
||||||
txhelper.res = await txhelper.res.text()
|
txhelper.res = await txhelper.res.text()
|
||||||
|
|
||||||
if (!txhelper.res) return false
|
if (!txhelper.res) return false
|
||||||
|
@ -219,14 +233,14 @@ export default class loginEvent extends EventListener {
|
||||||
if (ret.type == '1.网页扫码验证') {
|
if (ret.type == '1.网页扫码验证') {
|
||||||
console.log('\n' + logger.green(event.url) + '\n')
|
console.log('\n' + logger.green(event.url) + '\n')
|
||||||
console.log('请打开上面链接,完成验证后按回车')
|
console.log('请打开上面链接,完成验证后按回车')
|
||||||
await inquirer.prompt({ type: 'Input', message: '等待操作中...', name: 'enter' })
|
await inquirer.prompt({ type: 'input', message: '等待操作中...', name: 'enter' })
|
||||||
await this.client.login()
|
await this.client.login()
|
||||||
} else {
|
} else {
|
||||||
console.log('\n')
|
console.log('\n')
|
||||||
this.client.sendSmsCode()
|
this.client.sendSmsCode()
|
||||||
await sleep(200)
|
await sleep(200)
|
||||||
logger.info(`验证码已发送:${event.phone}\n`)
|
logger.info(`验证码已发送:${event.phone}\n`)
|
||||||
let res = await inquirer.prompt({ type: 'Input', message: '请输入短信验证码:', name: 'sms' })
|
let res = await inquirer.prompt({ type: 'input', message: '请输入短信验证码:', name: 'sms' })
|
||||||
await this.client.submitSmsCode(res.sms)
|
await this.client.submitSmsCode(res.sms)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ class PluginsLoader {
|
||||||
* @param file
|
* @param file
|
||||||
* @param packageErr
|
* @param packageErr
|
||||||
*/
|
*/
|
||||||
async importPlugin(file, packageErr) {
|
async importPlugin(file, packageErr?:any) {
|
||||||
try {
|
try {
|
||||||
let app = await import(file.path)
|
let app = await import(file.path)
|
||||||
if (app.apps) app = { ...app.apps }
|
if (app.apps) app = { ...app.apps }
|
||||||
|
@ -497,7 +497,7 @@ class PluginsLoader {
|
||||||
* @param data.recallMsg 群聊是否撤回消息,0-120秒,0不撤回
|
* @param data.recallMsg 群聊是否撤回消息,0-120秒,0不撤回
|
||||||
* @param data.at 是否at用户
|
* @param data.at 是否at用户
|
||||||
*/
|
*/
|
||||||
e.reply = async (msg = '', quote = false, data = {}) => {
|
e.reply = async (msg = '', quote = false, data:any = {}) => {
|
||||||
if (!msg) return false
|
if (!msg) return false
|
||||||
|
|
||||||
/** 禁言中 */
|
/** 禁言中 */
|
||||||
|
|
|
@ -193,10 +193,13 @@ export default class MysUser extends BaseModel {
|
||||||
*/
|
*/
|
||||||
static async getStatData() {
|
static async getStatData() {
|
||||||
let totalCount = {}
|
let totalCount = {}
|
||||||
let ret = { servs: {} }
|
let ret = { servs: {}, count: null }
|
||||||
await MysUser.eachServ(async function (servCache, serv) {
|
await MysUser.eachServ(async function (servCache, serv) {
|
||||||
let data = await servCache.zStat(tables.detail)
|
let data = await servCache.zStat(tables.detail)
|
||||||
let count = {}
|
let count = {
|
||||||
|
normal: null,
|
||||||
|
query: null
|
||||||
|
}
|
||||||
let list = []
|
let list = []
|
||||||
let query = 0
|
let query = 0
|
||||||
const stat = (type, num) => {
|
const stat = (type, num) => {
|
||||||
|
@ -438,7 +441,7 @@ export default class MysUser extends BaseModel {
|
||||||
* @param serv
|
* @param serv
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async getGameRole(serv = 'mys') {
|
async getGameRole(serv = 'mys'): Promise<any> {
|
||||||
const ck = this.ck
|
const ck = this.ck
|
||||||
const url = {
|
const url = {
|
||||||
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie',
|
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie',
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class MysApi {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
getUrl(type, data = {}) {
|
getUrl(type, data = {}) {
|
||||||
let urlMap = this.apiTool.getUrlMap({ ...data, deviceId: this.device })
|
const urlMap = this.apiTool.getUrlMap({ ...data, deviceId: this.device })
|
||||||
if (!urlMap[type]) return false
|
if (!urlMap[type]) return false
|
||||||
|
|
||||||
let { url, query = '', body = '' } = urlMap[type]
|
let { url, query = '', body = '' } = urlMap[type]
|
||||||
|
@ -70,7 +70,7 @@ export default class MysApi {
|
||||||
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)
|
const headers = this.getHeaders(query, body)
|
||||||
|
|
||||||
return { url, headers, body }
|
return { url, headers, body }
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,9 @@ export default class MysApi {
|
||||||
return this.isSr ? 'prod_gf_cn' : 'cn_gf01'
|
return this.isSr ? 'prod_gf_cn' : 'cn_gf01'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_device_fp = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
|
@ -106,7 +109,7 @@ export default class MysApi {
|
||||||
* @param cached
|
* @param cached
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
async getData(type, data = {}, cached = false) {
|
async getData(type, data:any = {}, cached = false) {
|
||||||
if (
|
if (
|
||||||
!this._device_fp &&
|
!this._device_fp &&
|
||||||
!data?.Getfp &&
|
!data?.Getfp &&
|
||||||
|
@ -142,6 +145,8 @@ export default class MysApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
let param = {
|
let param = {
|
||||||
|
method:null,
|
||||||
|
body:null,
|
||||||
headers,
|
headers,
|
||||||
agent: await this.getAgent(),
|
agent: await this.getAgent(),
|
||||||
timeout: 10000
|
timeout: 10000
|
||||||
|
@ -152,7 +157,11 @@ export default class MysApi {
|
||||||
} else {
|
} else {
|
||||||
param.method = 'get'
|
param.method = 'get'
|
||||||
}
|
}
|
||||||
let response = {}
|
let response = {
|
||||||
|
ok:null,
|
||||||
|
status: null,
|
||||||
|
statusText:null
|
||||||
|
}
|
||||||
let start = Date.now()
|
let start = Date.now()
|
||||||
try {
|
try {
|
||||||
response = await fetch(url, param)
|
response = await fetch(url, param)
|
||||||
|
|
|
@ -240,6 +240,8 @@ export default class MysInfo {
|
||||||
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) return false
|
||||||
|
|
||||||
if (!mysInfo.uid || !mysInfo.ckInfo.ck) return false
|
if (!mysInfo.uid || !mysInfo.ckInfo.ck) return false
|
||||||
e.uid = mysInfo.uid
|
e.uid = mysInfo.uid
|
||||||
|
|
||||||
|
@ -330,6 +332,8 @@ export default class MysInfo {
|
||||||
logger.mark(`加载用户UID:${userCount}个,加入查询池`)
|
logger.mark(`加载用户UID:${userCount}个,加入查询池`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static initing = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化缓存
|
* 初始化缓存
|
||||||
* @param force 若已经初始化是否强制初始化
|
* @param force 若已经初始化是否强制初始化
|
||||||
|
@ -351,7 +355,7 @@ export default class MysInfo {
|
||||||
// 初始化公共ck
|
// 初始化公共ck
|
||||||
await MysInfo.initPubCk()
|
await MysInfo.initPubCk()
|
||||||
|
|
||||||
await cache.set('cache-ready', new Date() * 1)
|
await cache.set('cache-ready', Date.now())
|
||||||
delete this.initing
|
delete this.initing
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { promisify } from 'util'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
import fs from 'node:fs'
|
import fs from 'node:fs'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
|
import { exec } from 'child_process'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 休眠函数
|
* 休眠函数
|
||||||
|
@ -47,3 +48,21 @@ export function mkdirs(dirname: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param cmd
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export function execAsync(cmd: string): Promise<{
|
||||||
|
stdout: string,
|
||||||
|
stderr: string
|
||||||
|
}> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(cmd, (error, stdout, stderr) => {
|
||||||
|
if (error) reject(error)
|
||||||
|
resolve({ stdout, stderr })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue