Websockets for listening to factorio logs and global chat plugin

You can now !shout things across the cluster
This commit is contained in:
Danielv123 committed 2018-04-26 18:33:29 +02:00
1 parent 641f980741
commit ce0deef83b
5 files changed
+54 -1

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
/*
Clusterio plugin to allow for chat between instances.
*/
module.exports = {
// Name of package. For display somewhere I guess.
name: "globalChat",
version: "1.0.0",
binary: "nodePackage",
description: "Clusterio plugin to allow for chat between instances.",
}
+24
View File
@@ -0,0 +1,24 @@
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 chatMessage = "["+data.instanceID+"]"+ data.data.trim().split(" ").shift().shift().shift().join(" ");
this.messageInterface("/c game.print('"+chatMessage+"')");
}
}
});
}
factorioOutput(data){
// console.log("GOT CHAT!"+data)
this.socket.emit("gameChat", {
instanceID: this.config.unique.toString(),
data,
});
}
}