fix: login
This commit is contained in:
parent
08c4ce093c
commit
8fc6650510
|
@ -17,6 +17,13 @@ import ListenerLoader from './core/loader.js'
|
||||||
*/
|
*/
|
||||||
import { Client } from 'icqq'
|
import { Client } from 'icqq'
|
||||||
|
|
||||||
|
import { plugin } from './core/plugin.js'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* global
|
||||||
|
*/
|
||||||
|
global.plugin = plugin
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -71,7 +71,7 @@ export default class loginEvent extends EventListener {
|
||||||
*/
|
*/
|
||||||
inquirer
|
inquirer
|
||||||
.prompt({
|
.prompt({
|
||||||
// type: 'input',
|
type: 'input',
|
||||||
message: '回车刷新二维码,等待扫码中...\n',
|
message: '回车刷新二维码,等待扫码中...\n',
|
||||||
name: 'enter'
|
name: 'enter'
|
||||||
})
|
})
|
||||||
|
@ -134,7 +134,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) {
|
||||||
|
@ -211,7 +211,7 @@ export default class loginEvent extends EventListener {
|
||||||
|
|
||||||
//
|
//
|
||||||
await inquirer.prompt({
|
await inquirer.prompt({
|
||||||
// type: 'input',
|
type: 'input',
|
||||||
message: '验证完成后按回车确认,等待在操作中...',
|
message: '验证完成后按回车确认,等待在操作中...',
|
||||||
name: 'enter'
|
name: 'enter'
|
||||||
})
|
})
|
||||||
|
@ -261,7 +261,7 @@ export default class loginEvent extends EventListener {
|
||||||
console.log('\n' + logger.green(event.url) + '\n')
|
console.log('\n' + logger.green(event.url) + '\n')
|
||||||
console.log('请打开上面链接,完成验证后按回车')
|
console.log('请打开上面链接,完成验证后按回车')
|
||||||
await inquirer.prompt({
|
await inquirer.prompt({
|
||||||
// type: 'input',
|
type: 'input',
|
||||||
message: '等待操作中...',
|
message: '等待操作中...',
|
||||||
name: 'enter'
|
name: 'enter'
|
||||||
})
|
})
|
||||||
|
@ -272,7 +272,7 @@ export default class loginEvent extends EventListener {
|
||||||
await sleep(200)
|
await sleep(200)
|
||||||
logger.info(`验证码已发送:${event.phone}\n`)
|
logger.info(`验证码已发送:${event.phone}\n`)
|
||||||
let res = await inquirer.prompt({
|
let res = await inquirer.prompt({
|
||||||
// type: 'input',
|
type: 'input',
|
||||||
message: '请输入短信验证码:',
|
message: '请输入短信验证码:',
|
||||||
name: 'sms'
|
name: 'sms'
|
||||||
})
|
})
|
||||||
|
|
|
@ -16,7 +16,7 @@ class ListenerLoader {
|
||||||
|
|
||||||
const files = fs
|
const files = fs
|
||||||
.readdirSync('./src/core/events')
|
.readdirSync('./src/core/events')
|
||||||
.filter(file => file.endsWith('.js'))
|
.filter(file => /(.ts|.js)$/.test(file))
|
||||||
|
|
||||||
for (let File of files) {
|
for (let File of files) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import schedule from 'node-schedule'
|
||||||
import { segment } from 'icqq'
|
import { segment } from 'icqq'
|
||||||
import chokidar from 'chokidar'
|
import chokidar from 'chokidar'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import path from 'node:path'
|
import path, { join } from 'node:path'
|
||||||
import Runtime from './runtime.js'
|
import Runtime from './runtime.js'
|
||||||
import Handler from './handler.js'
|
import Handler from './handler.js'
|
||||||
|
|
||||||
|
@ -17,12 +17,16 @@ class PluginsLoader {
|
||||||
priority = []
|
priority = []
|
||||||
handler = {}
|
handler = {}
|
||||||
task = []
|
task = []
|
||||||
dir = 'plugins'
|
|
||||||
|
//
|
||||||
|
dir = join(process.cwd(),'plugins')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 命令冷却cd
|
* 命令冷却cd
|
||||||
*/
|
*/
|
||||||
groupGlobalCD = {}
|
groupGlobalCD = {}
|
||||||
|
|
||||||
|
//
|
||||||
singleCD = {}
|
singleCD = {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +47,6 @@ class PluginsLoader {
|
||||||
*/
|
*/
|
||||||
srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
|
srReg = /^#?(\*|星铁|星轨|穹轨|星穹|崩铁|星穹铁道|崩坏星穹铁道|铁道)+/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @returns
|
* @returns
|
||||||
|
@ -55,21 +58,31 @@ class PluginsLoader {
|
||||||
if (val.isFile()) continue
|
if (val.isFile()) continue
|
||||||
const tmp = {
|
const tmp = {
|
||||||
name: val.name,
|
name: val.name,
|
||||||
path: `../../${this.dir}/${val.name}`,
|
path: join(this.dir,val.name),
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (await fs.stat(`${this.dir}/${val.name}/index.js`)) {
|
const dir = join(tmp.path,'index.js')
|
||||||
tmp.path = `${tmp.path}/index.js`
|
if (await fs.stat(dir)) {
|
||||||
|
tmp.path = dir
|
||||||
ret.push(tmp)
|
ret.push(tmp)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} catch (err) { }
|
} catch (err) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
const apps = await fs.readdir(`${this.dir}/${val.name}`, { withFileTypes: true })
|
//
|
||||||
|
|
||||||
|
const dir = join(this.dir,val.name)
|
||||||
|
|
||||||
|
const apps = await fs.readdir(dir, { withFileTypes: true })
|
||||||
|
|
||||||
|
//
|
||||||
for (const app of apps) {
|
for (const app of apps) {
|
||||||
if (!app.isFile()) continue
|
if (!app.isFile()) continue
|
||||||
if (!app.name.endsWith('.js')) continue
|
// .js .ts
|
||||||
|
if (!/^(.js|.ts)$/.test(app.name)) continue
|
||||||
ret.push({
|
ret.push({
|
||||||
name: `${tmp.name}/${app.name}`,
|
name: `${tmp.name}/${app.name}`,
|
||||||
path: `${tmp.path}/${app.name}`,
|
path: `${tmp.path}/${app.name}`,
|
||||||
|
@ -121,7 +134,7 @@ class PluginsLoader {
|
||||||
*/
|
*/
|
||||||
async importPlugin(file, packageErr?:any) {
|
async importPlugin(file, packageErr?:any) {
|
||||||
try {
|
try {
|
||||||
let app = await import(file.path)
|
let app = await import(`file://${file.path}`)
|
||||||
if (app.apps) app = { ...app.apps }
|
if (app.apps) app = { ...app.apps }
|
||||||
const pluginArray = []
|
const pluginArray = []
|
||||||
lodash.forEach(app, p =>
|
lodash.forEach(app, p =>
|
||||||
|
|
|
@ -9,6 +9,6 @@ declare global {
|
||||||
var redis: RedisClientType
|
var redis: RedisClientType
|
||||||
var Bot: typeof Yunzai.prototype
|
var Bot: typeof Yunzai.prototype
|
||||||
var segment: typeof se
|
var segment: typeof se
|
||||||
var plugin: typeof p.prototype
|
var plugin: typeof p
|
||||||
var logger: any
|
var logger: any
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export { Common, Date } from '#miao'
|
export { Common, Data } from '#miao'
|
||||||
export { Character, Weapon } from '#miao.models'
|
export { Character, Weapon } from '#miao.models'
|
||||||
|
|
Loading…
Reference in New Issue