-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdates.go
More file actions
39 lines (33 loc) · 1013 Bytes
/
Copy pathupdates.go
File metadata and controls
39 lines (33 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// This file is part of Camponotus
// Camponotus is free software: see LICENSE.txt for more details.
package telegram
import (
"io"
"net/url"
)
// GetUpdates maps to https://core.telegram.org/bots/api#getupdates
func (a *api) GetUpdates(offset, limit, timeout int) ([]Update, error) {
params := url.Values{}
optInt(params, "offset", offset)
optInt(params, "limit", limit)
optInt(params, "timeout", timeout)
var u updateResult
err := a.callAndSet("getUpdates", params, &u)
return u.Updates, err
}
// SetWebhook maps to https://core.telegram.org/bots/api#setwebhook
func (a *api) SetWebhook(cb string, certificate io.Reader) error {
params := url.Values{}
optStr(params, "url", cb)
var r boolResult
var err error
if certificate != nil {
err = a.uploadAndSet("setWebhook", params, "certificate", certificate, &r)
} else {
err = a.callAndSet("setWebhook", params, &r)
}
if err == nil && !r.Ok {
err = &ErrNotOK{"setWebhook", params, "certificate", certificate, []byte{}}
}
return err
}