Skip to content

Commit

Permalink
setMyCommands implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
bcmk committed Sep 26, 2020
1 parent b263943 commit 4a2c8c4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
15 changes: 15 additions & 0 deletions bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1036,3 +1036,18 @@ func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
}
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
}
6 changes: 6 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,3 +1005,9 @@ type Error struct {
func (e Error) Error() string {
return e.Message
}

// BotCommand represents a bot command.
type BotCommand struct {
Command string `json:"command"`
Description string `json:"description"`
}

0 comments on commit 4a2c8c4

Please sign in to comment.