From abb0943aec62dd0a7ec935864c952545c26dc2bb Mon Sep 17 00:00:00 2001 From: Nils Brinkmann Date: Fri, 7 Aug 2020 12:46:17 +0200 Subject: [PATCH] Fixed: Allowing /icebreaker with a space in the end (as autocomplete fills it in for the user) --- plugin.json | 2 +- server/commands.go | 1 + server/commands_test.go | 4 ++-- server/manifest.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugin.json b/plugin.json index c65fde2..ecf1443 100644 --- a/plugin.json +++ b/plugin.json @@ -2,7 +2,7 @@ "id": "com.nilsbrinkmann.icebreaker", "name": "Icebreaker Plugin", "description": "This plugin creates a bot which asks random questions", - "version": "1.4.1", + "version": "1.4.2", "min_server_version": "5.12.0", "server": { "executables": { diff --git a/server/commands.go b/server/commands.go index d0637cd..9312b02 100644 --- a/server/commands.go +++ b/server/commands.go @@ -132,6 +132,7 @@ func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*mo } trigger := strings.TrimPrefix(args.Command, "/") + trigger = strings.TrimSuffix(trigger, " ") //first check for admin commands, make sure the user has the right permission for key, value := range adminCommands { diff --git a/server/commands_test.go b/server/commands_test.go index 7e4de79..5ab9456 100644 --- a/server/commands_test.go +++ b/server/commands_test.go @@ -223,14 +223,14 @@ func TestAskIcebreaker_success(t *testing.T) { plugin.SetAPI(api) args := &model.CommandArgs{ - Command: "/icebreaker", + Command: "/icebreaker ", ChannelId: "TestChannel", TeamId: "TestTeam", RootId: "TestRoot", UserId: "TestUser", } - plugin.executeCommandIcebreaker(args) + plugin.ExecuteCommand(nil, args) }) t.Run("Successful, other user", func(t *testing.T) { rand.Seed(4) //seed guarantees that the loop goes through a few users before picking success_user2 diff --git a/server/manifest.go b/server/manifest.go index 06ca0a9..3971ab1 100644 --- a/server/manifest.go +++ b/server/manifest.go @@ -15,7 +15,7 @@ const manifestStr = ` "id": "com.nilsbrinkmann.icebreaker", "name": "Icebreaker Plugin", "description": "This plugin creates a bot which asks random questions", - "version": "1.4.1", + "version": "1.4.2", "min_server_version": "5.12.0", "server": { "executables": {