Skip to content

Commit

Permalink
Fix message parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
creekorful committed Mar 23, 2021
1 parent 6169694 commit 075be3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions parakeet.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func parseLog(name string, reader io.Reader) (Channel, error) {

line = strings.TrimSuffix(line, "\n")

// Only keep 'message' line i.e which contains something like '<username>'
if !strings.Contains(line, "<") || !strings.Contains(line, ">") {
// Only keep 'message' line i.e which contains something like '] <username>'
if !strings.Contains(line, "] <") || !strings.Contains(line, ">") {
continue
}

Expand Down
2 changes: 2 additions & 0 deletions parakeet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const file = `
[2021-03-01T13:59:00.732Z] <hentiphase> creekorful: https://example.org/manual :)
[2021-03-01T20:38:26.113Z] *** creekorful ([email protected]) quit ()
[2021-03-01T21:24:49.669Z] *** hentiphase ([email protected]) quit (Remote host closed the connection)
[2021-03-23T10:29:59.215Z] *** creekorful ([email protected]) joined
[2021-03-23T10:46:21.525Z] * creekorful sent a long message: < something >
`

func TestParseLog(t *testing.T) {
Expand Down

0 comments on commit 075be3f

Please sign in to comment.