mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-04-26 02:39:38 -05:00
Modlog: properly spawn processes (#3672)
This commit is contained in:
parent
5ab919d858
commit
bf85c96ac4
|
|
@ -72,6 +72,19 @@ const PM = exports.PM = new ModlogManager({
|
|||
isChatBased: true,
|
||||
});
|
||||
|
||||
if (!process.send) {
|
||||
PM.spawn();
|
||||
}
|
||||
|
||||
if (process.send && module === process.mainModule) {
|
||||
global.Config = require('../config/config');
|
||||
global.Dex = require('../sim/dex');
|
||||
global.toId = Dex.getId;
|
||||
process.on('message', message => PM.onMessageDownstream(message));
|
||||
process.on('disconnect', () => process.exit());
|
||||
require('../repl').start('modlog', cmd => eval(cmd));
|
||||
}
|
||||
|
||||
class SortedLimitedLengthList {
|
||||
constructor(maxSize) {
|
||||
this.maxSize = maxSize;
|
||||
|
|
@ -304,8 +317,10 @@ exports.commands = {
|
|||
searchString = searchString.substring(1, searchString.length - 1);
|
||||
}
|
||||
|
||||
PM.send(roomId, searchString, exactSearch, lines).then(response => connection.popup(prettifyResults(response, roomId, searchString, exactSearch, addModlogLinks, hideIps)));
|
||||
if (cmd === 'timedmodlog') this.sendReply(`The modlog query took ${Date.now() - startTime} ms to complete.`);
|
||||
PM.send(roomId, searchString, exactSearch, lines).then(response => {
|
||||
connection.popup(prettifyResults(response, roomId, searchString, exactSearch, addModlogLinks, hideIps));
|
||||
if (cmd === 'timedmodlog') this.sendReply(`The modlog query took ${Date.now() - startTime} ms to complete.`);
|
||||
});
|
||||
},
|
||||
modloghelp: ["/modlog [roomid|all|public], [n] - Roomid defaults to current room.",
|
||||
"If n is a number or omitted, display the last n lines of the moderator log. Defaults to 20.",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user