From 625d7ec88e649521eff18fb2291a36bfeee86a35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8C=8C?= Date: Tue, 29 Aug 2023 16:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- plugins/system/botOperate.js | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 plugins/system/botOperate.js diff --git a/package.json b/package.json index c38c6ca..18693e6 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "sequelize": "^6.32.1", "sqlite3": "^5.1.6", "ws": "^8.13.0", - "yaml": "^2.3.1" + "yaml": "^2.3.2" }, "devDependencies": { "eslint": "^8.48.0", diff --git a/plugins/system/botOperate.js b/plugins/system/botOperate.js new file mode 100644 index 0000000..acceaab --- /dev/null +++ b/plugins/system/botOperate.js @@ -0,0 +1,45 @@ +export class botOperate extends plugin { + constructor () { + super({ + name: "Bot 操作", + dsc: "Bot 操作", + event: "message", + rule: [ + { + reg: "^#(Bot|机器人)验证.+:.+$", + fnc: "Verify", + permission: "master", + }, + { + reg: "^#(Bot|机器人)(上|下)线.+$", + fnc: "Operate", + permission: "master", + } + ] + }) + } + + Verify() { + const data = { msg: this.e.msg.replace(/^#(Bot|机器人)验证/, "").trim().split(":") } + data.self_id = data.msg.shift() + data.msg = data.msg.join(":") + Bot.em(`verify.${data.self_id}`, data) + } + + Operate() { + const bot = Bot[this.e.msg.replace(/^#(Bot|机器人)(上|下)线/, "").trim()] + if (typeof bot != "object") { + this.reply("Bot 不存在", true) + return false + } + if (this.e.msg.includes("上线") && typeof bot.login == "function") { + this.reply("已发送上线操作", true) + bot.login() + } else if (this.e.msg.includes("下线") && typeof bot.logout == "function") { + this.reply("已发送下线操作", true) + bot.logout() + } else { + this.reply("暂不支持此操作", true) + } + } +} \ No newline at end of file