diff --git a/plugins/global_chat/control.js b/plugins/global_chat/control.js new file mode 100644 index 00000000..acba4340 --- /dev/null +++ b/plugins/global_chat/control.js @@ -0,0 +1,28 @@ +"use strict"; +const plugin = require("lib/plugin"); +const info = require("./info"); +const command = require("lib/command"); + + +const globalChatCommands = new command.CommandTree({ name: "global-chat", description: "Global Chat plugin commands" }); +globalChatCommands.add(new command.Command({ + definition: ["shout ", "Send message to all instances", (yargs) => { + yargs.positional("message", { describe: "message to send", type: "string" }); + }], + handler: async function(args, control) { + await info.messages.chat.send(control, { + instance_name: "Console", + content: args.message, + }); + }, +})); + +class ControlPlugin extends plugin.BaseControlPlugin { + async addCommands(rootCommand) { + rootCommand.add(globalChatCommands); + } +} + +module.exports = { + ControlPlugin, +}; diff --git a/plugins/global_chat/info.js b/plugins/global_chat/info.js index 69764974..7231ce8d 100644 --- a/plugins/global_chat/info.js +++ b/plugins/global_chat/info.js @@ -8,11 +8,12 @@ module.exports = { description: "Forwards chat between instances.", version: "2.0.0-alpha", instanceEntrypoint: "instance", + controlEntrypoint: "control", messages: { chat: new link.Event({ type: "global_chat:chat", - links: ["instance-slave", "slave-master", "master-slave", "slave-instance"], + links: ["instance-slave", "slave-master", "master-slave", "slave-instance", "control-master"], forwardTo: "master", broadcastTo: "instance", eventProperties: {