all repos — telegram-bot-api @ 4a2c8c4547a868841c1ec088302b23b59443de2b

Golang bindings for the Telegram Bot API

setMyCommands implemented
bcmk 45658475+bcmk@users.noreply.github.com
Sun, 27 Sep 2020 00:55:26 +0400
commit

4a2c8c4547a868841c1ec088302b23b59443de2b

parent

b2639432203d8b46127b037f03475c18846becf3

2 files changed, 21 insertions(+), 0 deletions(-)

jump to
M bot.gobot.go

@@ -1036,3 +1036,18 @@ return StickerSet{}, err

} return stickerSet, nil } + +// SetMyCommands changes the list of the bot's commands. +func (bot *BotAPI) SetMyCommands(commands []BotCommand) error { + v := url.Values{} + data, err := json.Marshal(commands) + if err != nil { + return err + } + v.Add("commands", string(data)) + _, err = bot.MakeRequest("setMyCommands", v) + if err != nil { + return err + } + return nil +}
M types.gotypes.go

@@ -1005,3 +1005,9 @@

func (e Error) Error() string { return e.Message } + +// BotCommand represents a bot command. +type BotCommand struct { + Command string `json:"command"` + Description string `json:"description"` +}