all repos — telegram-bot-api @ 9644984dae4c18c2109b47ac0da9eab69dae66b2

Golang bindings for the Telegram Bot API

removeWebhook method added.
Gleb Sinyavsky zhulik.gleb@gmail.com
Sat, 21 Nov 2015 14:26:39 +0300
commit

9644984dae4c18c2109b47ac0da9eab69dae66b2

parent

53dd9f6367ff5e28f99962463d58d2d298c8dba0

4 files changed, 9 insertions(+), 12 deletions(-)

jump to
M bot.gobot.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.gobot_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.goconfigs.go

@@ -436,7 +436,6 @@ }

// WebhookConfig contains information about a SetWebhook request. type WebhookConfig struct { - Clear bool URL *url.URL Certificate interface{} }
M helpers.gohelpers.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, } }