This commit is contained in:
dahyeon committed 2026-04-27 19:56:10 -07:00
1 parent 1fd37f992b
commit 4475a2d86b
7 files changed
+262 -34

No files matched your search

@@ -3,6 +3,11 @@ import { normalizeRiotIdPart } from '../riot-id.util';
export type DakaoCommand =
| { kind: 'match-list' }
| {
kind: 'account-register';
gameName: string;
tagLine: string;
}
| {
kind: 'match-join';
matchId: string;
@@ -49,11 +54,36 @@ export function parseCommand(rawMessage: string): DakaoCommand {
return { kind: 'match-list' };
case '신청':
return parseJoinArgs(args);
case '계정등록':
return parseAccountRegisterArgs(args);
default:
throw new CommandParseError('unknown_command', subCommand);
}
}
function parseAccountRegisterArgs(args: string): DakaoCommand {
if (args.length === 0) {
throw new CommandParseError('usage');
}
const hashIndex = args.lastIndexOf('#');
if (hashIndex <= 0 || hashIndex === args.length - 1) {
throw new CommandParseError('invalid_riot_id', args);
}
const gameName = normalizeRiotIdPart(args.slice(0, hashIndex));
const tagLine = normalizeRiotIdPart(args.slice(hashIndex + 1));
if (gameName.length === 0 || tagLine.length === 0) {
throw new CommandParseError('invalid_riot_id', args);
}
return {
kind: 'account-register',
gameName,
tagLine,
};
}
function parseJoinArgs(args: string): DakaoCommand {
if (args.length === 0) {
throw new CommandParseError('usage');