mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-16 15:30:41 +09:00
Websockets for listening to factorio logs and global chat plugin
You can now !shout things across the cluster
This commit is contained in:
1 parent
641f980741
commit
ce0deef83b
5 files changed
+54
-1
No files matched your search
@@ -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.",
|
||||
}
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user