diff --git a/bot.go b/bot.go index 08e4d60..b0cac2a 100644 --- a/bot.go +++ b/bot.go @@ -345,6 +345,10 @@ func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error) { return updates, nil } +func (bot *BotAPI) RemoveWebhook() (APIResponse, error) { + return bot.MakeRequest("setWebhook", url.Values{}) +} + // SetWebhook sets a webhook. // If this is set, GetUpdates will not get any data! // @@ -352,9 +356,7 @@ func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error) { func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error) { if config.Certificate == nil { v := url.Values{} - if !config.Clear { - v.Add("url", config.URL.String()) - } + v.Add("url", config.URL.String()) return bot.MakeRequest("setWebhook", v) } diff --git a/bot_test.go b/bot_test.go index 34b6968..0d15e11 100644 --- a/bot_test.go +++ b/bot_test.go @@ -437,17 +437,15 @@ func TestSetWebhook(t *testing.T) { t.Fail() } - wh := tgbotapi.WebhookConfig{Clear: true} - _, err = bot.SetWebhook(wh) + bot.RemoveWebhook() - wh = tgbotapi.NewWebhookWithCert("https://example.com/tgbotapi-test/" + bot.Token, "tests/cert.pem") + wh := tgbotapi.NewWebhookWithCert("https://example.com/tgbotapi-test/"+bot.Token, "tests/cert.pem") _, err = bot.SetWebhook(wh) if err != nil { t.Fail() } - wh = tgbotapi.WebhookConfig{Clear: true} - _, err = bot.SetWebhook(wh) + bot.RemoveWebhook() } func TestUpdatesChan(t *testing.T) { diff --git a/configs.go b/configs.go index a33d715..d01da3c 100644 --- a/configs.go +++ b/configs.go @@ -436,7 +436,6 @@ type UpdateConfig struct { // WebhookConfig contains information about a SetWebhook request. type WebhookConfig struct { - Clear bool URL *url.URL Certificate interface{} } diff --git a/helpers.go b/helpers.go index 21caf9f..6a5916b 100644 --- a/helpers.go +++ b/helpers.go @@ -206,8 +206,7 @@ func NewWebhook(link string) WebhookConfig { u, _ := url.Parse(link) return WebhookConfig{ - URL: u, - Clear: false, + URL: u, } } @@ -220,7 +219,6 @@ func NewWebhookWithCert(link string, file interface{}) WebhookConfig { return WebhookConfig{ URL: u, - Clear: false, Certificate: file, } }