mirror of
https://github.com/tucnak/telebot
synced 2024-11-05 06:00:58 +00:00
webhooks: add ip_address and drop_pending_updates fields
This commit is contained in:
parent
cfe18bbec5
commit
b7575fce70
19
webhook.go
19
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user