feat: 优化导出
This commit is contained in:
parent
3ea075091a
commit
c8a60391c3
|
@ -3,39 +3,27 @@
|
||||||
* 配置初始化
|
* 配置初始化
|
||||||
* **********
|
* **********
|
||||||
*/
|
*/
|
||||||
import './config/init.js'
|
import '../config/init.js'
|
||||||
/**
|
/**
|
||||||
* **********
|
* **********
|
||||||
* 配置读取工具
|
* 配置读取工具
|
||||||
* **********
|
* **********
|
||||||
*/
|
*/
|
||||||
import cfg from './config/config.js'
|
import cfg from '../config/config.js'
|
||||||
/**
|
/**
|
||||||
* **********
|
* **********
|
||||||
* 监听
|
* 监听
|
||||||
* **********
|
* **********
|
||||||
*/
|
*/
|
||||||
import ListenerLoader from './core/events.loader.js'
|
import ListenerLoader from './events.loader.js'
|
||||||
/**
|
/**
|
||||||
* 扩展
|
* 扩展
|
||||||
*/
|
*/
|
||||||
import { Client, segment } from 'icqq'
|
import { Client as IcqqClient } from 'icqq'
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
import { plugin } from './core/plugins/index.js'
|
export class Client extends IcqqClient {
|
||||||
/**
|
|
||||||
* global.plugin
|
|
||||||
*/
|
|
||||||
global.plugin = plugin
|
|
||||||
/**
|
|
||||||
* global.segment
|
|
||||||
*/
|
|
||||||
global.segment = segment
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export class Yunzai extends Client {
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param conf
|
* @param conf
|
||||||
|
@ -52,7 +40,7 @@ export class Yunzai extends Client {
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
static async run() {
|
static async run() {
|
||||||
const bot = new Yunzai(cfg.bot)
|
const bot = new Client(cfg.bot)
|
||||||
/** 加载监听事件 */
|
/** 加载监听事件 */
|
||||||
await ListenerLoader.load(bot)
|
await ListenerLoader.load(bot)
|
||||||
|
|
||||||
|
@ -79,6 +67,8 @@ export class Yunzai extends Client {
|
||||||
/** 全局变量 bot */
|
/** 全局变量 bot */
|
||||||
global.Bot = bot
|
global.Bot = bot
|
||||||
/** 加载插件 */
|
/** 加载插件 */
|
||||||
return await (await import('./core/plugins.loader.js')).default.load()
|
return await (await import('./plugins.loader.js')).default.load()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const Bot = global.Bot as typeof Client.prototype
|
|
@ -0,0 +1,10 @@
|
||||||
|
import EventLogin from './events/login'
|
||||||
|
import EventMessage from './events/message'
|
||||||
|
import EventNotice from './events/notice'
|
||||||
|
import EventOffine from './events/offline'
|
||||||
|
import EventOnline from './events/online'
|
||||||
|
export { EventLogin }
|
||||||
|
export { EventMessage }
|
||||||
|
export { EventNotice }
|
||||||
|
export { EventOffine }
|
||||||
|
export { EventOnline }
|
|
@ -1 +1 @@
|
||||||
export { Client, segment } from 'icqq'
|
export { segment } from 'icqq'
|
||||||
|
|
|
@ -3,3 +3,5 @@ export * from './plugins/functional.js'
|
||||||
export * from './plugins/types.js'
|
export * from './plugins/types.js'
|
||||||
export * from './plugins/common.js'
|
export * from './plugins/common.js'
|
||||||
export * from './icqq.js'
|
export * from './icqq.js'
|
||||||
|
export * from './events.js'
|
||||||
|
export * from './bot.js'
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { segment as se } from 'icqq'
|
import { segment as se } from 'icqq'
|
||||||
import { RedisClientType } from 'redis'
|
import { RedisClientType } from 'redis'
|
||||||
import { Yunzai } from './bot.js'
|
import { Client, plugin as p } from './core/index.js'
|
||||||
import { plugin as p } from './core/index.js'
|
|
||||||
import chalk, { type ChalkInstance } from 'chalk'
|
import chalk, { type ChalkInstance } from 'chalk'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +60,7 @@ declare global {
|
||||||
*
|
*
|
||||||
* @deprecated 不推荐使用,未来将废弃
|
* @deprecated 不推荐使用,未来将废弃
|
||||||
*/
|
*/
|
||||||
var Bot: typeof Yunzai.prototype
|
var Bot: typeof Client.prototype
|
||||||
/**
|
/**
|
||||||
* @deprecated 不推荐使用,未来将废弃
|
* @deprecated 不推荐使用,未来将废弃
|
||||||
*/
|
*/
|
||||||
|
|
18
src/main.ts
18
src/main.ts
|
@ -1,2 +1,16 @@
|
||||||
import { Yunzai } from './bot.js'
|
/**
|
||||||
await Yunzai.run()
|
*
|
||||||
|
*/
|
||||||
|
import { plugin, segment, Client } from './core/index.js'
|
||||||
|
/**
|
||||||
|
* global.plugin
|
||||||
|
*/
|
||||||
|
global.plugin = plugin
|
||||||
|
/**
|
||||||
|
* global.segment
|
||||||
|
*/
|
||||||
|
global.segment = segment
|
||||||
|
/**
|
||||||
|
* run
|
||||||
|
*/
|
||||||
|
await Client.run()
|
||||||
|
|
Loading…
Reference in New Issue