diff --git a/docs/PLAYER.md b/docs/PLAYER.md index e6995cc..d7216b7 100644 --- a/docs/PLAYER.md +++ b/docs/PLAYER.md @@ -53,7 +53,7 @@ Your callsign should be unique within a server. If multiple players have the sam Avoid: -* Names that contain brevity codewords, including "alpha", "radio", "comm", "bogey", "picture", "declare", "snaplock", "spiked", "bullseye". +* Names that contain or are similar to brevity codewords, including "alpha", "radio", "comm", "bogey", "picture", "declare", "snaplock", "spiked", "bullseye". For example, "Spade" can be difficult to distinguish from "SPIKE" * Names that are hard to distinguish, like "Spare"/"Spear", "Jester"/"Gesture", "Witch"/"Which". The bot will make a best effort, but may be less accurate. * Names that sound similar to numbers. For example, "Knight" sounds similar to "Nine", "Fort" sounds like "Four" * Names that aren't widely recognized words in common parlance, like "Razgriz" or "Beskar". The bot will make a best effort, but may be less accurate. diff --git a/pkg/parser/alphacheck_test.go b/pkg/parser/alphacheck_test.go new file mode 100644 index 0000000..6ab6c94 --- /dev/null +++ b/pkg/parser/alphacheck_test.go @@ -0,0 +1,56 @@ +package parser + +import ( + "testing" + + "github.com/dharmab/skyeye/pkg/brevity" + "github.com/stretchr/testify/require" +) + +func TestParserAlphaCheck(t *testing.T) { + t.Parallel() + testCases := []parserTestCase{ + { + text: "ANYFACE, HORNET 1, CHECKING IN AS FRAGGED, REQUEST ALPHA CHECK DEPOT", + expected: &brevity.AlphaCheckRequest{ + Callsign: "hornet 1", + }, + }, + { + text: "anyface intruder 11 alpha check", + expected: &brevity.AlphaCheckRequest{ + Callsign: "intruder 1 1", + }, + }, + { + text: "anyface intruder 11, checking in as fragged, request alpha check bullseye", + expected: &brevity.AlphaCheckRequest{ + Callsign: "intruder 1 1", + }, + }, + { + text: TestCallsign + "intruder 11 alpha check", + expected: &brevity.AlphaCheckRequest{ + Callsign: "intruder 1 1", + }, + }, + { + text: TestCallsign + "Gunfighter 2-1, AlphaJack, Bullseye.", + expected: &brevity.AlphaCheckRequest{ + Callsign: "gunfighter 2 1", + }, + }, + { + text: TestCallsign + " HORNET 12, ALPHACHEK", + expected: &brevity.AlphaCheckRequest{ + Callsign: "hornet 1 2", + }, + }, + } + runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { + t.Helper() + expected := test.expected.(*brevity.AlphaCheckRequest) + actual := request.(*brevity.AlphaCheckRequest) + require.Equal(t, expected.Callsign, actual.Callsign) + }) +} diff --git a/pkg/parser/bogeydope_test.go b/pkg/parser/bogeydope_test.go index 023f6f0..4c91255 100644 --- a/pkg/parser/bogeydope_test.go +++ b/pkg/parser/bogeydope_test.go @@ -195,6 +195,132 @@ func TestParserBogeyDope(t *testing.T) { Filter: brevity.Aircraft, }, }, + { + text: TestCallsign + ", CAT1/1, request BOGUETTO.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "cat 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + "Cat 1.1 request BOGUE.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "cat 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + "Serptants, 6-8, Bogeydove.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "serptants 6 8", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", Spartan 1-1, Boogitope.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "spartan 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", COPWIPE11, BOKI NOLA.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "copwipe 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", Hornet one two, Bowie dope.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "hornet 1 2", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", radon11, boobydope.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "radon 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", stubs on one, poke it up.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "stubs on 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", Hollywood 11, VOGUE IT UP!", + expected: &brevity.BogeyDopeRequest{ + Callsign: "hollywood 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + "'s far on 1-1. Buggydope.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "s far on 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", copwhip11, poke it open.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "copwhip 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", copwhip11, poke it open.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "copwhip 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + " who is saying one-on-one request, Buggydope.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "who is saying 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", hood 1-3, BOBBYDO.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "hood 1 3", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", CAT11 request \"BOGI\".", + expected: &brevity.BogeyDopeRequest{ + Callsign: "cat 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", Voodoo11, BOGUIDO, please.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "voodoo 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", CAT1/1 \"BOGI\"", + expected: &brevity.BogeyDopeRequest{ + Callsign: "cat 1 1", + Filter: brevity.Aircraft, + }, + }, + { + text: TestCallsign + ", hurry one, two. Bogeydome.", + expected: &brevity.BogeyDopeRequest{ + Callsign: "hurry 1 2", + Filter: brevity.Aircraft, + }, + }, } runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { t.Helper() diff --git a/pkg/parser/callsign.go b/pkg/parser/callsign.go index a74f874..f53a1be 100644 --- a/pkg/parser/callsign.go +++ b/pkg/parser/callsign.go @@ -16,7 +16,6 @@ func ParsePilotCallsign(tx string) (callsign string, isValid bool) { for token, replacement := range map[string]string{ "request": "", "this is": "", - "on one": "11", "want to": "12", "tutu": "22", "to 8": "28", diff --git a/pkg/parser/checkin_test.go b/pkg/parser/checkin_test.go new file mode 100644 index 0000000..989920b --- /dev/null +++ b/pkg/parser/checkin_test.go @@ -0,0 +1,33 @@ +package parser + +import ( + "testing" + + "github.com/dharmab/skyeye/pkg/brevity" + "github.com/stretchr/testify/require" +) + +func TestParserCheckIn(t *testing.T) { + t.Parallel() + testCases := []parserTestCase{ + { + text: "anyface Baron91 checking in.", + expected: &brevity.CheckInRequest{ + Callsign: "baron 9 1", + }, + }, + { + text: "anyface, Mako, 1-1, check in.", + expected: &brevity.CheckInRequest{ + Callsign: "mako 1 1", + }, + }, + } + + runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { + t.Helper() + expected := test.expected.(*brevity.CheckInRequest) + actual := request.(*brevity.CheckInRequest) + require.Equal(t, expected.Callsign, actual.Callsign) + }) +} diff --git a/pkg/parser/declare_test.go b/pkg/parser/declare_test.go index 2824c26..9110742 100644 --- a/pkg/parser/declare_test.go +++ b/pkg/parser/declare_test.go @@ -260,6 +260,39 @@ func TestParserDeclare(t *testing.T) { IsBRAA: true, }, }, + { + text: TestCallsign + ", Thunder 1-1, declare 17631.", + expected: &brevity.DeclareRequest{ + Callsign: "thunder 1 1", + Bullseye: *brevity.NewBullseye( + bearings.NewMagneticBearing(176*unit.Degree), + 31*unit.NauticalMile, + ), + Track: brevity.UnknownDirection, + }, + }, + { + text: TestCallsign + ", Thunder 1-1, declare 177.29.", + expected: &brevity.DeclareRequest{ + Callsign: "thunder 1 1", + Bullseye: *brevity.NewBullseye( + bearings.NewMagneticBearing(177*unit.Degree), + 29*unit.NauticalMile, + ), + Track: brevity.UnknownDirection, + }, + }, + { + text: TestCallsign + " who is saying 11 requests declare 25545.", + expected: &brevity.DeclareRequest{ + Callsign: "who is saying 1 1", + Bullseye: *brevity.NewBullseye( + bearings.NewMagneticBearing(255*unit.Degree), + 45*unit.NauticalMile, + ), + Track: brevity.UnknownDirection, + }, + }, } runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { t.Helper() diff --git a/pkg/parser/parser_test.go b/pkg/parser/parser_test.go index cb7854d..e3e66ca 100644 --- a/pkg/parser/parser_test.go +++ b/pkg/parser/parser_test.go @@ -48,73 +48,7 @@ func TestParserSadPaths(t *testing.T) { t, New(TestCallsign, true), testCases, + // Nothing more to do, since the type is already checked func(*testing.T, parserTestCase, any) {}, ) } - -func TestParserAlphaCheck(t *testing.T) { - t.Parallel() - testCases := []parserTestCase{ - { - text: "ANYFACE, HORNET 1, CHECKING IN AS FRAGGED, REQUEST ALPHA CHECK DEPOT", - expected: &brevity.AlphaCheckRequest{ - Callsign: "hornet 1", - }, - }, - { - text: "anyface intruder 11 alpha check", - expected: &brevity.AlphaCheckRequest{ - Callsign: "intruder 1 1", - }, - }, - { - text: "anyface intruder 11, checking in as fragged, request alpha check bullseye", - expected: &brevity.AlphaCheckRequest{ - Callsign: "intruder 1 1", - }, - }, - { - text: TestCallsign + "intruder 11 alpha check", - expected: &brevity.AlphaCheckRequest{ - Callsign: "intruder 1 1", - }, - }, - { - text: TestCallsign + "Gunfighter 2-1, AlphaJack, Bullseye.", - expected: &brevity.AlphaCheckRequest{ - Callsign: "gunfighter 2 1", - }, - }, - } - runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { - t.Helper() - expected := test.expected.(*brevity.AlphaCheckRequest) - actual := request.(*brevity.AlphaCheckRequest) - require.Equal(t, expected.Callsign, actual.Callsign) - }) -} - -func TestParserCheckIn(t *testing.T) { - t.Parallel() - testCases := []parserTestCase{ - { - text: "anyface Baron91 checking in.", - expected: &brevity.CheckInRequest{ - Callsign: "baron 9 1", - }, - }, - { - text: "anyface, Mako, 1-1, check in.", - expected: &brevity.CheckInRequest{ - Callsign: "mako 1 1", - }, - }, - } - - runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { - t.Helper() - expected := test.expected.(*brevity.CheckInRequest) - actual := request.(*brevity.CheckInRequest) - require.Equal(t, expected.Callsign, actual.Callsign) - }) -} diff --git a/pkg/parser/radiocheck_test.go b/pkg/parser/radiocheck_test.go index ddf1a56..7a1dc22 100644 --- a/pkg/parser/radiocheck_test.go +++ b/pkg/parser/radiocheck_test.go @@ -70,6 +70,12 @@ func TestParserRadioCheck(t *testing.T) { Callsign: "heaven", }, }, + { + text: TestCallsign + ", call me '1-2', DRAVIA CHECK.", + expected: &brevity.RadioCheckRequest{ + Callsign: "call me 1 2", + }, + }, } runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { t.Helper() diff --git a/pkg/parser/replacements.go b/pkg/parser/replacements.go index daf4d28..7f01a56 100644 --- a/pkg/parser/replacements.go +++ b/pkg/parser/replacements.go @@ -19,6 +19,7 @@ var replacementLUT = map[string]string{ "bobbydo": bogeyDope, "bobido": bogeyDope, "boby dope": bogeyDope, + "dravia check": radioCheck, "bobydo": bogeyDope, "bog it": bogeyDope, "bogado": bogeyDope, diff --git a/pkg/parser/snaplock_test.go b/pkg/parser/snaplock_test.go index 0c60955..e98152a 100644 --- a/pkg/parser/snaplock_test.go +++ b/pkg/parser/snaplock_test.go @@ -45,6 +45,17 @@ func TestParserSnaplock(t *testing.T) { ), }, }, + { + text: TestCallsign + " Cat 1 1 Snaplock 0608-9.", + expected: &brevity.SnaplockRequest{ + Callsign: "cat 1 1", + BRA: brevity.NewBRA( + bearings.NewMagneticBearing(60*unit.Degree), + 8*unit.NauticalMile, + 9000*unit.Foot, + ), + }, + }, } runParserTestCases(t, New(TestCallsign, true), testCases, func(t *testing.T, test parserTestCase, request any) { t.Helper()