Browse Source

Add additional fields to advertisemend methods

main
Sam 5 years ago
parent
commit
b247e10f1b
  1. 4
      docs_test.go
  2. 20
      keybase.go
  3. 12
      types.go

4
docs_test.go

@ -10,8 +10,8 @@ func ExampleKeybase_AdvertiseCommand() { @@ -10,8 +10,8 @@ func ExampleKeybase_AdvertiseCommand() {
c := BotAdvertisement{
Type: "public",
BotCommands: []BotCommand{
NewBotCommand("help", "Get help using this bot"),
NewBotCommand("hello", "Say hello"),
NewBotCommand("help", "Get help using this bot", "!help <command>"),
NewBotCommand("hello", "Say hello", "!hello"),
},
}

20
keybase.go

@ -37,10 +37,26 @@ func NewKeybase(path ...string) *Keybase { @@ -37,10 +37,26 @@ func NewKeybase(path ...string) *Keybase {
}
// NewBotCommand returns a new BotCommand instance
func NewBotCommand(name string, description string) BotCommand {
return BotCommand{
func NewBotCommand(name, description, usage string, extendedDescription ...BotCommandExtendedDescription) BotCommand {
result := BotCommand{
Name: name,
Description: description,
Usage: usage,
}
if len(extendedDescription) > 0 {
result.ExtendedDescription = &extendedDescription[0]
}
return result
}
// NewBotCommandExtendedDescription
func NewBotCommandExtendedDescription(title, desktopBody, mobileBody string) BotCommandExtendedDescription {
return BotCommandExtendedDescription{
Title: title,
DesktopBody: desktopBody,
MobileBody: mobileBody,
}
}

12
types.go

@ -297,8 +297,16 @@ type Channel struct { @@ -297,8 +297,16 @@ type Channel struct {
}
type BotCommand struct {
Name string `json:"name"`
Description string `json:"description"`
Name string `json:"name"`
Description string `json:"description"`
Usage string `json:"usage"`
ExtendedDescription *BotCommandExtendedDescription `json:"extended_description,omitempty"`
}
type BotCommandExtendedDescription struct {
Title string `json:"title"`
DesktopBody string `json:"desktop_body"`
MobileBody string `json:"mobile_body"`
}
type BotAdvertisement struct {

Loading…
Cancel
Save