Miao-Yunzai/lib/bot.js

40 lines
940 B
JavaScript
Raw Normal View History

2023-03-04 14:30:13 +08:00
import './config/init.js'
import ListenerLoader from './listener/loader.js'
import { Client } from 'icqq'
2023-03-04 14:30:13 +08:00
import cfg from './config/config.js'
export default class Yunzai extends Client {
// eslint-disable-next-line no-useless-constructor
2023-03-11 09:35:53 +08:00
constructor (conf) {
super(conf)
2023-03-04 14:30:13 +08:00
}
/** 登录机器人 */
static async run () {
const bot = new Yunzai(cfg.bot)
/** 加载监听事件 */
2023-03-04 14:30:13 +08:00
await ListenerLoader.load(bot)
2023-11-02 23:30:52 +08:00
/** 跳过登录 */
if (cfg.bot.skip_login) return await this.skip_login(bot)
/** 正常的登录 */
await bot.login(cfg.qq, cfg.pwd)
bot[bot.uin] = bot
/** 全局变量 bot */
global.Bot = bot
return bot
}
/** 跳过登录ICQQ */
static async skip_login (bot) {
bot.uin = 88888
bot[bot.uin] = bot
/** 全局变量 bot */
global.Bot = bot
/** 加载插件 */
return await ((await import('../lib/plugins/loader.js')).default).load()
2023-03-04 14:30:13 +08:00
}
}