1 Star 0 Fork 25

萝一生/Yenai-Plugin

forked from 椰羊/Yenai-Plugin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.js 1.41 KB
一键复制 编辑 原始数据 按行查看 历史
椰羊 提交于 2023-04-28 16:29 . ⚗️ 增加设置机型函数
import Ver from './components/Version.js'
import chalk from 'chalk'
import Data from './components/Data.js'
import fs from 'fs'
logger.info(chalk.rgb(253, 235, 255)('----ヾ( ̄▽ ̄)Bye~Bye~----'))
logger.info(chalk.rgb(134, 142, 204)(`椰奶插件${Ver.ver}初始化~`))
logger.info(chalk.rgb(253, 235, 255)('-------------------------'))
if (!global.segment) {
try {
global.segment = (await import('oicq')).segment
} catch (err) {
global.segment = (await import('icqq')).segment
}
}
// 加载监听事件
const eventsPath = './plugins/yenai-plugin/apps/events'
const events = fs.readdirSync(eventsPath)
.filter(file => file.endsWith('.js'))
for (const File of events) {
try {
logger.debug(`[Yenai-Plugin] 加载监听事件:${File}`)
await import(`./apps/events/${File}`)
} catch (e) {
logger.error(`[Yenai-Plugin] 监听事件错误:${File}`)
logger.error(e)
}
}
const appsPath = './plugins/yenai-plugin/apps'
const jsFiles = Data.readDirRecursive(appsPath, 'js', 'events')
let ret = jsFiles.map(file => {
return import(`./apps/${file}`)
})
ret = await Promise.allSettled(ret)
let apps = {}
for (let i in jsFiles) {
let name = jsFiles[i].replace('.js', '')
if (ret[i].status != 'fulfilled') {
logger.error(`载入插件错误:${logger.red(name)}`)
logger.error(ret[i].reason)
continue
}
apps[name] = ret[i].value[Object.keys(ret[i].value)[0]]
}
export { apps }
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/luoyisheng/yenai-plugin.git
[email protected]:luoyisheng/yenai-plugin.git
luoyisheng
yenai-plugin
Yenai-Plugin
master

搜索帮助