mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
30 lines
965 B
JavaScript
30 lines
965 B
JavaScript
module.exports = class remoteCommands {
|
|
constructor(mergedConfig, messageInterface, extras){
|
|
this.messageInterface = messageInterface;
|
|
this.config = mergedConfig;
|
|
this.socket = extras.socket;
|
|
|
|
this.socket.emit("registerChatReciever");
|
|
this.socket.on("gameChat", data => {
|
|
if(data.instanceID && data.instanceID != this.config.unique.toString()){
|
|
if(data.data.includes("[CHAT]") && data.data.toLowerCase().includes("!shout")){
|
|
let message = data.data.trim().split(" ");
|
|
message.shift();
|
|
message.shift();
|
|
message.shift();
|
|
let chatMessage = "["+data.instanceID+"]"+ message.join(" ");
|
|
chatMessage = chatMessage.replace(/[^a-zA-Z0-9]+/g, " ");
|
|
this.messageInterface("/silent-command game.print('"+chatMessage.replace("!shout ","")+"')");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
factorioOutput(data){
|
|
// console.log("GOT CHAT!"+data)
|
|
this.socket.emit("gameChat", {
|
|
instanceID: this.config.unique.toString(),
|
|
data,
|
|
});
|
|
}
|
|
}
|