Remove redundant API call in globalChat

Remove call to getInstanceName which in turn calls the rather expensive
/api/slaves in the globalChat plugin.
This commit is contained in:
Hornwitser committed 2019-11-20 22:37:25 +01:00
1 parent f3171c2feb
commit 2f3b4c1aa8
2 files changed
+3 -5

No files matched your search

+1
View File
@@ -44,6 +44,7 @@ Version 2.0.0
- Removed undocumented --port and --rcon-port arguments to client.
- Removed undocumented FACTORIOPORT and RCONPORT enviroment variable
handling in client.
- Removed redundant call to /api/slaves in globalChat plugin.
### Breaking Changes
+2 -5
View File
@@ -1,12 +1,9 @@
const needle = require("needle");
module.exports = class remoteCommands {
constructor(mergedConfig, messageInterface, extras){
this.messageInterface = messageInterface;
this.config = mergedConfig;
this.socket = extras.socket;
this.instances = {};
this.getInstanceName = require("lib/clusterTools/getInstanceName")(mergedConfig);
this.socket.on("hello", () => this.socket.emit("registerChatReciever"));
@@ -25,11 +22,10 @@ module.exports = class remoteCommands {
words.shift();
let message = words.join(" ").replace(/[";]/g, " ").replace(/[']/g,"").replace("/shout ", "").replace("!shout ","").replace(/\[gps=.*?\]/g, "").replace(/\[train=.*?\]/g, "");
let instance = await this.getInstanceName(data.instanceID);
if(data.data.includes("[gps=")){
//Nothing
}else{
this.messageInterface("/silent-command game.print('[" + instance + "] " + message + "')");
this.messageInterface("/silent-command game.print('[" + data.instanceName + "] " + message + "')");
}
}
}
@@ -39,6 +35,7 @@ module.exports = class remoteCommands {
try{
this.socket.emit("gameChat", {
instanceID: this.config.unique.toString(),
instanceName: this.config.name,
data,
});
if(data.includes("[CHAT]") && data.includes("!info")){