细节优化
This commit is contained in:
parent
cdc5d46dbe
commit
625d7ec88e
|
@ -37,7 +37,7 @@
|
||||||
"sequelize": "^6.32.1",
|
"sequelize": "^6.32.1",
|
||||||
"sqlite3": "^5.1.6",
|
"sqlite3": "^5.1.6",
|
||||||
"ws": "^8.13.0",
|
"ws": "^8.13.0",
|
||||||
"yaml": "^2.3.1"
|
"yaml": "^2.3.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.48.0",
|
"eslint": "^8.48.0",
|
||||||
|
|
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue