miao-plugin/index.js

38 lines
1.3 KiB
JavaScript
Raw Normal View History

2022-08-18 10:13:42 +00:00
import { Data, Version } from './components/index.js'
import fs from 'fs'
2022-07-23 20:32:10 +00:00
export * from './apps/index.js'
2022-09-16 21:45:10 +00:00
if (Bot?.logger?.info) {
Bot.logger.info('---------^_^---------')
2022-08-18 10:13:42 +00:00
Bot.logger.info(`喵喵插件${Version.version}初始化~`)
} else {
2022-08-18 10:13:42 +00:00
console.log(`喵喵插件${Version.version}初始化~`)
}
setTimeout(async function () {
2022-07-23 20:32:10 +00:00
let msgStr = await redis.get('miao:restart-msg')
let relpyPrivate = async function () {
}
let common = await Data.importModule(Version.isV3 ? 'lib/common/common.js' : 'lib/common.js', 'root')
if (common && common.default && common.default.relpyPrivate) {
relpyPrivate = common.default.relpyPrivate
2022-07-24 21:11:19 +00:00
}
if (msgStr) {
2022-07-23 20:32:10 +00:00
let msg = JSON.parse(msgStr)
await relpyPrivate(msg.qq, msg.msg)
await redis.del('miao:restart-msg')
2022-08-18 10:13:42 +00:00
let msgs = [`当前喵喵版本: ${Version.version}`, '您可使用 #喵喵版本 命令查看更新信息']
2022-07-23 20:32:10 +00:00
await relpyPrivate(msg.qq, msgs.join('\n'))
}
2022-11-26 22:20:58 +00:00
if (!fs.existsSync(process.cwd() + '/lib/plugins/runtime.js')) {
let msg = '警告未检测到runtimemiao-plugin可能无法正常工作。请升级至最新版Yunzai以使用miao-plugin'
if (!await redis.get('miao:runtime-warning')) {
await relpyPrivate(msg.qq, msg)
await redis.set('miao:runtime-warning', 'true', { EX: 3600 * 24 })
} else {
console.log(msg)
}
}
2022-07-23 20:32:10 +00:00
}, 1000)