2023-05-26 09:43:51 +08:00
|
|
|
package telegram
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/url"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetUpdates make a getUpdates api request.
|
2023-09-06 21:14:07 +08:00
|
|
|
func (b *Bot) GetUpdates(ctx context.Context, offset int64) ([]Update, error) {
|
2023-05-26 09:43:51 +08:00
|
|
|
formData := url.Values{
|
|
|
|
"timeout": {"60"},
|
2023-09-06 21:14:07 +08:00
|
|
|
"offset": {strconv.FormatInt(offset, 10)},
|
2023-05-26 09:43:51 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var result []Update
|
2023-05-29 19:49:05 +08:00
|
|
|
err := b.postForm(ctx, "/getUpdates", formData, &result)
|
2023-05-26 09:43:51 +08:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|