Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use serverless for AWS deploys #12

Open
wants to merge 1 commit into
base: aws-lambda
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/18xx_message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ test('parses message', () => {
});
});

test('parses 18ZOO message', () => {
const message = new Parsed18xxMessage({
text: '<@Hello> Your Turn in 18ZOO - Map A "test zoo" (SR-day 1)\nhttp://18xx.games/game/59585',
});

expect(message.valid).toBeTruthy();
});

test('formats message text back to original', () => {
const message = new Parsed18xxMessage(JSON.parse(event));

Expand Down
4 changes: 2 additions & 2 deletions src/lib/18xx_message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ interface Incoming18xxMessage {
}

const MESSAGE_PATTERN =
/<@(?<userId>.*)> (?<text>.+) in (?<title>\w+) "(?<description>.*)" \((?<round>.*) (?<turn>\d+)\)\n(?<link>.*)/;
/<@(?<userId>.*)> (?<text>.+) in (?<title>.+) "(?<description>.*)" \((?<round>.*) (?<turn>\d+)\)\n(?<link>.*)/;

/**
* Extracts and stores meaningful data from 18xx.games turn notification
Expand Down Expand Up @@ -54,5 +54,5 @@ export class Parsed18xxMessage {
}

function isValidMessage(message: any): message is Incoming18xxMessage {
return typeof message === 'object' && 'text' in message;
return message && typeof message === 'object' && 'text' in message;
}