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

Responding to "Thanks" with "You're welcome!" #103

Merged
merged 4 commits into from
Oct 22, 2024
Merged
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
3 changes: 3 additions & 0 deletions dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ func (pl *PairingLogic) dispatch(ctx context.Context, cmd string, cmdArgs []stri
case "version":
return pl.version, nil

case "thanks":
return youreWelcomeMessage, nil

default:
// this won't execute because all input has been sanitized
// by parseCmd() and all cases are handled explicitly above
Expand Down
13 changes: 13 additions & 0 deletions dispatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,17 @@ func Test_dispatch(t *testing.T) {
t.Errorf("expected %q, got %q", expected, resp)
}
})

t.Run("thanks", func(t *testing.T) {
resp, err := pl.dispatch(ctx, "thanks", nil, rec)

if err != nil {
t.Fatal(err)
}

expected := "You're welcome!"
if resp != expected {
t.Errorf("expected %q, got %q", expected, resp)
}
})
}
1 change: 1 addition & 0 deletions messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var subscribeMessage string
var unsubscribeMessage string

const notSubscribedMessage string = "You're not subscribed to Pairing Bot <3"
const youreWelcomeMessage string = "You're welcome!"

var writeErrorMessage = fmt.Sprintf("Something went sideways while writing to the database. You should probably ping %v", maintainersMention())
var readErrorMessage = fmt.Sprintf("Something went sideways while reading from the database. You should probably ping %v", maintainersMention())
3 changes: 2 additions & 1 deletion parse_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ func parseCmd(cmdStr string) (string, []string, error) {
return "help", nil, fmt.Errorf(`%w: wanted "tomorrow"`, ErrInvalidArguments)
}
return name, []string{"tomorrow"}, nil

case "thank", "thanks":
return "thanks", nil, nil
default:
return "help", nil, fmt.Errorf("%w: %q", ErrUnknownCommand, name)
}
Expand Down
4 changes: 4 additions & 0 deletions parse_cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ var acceptedCommands = map[string]parseResult{

// Review content *is* case-sensitive.
"add-review I :heart: Pairing Bot!\n": {"add-review", []string{"I :heart: Pairing Bot!"}},

// We appreciate being appreciated
"thanks": {"thanks", nil},
"thank you": {"thanks", nil},
}

func TestParseCmdAccept(t *testing.T) {
Expand Down
Loading