File size: 1,274 Bytes
af5a34b
481eba0
af5a34b
481eba0
af5a34b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
481eba0
 
 
 
af5a34b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
export class botOperate extends plugin {
  constructor() {
    super({
      name: "botOperate",
      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(":"),
      reply: msg => this.reply(msg, true),
    }
    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)
    }
  }
}