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