removeWebhook method added.
Gleb Sinyavsky zhulik.gleb@gmail.com
Sat, 21 Nov 2015 14:26:39 +0300
4 files changed,
9 insertions(+),
12 deletions(-)
M
bot.go
→
bot.go
@@ -345,6 +345,10 @@
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 @@ // Requires URL OR to set Clear to true.
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) }
M
bot_test.go
→
bot_test.go
@@ -437,17 +437,15 @@ if err != nil {
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) {
M
configs.go
→
configs.go
@@ -436,7 +436,6 @@ }
// WebhookConfig contains information about a SetWebhook request. type WebhookConfig struct { - Clear bool URL *url.URL Certificate interface{} }
M
helpers.go
→
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 @@ u, _ := url.Parse(link)
return WebhookConfig{ URL: u, - Clear: false, Certificate: file, } }