diff --git a/lib/adapter/server/server.js b/lib/adapter/server/server.js index 8e10fce7..9856552d 100644 --- a/lib/adapter/server/server.js +++ b/lib/adapter/server/server.js @@ -2,6 +2,7 @@ import express from 'express' import { createServer } from 'http' import { WebSocketServer } from 'ws' import { Cfg, logger, Bot } from '#Karin' +import loader from '../../../lib/plugins/loader.js' const app = express() export const server = createServer(app) @@ -36,6 +37,7 @@ export default async function Server () { const http_port = Cfg.Config.http_port server.listen(http_port, () => { logger.mark(`[服务器][启动成功][HTTP][http://0.0.0.0:${http_port}]`) - Bot.emit('init', '') + /** 加载插件 */ + loader.load() }) } diff --git a/lib/bot/bot.js b/lib/bot/bot.js index 6d5f80c7..42ec83be 100644 --- a/lib/bot/bot.js +++ b/lib/bot/bot.js @@ -1,6 +1,5 @@ import '../adapter/kritor/index.js' import { EventEmitter } from 'events' -import loader from '../plugins/loader.js' import logger from '../config/log.js' import message from '../event/message.js' import notice from '../event/notice.js' @@ -14,8 +13,6 @@ class Bot extends EventEmitter { this.adapter = {} /** WebSocket适配器 */ this.WebSocket = {} - /** 初始化事件 */ - this.on('init', data => this.init()) /** 错误事件 */ this.on('error', data => logger.error(data)) /** 消息事件 */ @@ -37,12 +34,6 @@ class Bot extends EventEmitter { logger.mark(`[适配器][WebSocket][注册][${data.url}]`) }) } - - /** 初始化 */ - async init () { - /** 加载插件 */ - await loader.load() - } } export default new Bot() diff --git a/lib/config/index.js b/lib/config/index.js index 57d923e5..129db37b 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -1,4 +1,3 @@ -import title from './init.js' import logger from './log.js' import redis from './redis.js' import Bot from '../bot/bot.js' @@ -7,6 +6,12 @@ import httpServer from '../adapter/server/server.js' import OneBot11 from '../adapter/onebot/OneBot11.js' import puppeteer from '../Renderer/puppeteer.js' +const title = 'Karin' +/** 设置标题 */ +process.title = title +/** 设置时区 */ +process.env.TZ = 'Asia/Shanghai' + export default class Karin { static async start () { logger.mark(`${title} 启动中...`) diff --git a/lib/config/init.js b/lib/config/init.js deleted file mode 100644 index 9627e0b4..00000000 --- a/lib/config/init.js +++ /dev/null @@ -1,14 +0,0 @@ -import fs from 'node:fs' - -const title = 'Karin' -/** 设置标题 */ -process.title = title -/** 设置时区 */ -process.env.TZ = 'Asia/Shanghai' -/** 检查node_modules */ -if (!fs.existsSync('./node_modules')) { - console.error('请先运行命令:pnpm install -P 安装依赖') - process.exit() -} - -export default title