✨ Call vnstati command
This commit is contained in:
parent
e0d339d296
commit
ead8b88f32
26
index.js
26
index.js
|
@ -1,13 +1,35 @@
|
||||||
const { KiviPlugin } = require("@kivibot/core");
|
const { KiviPlugin, segment } = require("@kivibot/core");
|
||||||
|
const { execSync } = require("child_process");
|
||||||
|
|
||||||
const plugin = new KiviPlugin("demo", "0.1.0");
|
const plugin = new KiviPlugin("demo", "0.1.0");
|
||||||
|
|
||||||
|
function vnstati() {
|
||||||
|
execSync("vnstati -L -i eth0 -s -o s.png");
|
||||||
|
execSync("vnstati -L -i eth0 -h -o h.png");
|
||||||
|
execSync("vnstati -L -i eth0 -hg -o hg.png");
|
||||||
|
}
|
||||||
|
|
||||||
plugin.onMounted(() => {
|
plugin.onMounted(() => {
|
||||||
plugin.cron("0 8 * * *", (bot, admins) => {
|
plugin.cron("0 8 * * *", (bot, admins) => {
|
||||||
|
vnstati();
|
||||||
admins.forEach((admin) => {
|
admins.forEach((admin) => {
|
||||||
bot.sendPrivateMsg(admin, "早上好!");
|
bot.sendPrivateMsg(admin, [
|
||||||
|
"昨日流量使用数据:\n",
|
||||||
|
segment.image("s.png"),
|
||||||
|
segment.image("h.png"),
|
||||||
|
segment.image("hg.png"),
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
plugin.onAdminCmd("vnstat", (event, params, options) => {
|
||||||
|
vnstati();
|
||||||
|
event.reply([
|
||||||
|
"过去24小时内流量使用数据:\n",
|
||||||
|
segment.image("s.png"),
|
||||||
|
segment.image("h.png"),
|
||||||
|
segment.image("hg.png"),
|
||||||
|
]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = { plugin };
|
module.exports = { plugin };
|
||||||
|
|
Loading…
Reference in New Issue