Files
yenai-plugin/apps/state.js
2024-04-04 13:10:08 +08:00

58 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import plugin from "../../../lib/plugins/plugin.js"
import { Config } from "../components/index.js"
import { puppeteer } from "../model/index.js"
import { getData, si } from "../model/State/index.js"
import Monitor from "../model/State/Monitor.js"
let interval = false
export class NewState extends plugin {
constructor () {
super({
name: "椰奶状态",
event: "message",
priority: 50,
rule: [
{
reg: "^#?(椰奶)?状态(pro)?$",
fnc: "state"
}, {
reg: "^#椰奶监控$",
fnc: "monitor"
}
]
})
}
async monitor (e) {
await puppeteer.render("state/monitor", {
chartData: JSON.stringify(Monitor.chartData)
}, {
e,
scale: 1.4
})
}
async state (e) {
if (!/椰奶/.test(e.msg) && !Config.whole.state) return false
if (!si) return e.reply("❎ 没有检测到systeminformation依赖请运行\"pnpm add systeminformation -w\"进行安装")
// 防止多次触发
if (interval) { return false } else interval = true
// 获取数据
let data = await getData(e)
// 渲染图片
await puppeteer.render("state/state", {
...data
}, {
e,
scale: 1.4
})
interval = false
}
}