Updates for Bot API 4.7.
This commit is contained in:
parent
6ce4ec747d
commit
75e27e1380
5 changed files with 194 additions and 11 deletions
27
bot.go
27
bot.go
|
@ -62,8 +62,9 @@ func NewBotAPIWithClient(token string, client *http.Client) (*BotAPI, error) {
|
|||
return bot, nil
|
||||
}
|
||||
|
||||
func (b *BotAPI) SetAPIEndpoint(apiEndpoint string) {
|
||||
b.apiEndpoint = apiEndpoint
|
||||
// SetAPIEndpoint changes the Telegram Bot API endpoint used by the instance.
|
||||
func (bot *BotAPI) SetAPIEndpoint(apiEndpoint string) {
|
||||
bot.apiEndpoint = apiEndpoint
|
||||
}
|
||||
|
||||
func buildParams(in Params) (out url.Values) {
|
||||
|
@ -473,7 +474,7 @@ func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error {
|
|||
|
||||
if t, ok := c.(Fileable); ok {
|
||||
if !t.useExistingFile() {
|
||||
return errors.New("Can't use HTTP Response to upload files.")
|
||||
return errors.New("unable to use http response to upload files")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -610,3 +611,23 @@ func (bot *BotAPI) StopPoll(config StopPollConfig) (Poll, error) {
|
|||
|
||||
return poll, err
|
||||
}
|
||||
|
||||
// GetMyCommands gets the currently registered commands.
|
||||
func (bot *BotAPI) GetMyCommands() ([]BotCommand, error) {
|
||||
config := GetMyCommandsConfig{}
|
||||
|
||||
params, err := config.params()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := bot.MakeRequest(config.method(), params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var commands []BotCommand
|
||||
err = json.Unmarshal(resp.Result, &commands)
|
||||
|
||||
return commands, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue