Skip to content

Commit e3aedd3

Browse files
authored
Merge pull request #111 from shomali11/examples
Converted Example to Examples
2 parents a218a1f + a1936b5 commit e3aedd3

7 files changed

Lines changed: 13 additions & 13 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func main() {
127127

128128
definition := &slacker.CommandDefinition{
129129
Description: "Ping!",
130-
Example: "ping",
130+
Examples: []string{"ping"},
131131
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
132132
response.Reply("pong", slacker.WithThreadReply(true))
133133
},
@@ -165,7 +165,7 @@ func main() {
165165

166166
bot.Command("echo {word}", &slacker.CommandDefinition{
167167
Description: "Echo a word!",
168-
Example: "echo hello",
168+
Examples: []string{"echo hello"},
169169
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
170170
word := request.Param("word")
171171
response.Reply(word)
@@ -174,7 +174,7 @@ func main() {
174174

175175
bot.Command("say <sentence>", &slacker.CommandDefinition{
176176
Description: "Say a sentence!",
177-
Example: "say hello there everyone!",
177+
Examples: []string{"say hello there everyone!"},
178178
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
179179
sentence := request.Param("sentence")
180180
response.Reply(sentence)
@@ -212,7 +212,7 @@ func main() {
212212

213213
definition := &slacker.CommandDefinition{
214214
Description: "Repeat a word a number of times!",
215-
Example: "repeat hello 10",
215+
Examples: []string{"repeat hello 10"},
216216
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
217217
word := request.StringParam("word", "Hello!")
218218
number := request.IntegerParam("number", 1)
@@ -755,7 +755,7 @@ func main() {
755755

756756
bot.Command("echo {word}", &slacker.CommandDefinition{
757757
Description: "Echo a word!",
758-
Example: "echo hello",
758+
Examples: []string{"echo hello"},
759759
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
760760
word := request.Param("word")
761761
response.Reply(word)

command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
// CommandDefinition structure contains definition of the bot command
1111
type CommandDefinition struct {
1212
Description string
13-
Example string
13+
Examples []string
1414
BlockID string
1515
AuthorizationFunc func(botCtx BotContext, request Request) bool
1616
Handler func(botCtx BotContext, request Request, response ResponseWriter)

examples/14/example14.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func main() {
3434

3535
bot.Command("echo {word}", &slacker.CommandDefinition{
3636
Description: "Echo a word!",
37-
Example: "echo hello",
37+
Examples: []string{"echo hello"},
3838
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
3939
word := request.Param("word")
4040
response.Reply(word)

examples/2/example2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313

1414
definition := &slacker.CommandDefinition{
1515
Description: "Ping!",
16-
Example: "ping",
16+
Examples: []string{"ping"},
1717
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
1818
response.Reply("pong", slacker.WithThreadReply(true))
1919
},

examples/3/example3.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313

1414
bot.Command("echo {word}", &slacker.CommandDefinition{
1515
Description: "Echo a word!",
16-
Example: "echo hello",
16+
Examples: []string{"echo hello"},
1717
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
1818
word := request.Param("word")
1919
response.Reply(word)
@@ -22,7 +22,7 @@ func main() {
2222

2323
bot.Command("say <sentence>", &slacker.CommandDefinition{
2424
Description: "Say a sentence!",
25-
Example: "say hello there everyone!",
25+
Examples: []string{"say hello there everyone!"},
2626
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
2727
sentence := request.Param("sentence")
2828
response.Reply(sentence)

examples/4/example4.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func main() {
1313

1414
definition := &slacker.CommandDefinition{
1515
Description: "Repeat a word a number of times!",
16-
Example: "repeat hello 10",
16+
Examples: []string{"repeat hello 10"},
1717
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
1818
word := request.StringParam("word", "Hello!")
1919
number := request.IntegerParam("number", 1)

slacker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ func (s *Slacker) defaultHelp(botCtx BotContext, request Request, response Respo
285285

286286
helpMessage += newLine
287287

288-
if len(command.Definition().Example) > 0 {
289-
helpMessage += fmt.Sprintf(quoteMessageFormat, command.Definition().Example) + newLine
288+
for _, example := range command.Definition().Examples {
289+
helpMessage += fmt.Sprintf(quoteMessageFormat, example) + newLine
290290
}
291291
}
292292

0 commit comments

Comments
 (0)