From b7575fce7041b962bf43d13ff5a5129ee1f22a57 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sun, 23 May 2021 15:17:03 +0300 Subject: [PATCH] webhooks: add ip_address and drop_pending_updates fields --- webhook.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/webhook.go b/webhook.go index e3f953a..22970c1 100644 --- a/webhook.go +++ b/webhook.go @@ -49,6 +49,9 @@ type Webhook struct { ErrorUnixtime int64 `json:"last_error_date"` ErrorMessage string `json:"last_error_message"` + IpAddress string `json:"ip_address"` + DropPendingUpdates bool `json:"drop_pending_updates"` + TLS *WebhookTLS Endpoint *WebhookEndpoint @@ -88,6 +91,12 @@ func (h *Webhook) getParams() map[string]string { data, _ := json.Marshal(h.AllowedUpdates) params["allowed_updates"] = string(data) } + if h.IpAddress != "" { + params["ip_address"] = h.IpAddress + } + if h.DropPendingUpdates { + params["drop_pending_updates"] = strconv.FormatBool(h.DropPendingUpdates) + } if h.TLS != nil { params["url"] = "https://" + h.Listen @@ -178,7 +187,13 @@ func (b *Bot) SetWebhook(w *Webhook) error { } // RemoveWebhook removes webhook integration. -func (b *Bot) RemoveWebhook() error { - _, err := b.Raw("deleteWebhook", nil) +func (b *Bot) RemoveWebhook(dropPending ...bool) error { + drop := false + if len(dropPending) > 0 { + drop = dropPending[0] + } + _, err := b.Raw("deleteWebhook", map[string]bool{ + "drop_pending_updates": drop, + }) return err }