diff --git a/go.sum b/go.sum index 9443345..766f6ad 100644 --- a/go.sum +++ b/go.sum @@ -339,6 +339,7 @@ github.com/mattermost/mattermost-server/v5 v5.24.0/go.mod h1:TVkOfVyk4wGw8j5J2IX github.com/mattermost/mattermost-server/v5 v5.24.1 h1:dkEDqjLTtgqlQTc03kEi7N2IgBT9cZmzLs6XPylpMUo= github.com/mattermost/mattermost-server/v5 v5.24.2 h1:dIh6Xlz257m+Y6m0VcqsTCekT+qdGPd+Usxj7Kfk980= github.com/mattermost/mattermost-server/v5 v5.25.2 h1:A1nyhIbRgY6NoSqg5zQP47F3zt2KEDEBcQs0sy5fAmw= +github.com/mattermost/mattermost-server/v5 v5.29.0 h1:v+qGNpMkgYRJY1qn4Rx2u1W7dbkmes47NnDZLSTIRGU= github.com/mattermost/rsc v0.0.0-20160330161541-bbaefb05eaa0/go.mod h1:nV5bfVpT//+B1RPD2JvRnxbkLmJEYXmRaaVl15fsXjs= github.com/mattermost/viper v1.0.4/go.mod h1:uc5hKG9lv4/KRwPOt2c1omOyirS/UnuA2TytiZQSFHM= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= diff --git a/plugin.json b/plugin.json index 8d06e4c..758cd91 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": "2.2.1", + "version": "2.2.2", "support_url": "https://github.com/monsdar/mattermost-icebreaker-plugin/issues", "homepage_url": "https://github.com/monsdar/mattermost-icebreaker-plugin", "release_notes_url": "https://github.com/monsdar/mattermost-icebreaker-plugin/releases", diff --git a/server/commands.go b/server/commands.go index e998968..5897291 100644 --- a/server/commands.go +++ b/server/commands.go @@ -16,7 +16,7 @@ const ( subcommandList = "list" subcommandRemove = "admin remove" subcommandClearAll = "admin clearall" - subcommandResetToDefault = "admin reset qestions" + subcommandResetToDefault = "admin reset questions" commandIcebreakerAsk = commandIcebreaker + " " + subcommandAsk commandIcebreakerAdd = commandIcebreaker + " " + subcommandAdd commandIcebreakerList = commandIcebreaker + " " + subcommandList @@ -28,24 +28,24 @@ const ( func getAutocompleteData() *model.AutocompleteData { icebreakerCommand := model.NewAutocompleteData(commandIcebreaker, "[command]", "Ask an icebreaker, available subcommands: [ask], [add], [list], [admin remove], [admin clearall], [admin reset questions]") - ask := model.NewAutocompleteData("ask", "", "Ask a new icebreaker") + ask := model.NewAutocompleteData("ask", "", "This will randomly select an available user from the channel and ask a random icebreaker question") icebreakerCommand.AddCommand(ask) - add := model.NewAutocompleteData(subcommandAdd, "[question]", "Add as new icebreaker question") - add.AddTextArgument("Question: Question you'd like to add", "[question]", "") + add := model.NewAutocompleteData(subcommandAdd, "[question]", "Add as new icebreaker question to the list") + add.AddTextArgument("Question: Question you'd like to add. Max 200 characters long.", "[question]", "") icebreakerCommand.AddCommand(add) - list := model.NewAutocompleteData(subcommandList, "", "Show available questions") + list := model.NewAutocompleteData(subcommandList, "", "Show a list of available questions") icebreakerCommand.AddCommand(list) remove := model.NewAutocompleteData(subcommandRemove, "[id]", "Remove a question. Admin only") remove.AddTextArgument("Id: Index of the question, as per `/icebreaker list`", "[id]", "") icebreakerCommand.AddCommand(remove) - clearall := model.NewAutocompleteData(subcommandClearAll, "", "Remove ALL questions. Admin only") + clearall := model.NewAutocompleteData(subcommandClearAll, "", "Remove ALL questions. *WARNING: No backup is being made.* Admin only") icebreakerCommand.AddCommand(clearall) - reset := model.NewAutocompleteData(subcommandResetToDefault, "", "Resets the questions to the default ones from this plugin. Admin only") + reset := model.NewAutocompleteData(subcommandResetToDefault, "", "Resets the questions to the default ones from this plugin. *WARNING: No backup is being made.* Admin only") icebreakerCommand.AddCommand(reset) return icebreakerCommand @@ -140,7 +140,7 @@ func (p *Plugin) executeCommandIcebreakerResetToDefault(args *model.CommandArgs) return &model.CommandResponse{ ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, - Text: fmt.Sprintf("All questions have been reset to the default ones. Beware the pitchforks!"), + Text: "All questions have been reset to the default ones. Beware the pitchforks!", } } @@ -191,11 +191,12 @@ func (p *Plugin) executeCommandIcebreakerList(args *model.CommandArgs) *model.Co if err == nil { creator = user.GetDisplayName("") } - message = message + fmt.Sprintf("%d.\t@%s:\t%s\n", index, creator, question.Question) + message = message + fmt.Sprintf("%d.\t@%s:\t%s\n", index+1, creator, question.Question) } return &model.CommandResponse{ ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL, + Username: "icebreaker", Text: message, } } diff --git a/server/manifest.go b/server/manifest.go index b32aebf..8bdc01b 100644 --- a/server/manifest.go +++ b/server/manifest.go @@ -18,7 +18,7 @@ const manifestStr = ` "homepage_url": "https://github.com/monsdar/mattermost-icebreaker-plugin", "support_url": "https://github.com/monsdar/mattermost-icebreaker-plugin/issues", "release_notes_url": "https://github.com/monsdar/mattermost-icebreaker-plugin/releases", - "version": "2.2.1", + "version": "2.2.2", "min_server_version": "5.12.0", "server": { "executables": { diff --git a/server/plugin.go b/server/plugin.go index 26282d4..7eec551 100644 --- a/server/plugin.go +++ b/server/plugin.go @@ -41,13 +41,16 @@ type IceBreakerData struct { const LenHistory int = 50 // OnActivate is invoked when the plugin is activated. -// -// This demo implementation logs a message to the demo channel whenever the plugin is activated. -// It also creates a demo bot account func (p *Plugin) OnActivate() error { //init the rand rand.Seed(1337) + //add default set of questions in case the list is empty + data := p.ReadFromStorage() + if len(data.Questions) == 0 { + p.FillDefaultQuestions() + } + //register all our commands if err := p.registerCommands(); err != nil { return errors.Wrap(err, "failed to register commands")