mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
It makes more sense to put the address first then have the large structure to send as the second argument to sendTo. The opposite order was originally chosen to be similar to that of sendto in BSD sockets.
28 lines
812 B
JavaScript
28 lines
812 B
JavaScript
"use strict";
|
|
const libPlugin = require("@clusterio/lib/plugin");
|
|
const { ChatEvent } = require("./messages");
|
|
const libCommand = require("@clusterio/lib/command");
|
|
|
|
|
|
const globalChatCommands = new libCommand.CommandTree({
|
|
name: "global-chat", description: "Global Chat plugin commands",
|
|
});
|
|
globalChatCommands.add(new libCommand.Command({
|
|
definition: ["shout <message>", "Send message to all instances", (yargs) => {
|
|
yargs.positional("message", { describe: "message to send", type: "string" });
|
|
}],
|
|
handler: async function(args, control) {
|
|
await control.sendTo("allInstances", new ChatEvent("Console", args.message));
|
|
},
|
|
}));
|
|
|
|
class ControlPlugin extends libPlugin.BaseControlPlugin {
|
|
async addCommands(rootCommand) {
|
|
rootCommand.add(globalChatCommands);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
ControlPlugin,
|
|
};
|