52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
import plugin from '../../../lib/plugins/plugin.js'
|
|
import { segment } from 'oicq'
|
|
import cfg from '../../../lib/config/config.js'
|
|
import common from '../../../lib/common/common.js'
|
|
|
|
class Config {
|
|
|
|
/** 读取文件 */
|
|
async getread(path) {
|
|
return await fs.promises
|
|
.readFile(path, 'utf8')
|
|
.then((data) => {
|
|
return JSON.parse(data)
|
|
})
|
|
.catch((err) => {
|
|
logger.error('读取失败')
|
|
console.error(err)
|
|
return false
|
|
})
|
|
}
|
|
|
|
/** 写入文件 */
|
|
async getwrite(path, cot) {
|
|
return await fs.promises
|
|
.writeFile(path, JSON.stringify(cot, '', '\t'))
|
|
.then(() => {
|
|
return true
|
|
})
|
|
.catch((err) => {
|
|
logger.error('写入失败')
|
|
console.error(err)
|
|
return false
|
|
})
|
|
}
|
|
|
|
/** 发消息 */
|
|
async getSend(msg) {
|
|
if (await redis.del(`yenai:notice:notificationsAll`,)) {
|
|
// 发送全部管理
|
|
for (let index of cfg.masterQQ) {
|
|
await common.relpyPrivate(index, msg)
|
|
}
|
|
} else {
|
|
// 发给第一个管理
|
|
await common.relpyPrivate(cfg.masterQQ[0], msg)
|
|
await common.sleep(200)
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
export default new Config(); |