-
Notifications
You must be signed in to change notification settings - Fork 1
/
methods.go
50 lines (46 loc) · 1.03 KB
/
methods.go
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
40
41
42
43
44
45
46
47
48
49
50
package ted
import (
"encoding/json"
)
func (b Bot) GetMe() (User, error) {
req := GetMeRequest{}
res, err := b.Do(req)
if err != nil {
return User{}, err
}
var me User
err = json.Unmarshal(res.Result, &me)
if err != nil {
return User{}, err
}
return me, nil
}
// GetWebhookInfo returns the current webhook status. Requires no parameters.
// On success, returns a WebhookInfo object. If the bot is using getUpdates,
// will return an object with the url field empty.
func (b Bot) GetWebhookInfo() (WebhookInfo, error) {
req := GetWebhookInfoRequest{}
res, err := b.Do(req)
if err != nil {
return WebhookInfo{}, err
}
var info WebhookInfo
err = json.Unmarshal(res.Result, &info)
if err != nil {
return WebhookInfo{}, err
}
return info, nil
}
func (b Bot) GetMyCommands() ([]BotCommand, error) {
req := GetMyCommandsRequest{}
res, err := b.Do(req)
if err != nil {
return nil, err
}
var commands []BotCommand
err = json.Unmarshal(res.Result, &commands)
if err != nil {
return nil, err
}
return commands, nil
}