.
This commit is contained in:
1 parent
673ee3d80a
commit
bd3cd4fa5f
9 files changed
+332
-3
No files matched your search
@@ -14,6 +14,10 @@ export type DakaoCommand =
|
||||
gameName: string;
|
||||
tagLine: string;
|
||||
positions: ParsedPositions;
|
||||
}
|
||||
| {
|
||||
kind: 'match-cancel';
|
||||
matchId: string;
|
||||
};
|
||||
|
||||
export class CommandParseError extends Error {
|
||||
@@ -54,6 +58,9 @@ export function parseCommand(rawMessage: string): DakaoCommand {
|
||||
return { kind: 'match-list' };
|
||||
case '신청':
|
||||
return parseJoinArgs(args);
|
||||
case '취소':
|
||||
case '참가취소':
|
||||
return parseCancelArgs(args);
|
||||
case '계정등록':
|
||||
return parseAccountRegisterArgs(args);
|
||||
default:
|
||||
@@ -84,6 +91,21 @@ function parseAccountRegisterArgs(args: string): DakaoCommand {
|
||||
};
|
||||
}
|
||||
|
||||
function parseCancelArgs(args: string): DakaoCommand {
|
||||
const matchId = args.trim();
|
||||
if (matchId.length === 0) {
|
||||
throw new CommandParseError('usage');
|
||||
}
|
||||
if (!isObjectIdHex(matchId)) {
|
||||
throw new CommandParseError('invalid_match_id', matchId);
|
||||
}
|
||||
|
||||
return {
|
||||
kind: 'match-cancel',
|
||||
matchId,
|
||||
};
|
||||
}
|
||||
|
||||
function parseJoinArgs(args: string): DakaoCommand {
|
||||
if (args.length === 0) {
|
||||
throw new CommandParseError('usage');
|
||||
|
||||
Reference in new issue
Block a user