Skip to content

Commit 8f0cde3

Browse files
committed
games: Support closepage on single-player games
1 parent 73ffcd3 commit 8f0cde3

5 files changed

Lines changed: 2 additions & 14 deletions

File tree

src/ps/handlers/interface.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ export function interfaceHandler(message: PSMessage) {
1212
// Handle page requests
1313
if (message.content.startsWith('|requestpage|')) return; // currently nothing; might do stuff with this later
1414
if (message.content.startsWith('|closepage|')) {
15-
// |closepage|TheJ3estPenguin|test
1615
const match = message.content.match(/^\|closepage\|(?<user>.*?)\|(?<pageId>\w+)$/);
1716
if (!match) return message.reply('...hmm hmm hmmmmmmmm very sus');
1817
if (toId(match.groups!.user) !== message.author.id) return message.reply('Wow I see how it is');
1918
const pageId = match.groups!.pageId;
2019
const gameId = `#${pageId.toUpperCase()}`;
20+
const singlePlayerGameId = `#${pageId.slice(0, 2)}-${pageId.slice(2)}`;
2121

2222
// Check if there's any relevant games
2323
const game = Object.values(PSGames)
2424
.flatMap(gamesList => Object.values(gamesList))
25-
.find(checkGame => checkGame.id === gameId);
25+
.find(checkGame => checkGame.id === gameId || checkGame.id === singlePlayerGameId);
2626
if (!game) return; // Don't put any errors here! People should be able to close games that don't exist, like ones that ended
2727

2828
const user = message.author.id;

src/ps/handlers/page.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/ps/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ if (IS_ENABLED.PS) loadPS().then(() => PS.connect());
1616
PS.on('message', registerEvent(PS, 'commandHandler'));
1717
PS.on('message', registerEvent(PS, 'interfaceHandler'));
1818
PS.on('message', registerEvent(PS, 'autoResHandler'));
19-
PS.on('message', registerEvent(PS, 'pageHandler'));
2019

2120
PS.on('join', registerEvent(PS, 'joinHandler'));
2221
PS.on('name', registerEvent(PS, 'nickHandler'));

src/sentinel/live.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { spoof } from '@/ps/handlers/commands/spoof';
99
import { interfaceHandler } from '@/ps/handlers/interface';
1010
import { joinHandler, leaveHandler, nickHandler } from '@/ps/handlers/joins';
1111
import { notifyHandler } from '@/ps/handlers/notifications';
12-
import { pageHandler } from '@/ps/handlers/page';
1312
import { rawHandler } from '@/ps/handlers/raw';
1413
import { tourHandler } from '@/ps/handlers/tours';
1514

@@ -34,7 +33,6 @@ export const LivePSHandlers = {
3433
leaveHandler,
3534
nickHandler,
3635
notifyHandler,
37-
pageHandler,
3836
rawHandler,
3937
tourHandler,
4038
};

src/sentinel/registers/ps.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const PS_EVENT_HANDLERS = {
1313
'autores-handler': { imports: ['autoResHandler'], importPath: '@/ps/handlers/autores', fileName: 'autores' },
1414
'interface-handler': { imports: ['interfaceHandler'], importPath: '@/ps/handlers/interface', fileName: 'interface' },
1515
'joins-handler': { imports: ['joinHandler', 'leaveHandler', 'nickHandler'], importPath: '@/ps/handlers/joins', fileName: 'joins' },
16-
'page-handler': { imports: ['pageHandler'], importPath: '@/ps/handlers/page', fileName: 'page' },
1716
'raw-handler': { imports: ['rawHandler'], importPath: '@/ps/handlers/raw', fileName: 'raw' },
1817
'notify-handler': { imports: ['notifyHandler'], importPath: '@/ps/handlers/notifications', fileName: 'notifications' },
1918
'tour-handler': { imports: ['tourHandler'], importPath: '@/ps/handlers/tours', fileName: 'tours' },

0 commit comments

Comments
 (0)