Skip to content

Commit

Permalink
Merge pull request #111 from shomali11/examples
Browse files Browse the repository at this point in the history
Converted Example to Examples
  • Loading branch information
raed-shomali authored Jul 26, 2022
2 parents a218a1f + a1936b5 commit e3aedd3
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func main() {

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

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

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

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

bot.Command("echo {word}", &slacker.CommandDefinition{
Description: "Echo a word!",
Example: "echo hello",
Examples: []string{"echo hello"},
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
word := request.Param("word")
response.Reply(word)
Expand Down
2 changes: 1 addition & 1 deletion command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// CommandDefinition structure contains definition of the bot command
type CommandDefinition struct {
Description string
Example string
Examples []string
BlockID string
AuthorizationFunc func(botCtx BotContext, request Request) bool
Handler func(botCtx BotContext, request Request, response ResponseWriter)
Expand Down
2 changes: 1 addition & 1 deletion examples/14/example14.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {

bot.Command("echo {word}", &slacker.CommandDefinition{
Description: "Echo a word!",
Example: "echo hello",
Examples: []string{"echo hello"},
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
word := request.Param("word")
response.Reply(word)
Expand Down
2 changes: 1 addition & 1 deletion examples/2/example2.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {

definition := &slacker.CommandDefinition{
Description: "Ping!",
Example: "ping",
Examples: []string{"ping"},
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
response.Reply("pong", slacker.WithThreadReply(true))
},
Expand Down
4 changes: 2 additions & 2 deletions examples/3/example3.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {

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

bot.Command("say <sentence>", &slacker.CommandDefinition{
Description: "Say a sentence!",
Example: "say hello there everyone!",
Examples: []string{"say hello there everyone!"},
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
sentence := request.Param("sentence")
response.Reply(sentence)
Expand Down
2 changes: 1 addition & 1 deletion examples/4/example4.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func main() {

definition := &slacker.CommandDefinition{
Description: "Repeat a word a number of times!",
Example: "repeat hello 10",
Examples: []string{"repeat hello 10"},
Handler: func(botCtx slacker.BotContext, request slacker.Request, response slacker.ResponseWriter) {
word := request.StringParam("word", "Hello!")
number := request.IntegerParam("number", 1)
Expand Down
4 changes: 2 additions & 2 deletions slacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ func (s *Slacker) defaultHelp(botCtx BotContext, request Request, response Respo

helpMessage += newLine

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

Expand Down

0 comments on commit e3aedd3

Please sign in to comment.