mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 00:13:12 +09:00
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:
1 parent
f3171c2feb
commit
2f3b4c1aa8
2 files changed
+3
-5
No files matched your search
@@ -44,6 +44,7 @@ Version 2.0.0
|
|||||||
- Removed undocumented --port and --rcon-port arguments to client.
|
- Removed undocumented --port and --rcon-port arguments to client.
|
||||||
- Removed undocumented FACTORIOPORT and RCONPORT enviroment variable
|
- Removed undocumented FACTORIOPORT and RCONPORT enviroment variable
|
||||||
handling in client.
|
handling in client.
|
||||||
|
- Removed redundant call to /api/slaves in globalChat plugin.
|
||||||
|
|
||||||
### Breaking Changes
|
### Breaking Changes
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
const needle = require("needle");
|
|
||||||
|
|
||||||
module.exports = class remoteCommands {
|
module.exports = class remoteCommands {
|
||||||
constructor(mergedConfig, messageInterface, extras){
|
constructor(mergedConfig, messageInterface, extras){
|
||||||
this.messageInterface = messageInterface;
|
this.messageInterface = messageInterface;
|
||||||
this.config = mergedConfig;
|
this.config = mergedConfig;
|
||||||
this.socket = extras.socket;
|
this.socket = extras.socket;
|
||||||
this.instances = {};
|
this.instances = {};
|
||||||
this.getInstanceName = require("lib/clusterTools/getInstanceName")(mergedConfig);
|
|
||||||
|
|
||||||
this.socket.on("hello", () => this.socket.emit("registerChatReciever"));
|
this.socket.on("hello", () => this.socket.emit("registerChatReciever"));
|
||||||
|
|
||||||
@@ -25,11 +22,10 @@ module.exports = class remoteCommands {
|
|||||||
words.shift();
|
words.shift();
|
||||||
let message = words.join(" ").replace(/[";]/g, " ").replace(/[']/g,"").replace("/shout ", "").replace("!shout ","").replace(/\[gps=.*?\]/g, "").replace(/\[train=.*?\]/g, "");
|
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=")){
|
if(data.data.includes("[gps=")){
|
||||||
//Nothing
|
//Nothing
|
||||||
}else{
|
}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{
|
try{
|
||||||
this.socket.emit("gameChat", {
|
this.socket.emit("gameChat", {
|
||||||
instanceID: this.config.unique.toString(),
|
instanceID: this.config.unique.toString(),
|
||||||
|
instanceName: this.config.name,
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
if(data.includes("[CHAT]") && data.includes("!info")){
|
if(data.includes("[CHAT]") && data.includes("!info")){
|
||||||
|
|||||||
Reference in new issue
Block a user