api_get_updates.go 424 B

1234567891011121314151617181920212223
  1. package telegram
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. )
  7. // GetUpdates make a getUpdates api request.
  8. func (b *Bot) GetUpdates(ctx context.Context, offset int64) ([]Update, error) {
  9. formData := url.Values{
  10. "timeout": {"60"},
  11. "offset": {strconv.FormatInt(offset, 10)},
  12. }
  13. var result []Update
  14. err := b.postForm(ctx, "/getUpdates", formData, &result)
  15. if err != nil {
  16. return nil, err
  17. }
  18. return result, nil
  19. }