From b247e10f1b4020438bcb3c08b010e58f5da5b341 Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 4 Nov 2019 08:19:19 -0500 Subject: [PATCH] Add additional fields to advertisemend methods --- docs_test.go | 4 ++-- keybase.go | 20 ++++++++++++++++++-- types.go | 12 ++++++++++-- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/docs_test.go b/docs_test.go index 77808ec..e92ece6 100644 --- a/docs_test.go +++ b/docs_test.go @@ -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 "), + NewBotCommand("hello", "Say hello", "!hello"), }, } diff --git a/keybase.go b/keybase.go index 3e21e5f..1124fcd 100644 --- a/keybase.go +++ b/keybase.go @@ -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, } } diff --git a/types.go b/types.go index 8adcaa3..790079f 100644 --- a/types.go +++ b/types.go @@ -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 {