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. 8
      types.go

4
docs_test.go

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

20
keybase.go

@ -37,10 +37,26 @@ func NewKeybase(path ...string) *Keybase {
} }
// NewBotCommand returns a new BotCommand instance // NewBotCommand returns a new BotCommand instance
func NewBotCommand(name string, description string) BotCommand { func NewBotCommand(name, description, usage string, extendedDescription ...BotCommandExtendedDescription) BotCommand {
return BotCommand{ result := BotCommand{
Name: name, Name: name,
Description: description, 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,
} }
} }

8
types.go

@ -299,6 +299,14 @@ type Channel struct {
type BotCommand struct { type BotCommand struct {
Name string `json:"name"` Name string `json:"name"`
Description string `json:"description"` 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 { type BotAdvertisement struct {

Loading…
Cancel
Save