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