diff --git a/lib/index.js b/lib/index.js index bc66301..94d9ff0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -121,6 +121,8 @@ bot.once("spawn", () => { cfg.plugins = plugins cfg.botAddressRegex = new RegExp(`^${bot.username} (${cfg.botAddressPrefix}.+)`) + // FIXME leaks every load, so adding here instead of command.js to load only once + bot.addChatPattern("web", /\[WEB\] (\[.+\])?\s*([\w.]+): (.+)/, { parse: true }) for (const plugin of Object.values(plugins)) { try { diff --git a/lib/plugins/command.js b/lib/plugins/command.js index 770e081..111c2e1 100644 --- a/lib/plugins/command.js +++ b/lib/plugins/command.js @@ -57,6 +57,7 @@ const events = { } } , message: systemMessage + , "chat:web": commandWeb } function systemMessage(...args) { @@ -71,6 +72,11 @@ function systemMessage(...args) { ) } +function commandWeb([[mode, username, message]]) { + console.log("web msg:", mode, username, message) + message && command(username, message) +} + function _clientSystemMessage(...args) { console.log("cmd msg:", args[0]?.message, args[0]?.extra?.length, args[0]?.extra, args[0], args.slice(1)) }