Skip to content

Commit 7a44f2d

Browse files
mia-pi-gitQuanyails
authored andcommitted
Helptickets: Automatically save replays linked in tickets (smogon#8120)
1 parent f34af4a commit 7a44f2d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

server/chat-plugins/helptickets.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,16 @@ export class HelpTicket extends Rooms.RoomGame {
352352
// @ts-ignore
353353
this.playerTable = null;
354354
}
355+
onChatMessage(message: string, user: User) {
356+
const roomids = message.match(/battle-(?:[a-z0-9]+)-(?:[0-9]+)(?:-[a-z0-9]+pw)?/g);
357+
if (roomids) {
358+
for (const roomid of roomids) {
359+
const curRoom = Rooms.get(roomid);
360+
if (!curRoom || !('uploadReplay' in curRoom) || curRoom?.battle?.replaySaved) continue;
361+
void curRoom.uploadReplay(user, user.connections[0], 'forpunishment');
362+
}
363+
}
364+
}
355365
static ban(user: User | ID, reason = '') {
356366
const userid = toID(user);
357367
const userObj = Users.get(user);

0 commit comments

Comments
 (0)