mirror of
https://github.com/AsgardEternal/SquadJS.git
synced 2024-09-28 15:14:25 -05:00
New RCON event emit for BAN, KICK, WARN + rcon.ban method
This commit is contained in:
parent
19087e93dd
commit
10be536c7b
@ -130,6 +130,24 @@ export default class SquadServer extends EventEmitter {
|
|||||||
this.rcon.on('RCON_ERROR', (data) => {
|
this.rcon.on('RCON_ERROR', (data) => {
|
||||||
this.emit('RCON_ERROR', data);
|
this.emit('RCON_ERROR', data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.rcon.on('PLAYER_WARNED', async (data) => {
|
||||||
|
data.player = await this.getPlayerByName(data.name);
|
||||||
|
|
||||||
|
this.emit('PLAYER_WARNED', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.rcon.on('PLAYER_KICKED', async (data) => {
|
||||||
|
data.player = await this.getPlayerBySteamID(data.steamID);
|
||||||
|
|
||||||
|
this.emit('PLAYER_KICKED', data);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.rcon.on('PLAYER_BANNED', async (data) => {
|
||||||
|
data.player = await this.getPlayerBySteamID(data.steamID);
|
||||||
|
|
||||||
|
this.emit('PLAYER_BANNED', data);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async restartRCON() {
|
async restartRCON() {
|
||||||
|
@ -47,6 +47,54 @@ export default class SquadRcon extends Rcon {
|
|||||||
name: matchUnpossessedAdminCam[2],
|
name: matchUnpossessedAdminCam[2],
|
||||||
time: new Date()
|
time: new Date()
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchKick = decodedPacket.body.match(/Kicked player \d.?.\s?\[steamid=([0-9]{17})] (.*)/);
|
||||||
|
if (matchKick) {
|
||||||
|
Logger.verbose('SquadRcon', 2, `Matched kick message: ${decodedPacket.body}`);
|
||||||
|
|
||||||
|
this.emit('PLAYER_KICKED', {
|
||||||
|
raw: decodedPacket.body,
|
||||||
|
steamID: matchKick[1],
|
||||||
|
name: matchKick[2],
|
||||||
|
time: new Date()
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchWarn = decodedPacket.body.match(
|
||||||
|
/Remote admin has warned player (.*)\. Message was "(.*)"/
|
||||||
|
);
|
||||||
|
if (matchWarn) {
|
||||||
|
Logger.verbose('SquadRcon', 2, `Matched warn message: ${decodedPacket.body}`);
|
||||||
|
|
||||||
|
this.emit('PLAYER_WARNED', {
|
||||||
|
raw: decodedPacket.body,
|
||||||
|
name: matchWarn[1],
|
||||||
|
reason: matchWarn[2],
|
||||||
|
time: new Date()
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const matchBan = decodedPacket.body.match(
|
||||||
|
/Banned player (.*)\. \[steamid=(.*?)\] (.*) for interval (.*)/
|
||||||
|
);
|
||||||
|
if (matchBan) {
|
||||||
|
Logger.verbose('SquadRcon', 2, `Matched ban message: ${decodedPacket.body}`);
|
||||||
|
|
||||||
|
this.emit('PLAYER_BANNED', {
|
||||||
|
raw: decodedPacket.body,
|
||||||
|
playerID: matchBan[1],
|
||||||
|
steamID: matchBan[2],
|
||||||
|
name: matchBan[3],
|
||||||
|
interval: matchBan[4],
|
||||||
|
time: new Date()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +174,11 @@ export default class SquadRcon extends Rcon {
|
|||||||
await this.execute(`AdminWarn "${steamID}" ${message}`);
|
await this.execute(`AdminWarn "${steamID}" ${message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 0 = Perm | 1m = 1 minute | 1d = 1 Day | 1M = 1 Month | etc...
|
||||||
|
async ban(steamID, banLength, message) {
|
||||||
|
await this.execute(`AdminBan "${steamID}" ${banLength} ${message}`);
|
||||||
|
}
|
||||||
|
|
||||||
async switchTeam(steamID) {
|
async switchTeam(steamID) {
|
||||||
await this.execute(`AdminForceTeamChange "${steamID}"`);
|
await this.execute(`AdminForceTeamChange "${steamID}"`);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user