Skip to content

Commit

Permalink
Fixed a number of minor issues found during the Mattermost marketplac…
Browse files Browse the repository at this point in the history
…e review
  • Loading branch information
Nils Brinkmann committed Nov 21, 2020
1 parent ba5f304 commit 72a608a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 10 additions & 9 deletions server/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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!",
}
}

Expand Down Expand Up @@ -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,
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/manifest.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions server/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 72a608a

Please sign in to comment.