Skip to content

Commit ce9d0e0

Browse files
committed
Wifi: Kick users from giveaways upon punishment
1 parent d29a90f commit ce9d0e0

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

server/chat-commands/moderation.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,7 @@ export const commands: Chat.ChatCommands = {
707707
this.privateModAction(displayMessage);
708708
}
709709

710+
Chat.runHandlers('onPunishUser', 'MUTE', user, room);
710711
room.mute(targetUser, muteDuration);
711712
},
712713
mutehelp: [`/mute OR /m [username], [reason] - Mutes a user with reason for 7 minutes. Requires: % @ # &`],
@@ -803,6 +804,7 @@ export const commands: Chat.ChatCommands = {
803804
const time = week ? Date.now() + 7 * 24 * 60 * 60 * 1000 : null;
804805
const affected = Punishments.roomBan(room, targetUser, time, null, privateReason);
805806

807+
for (const u of affected) Chat.runHandlers('onPunishUser', 'ROOMBAN', u, room);
806808
if (!room.settings.isPrivate && room.persist) {
807809
const acAccount = (targetUser.autoconfirmed !== userid && targetUser.autoconfirmed);
808810
let displayMessage = '';
@@ -923,6 +925,7 @@ export const commands: Chat.ChatCommands = {
923925
affected = await Punishments.lock(userid, duration, null, false, publicReason);
924926
}
925927

928+
for (const u of affected) Chat.runHandlers('onPunishUser', 'LOCK', u, room);
926929
this.globalModlog(
927930
(force ? `FORCE` : ``) + (week ? "WEEKLOCK" : (month ? "MONTHLOCK" : "LOCK")), targetUser || userid, privateReason
928931
);
@@ -1127,6 +1130,7 @@ export const commands: Chat.ChatCommands = {
11271130
this.addGlobalModAction(`${name} was globally banned by ${user.name}.${(publicReason ? ` (${publicReason})` : ``)}`);
11281131

11291132
const affected = await Punishments.ban(userid, null, null, false, publicReason);
1133+
for (const u of affected) Chat.runHandlers('onPunishUser', 'BAN', u, room);
11301134
const acAccount = (targetUser && targetUser.autoconfirmed !== userid && targetUser.autoconfirmed);
11311135
let displayMessage = '';
11321136
if (affected.length > 1) {
@@ -1969,6 +1973,7 @@ export const commands: Chat.ChatCommands = {
19691973
}
19701974
const duration = week ? 7 * 24 * 60 * 60 * 1000 : 48 * 60 * 60 * 1000;
19711975
await Punishments.namelock(userid, Date.now() + duration, null, false, publicReason);
1976+
if (targetUser) Chat.runHandlers('onPunishUser', 'NAMELOCK', targetUser, room);
19721977
// Automatically upload replays as evidence/reference to the punishment
19731978
if (room?.battle) this.parse('/savereplay forpunishment');
19741979
Monitor.forceRenames.set(userid, false);
@@ -2158,6 +2163,7 @@ export const commands: Chat.ChatCommands = {
21582163

21592164
const affected = Punishments.roomBlacklist(room, targetUser, expireTime, null, reason);
21602165

2166+
for (const u of affected) Chat.runHandlers('onPunishUser', 'BLACKLIST', u, room);
21612167
if (!room.settings.isPrivate && room.persist) {
21622168
const acAccount = (targetUser.autoconfirmed !== userid && targetUser.autoconfirmed);
21632169
let displayMessage = '';

server/chat-plugins/wifi.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,12 @@ export const handlers: Chat.Handlers = {
920920
saveData();
921921
}
922922
},
923+
onPunishUser(type, user, room) {
924+
const game = room?.getGame(LotteryGiveaway) || room?.getGame(QuestionGiveaway);
925+
if (game) {
926+
game.kickUser(user);
927+
}
928+
},
923929
};
924930

925931
export const commands: Chat.ChatCommands = {

server/chat.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ interface Handlers {
8888
onChallenge: (user: User, targetUser: User, format: string | ID) => void;
8989
onMessageOffline: (context: Chat.CommandContext, message: string, targetUserID: ID) => void;
9090
onBattleJoin: (slot: string, user: User, battle: RoomBattle) => void;
91+
onPunishUser: (type: string, user: User, room?: Room | null) => void;
9192
}
9293

9394
export interface ChatPlugin {

0 commit comments

Comments
 (0)