Skip to content

Latest commit

 

History

History
103 lines (85 loc) · 7.6 KB

File metadata and controls

103 lines (85 loc) · 7.6 KB

Changelog

[v0.5.0] - 2026-04-01

Added

  • WithRetry() option — opt-in automatic retry for retryable API errors (HTTP 429 rate limit and attachment processing errors). Configurable intervals, respects context cancellation. Default intervals: 500ms, 1s, 2s, 5s
  • DefaultRetryIntervals — exported default retry intervals for WithRetry
  • CheckPhoneNumbers(ctx, phoneNumbers) — check which phone numbers are registered in Max (GET /notify/exists)
  • SendMessageToPhones(ctx, phoneNumbers, body) — send messages to users by phone numbers (POST /messages with phone_numbers query parameter)

[v0.4.0] - 2026-03-11

Added

  • 5 new ChatAdminPermission constants: PermCanCall, PermEditLink, PermPostEditDeleteMessage, PermEditMessage, PermDeleteMessage
  • Upload convenience methods: UploadPhotoFromFile, UploadPhotoFromURL, UploadMediaFromFile, UploadMediaFromURL
  • ErrFetch error kind for external URL and local file failures in upload helpers
  • Example tests for godoc documentation

Security

  • FromURL upload methods validate URL scheme (only http/https allowed, prevents SSRF via file:// etc.)
  • FromURL upload methods limit download size to 50 MB (maxFetchSize)
  • extractFilename sanitizes Content-Disposition filenames with filepath.Base (prevents path traversal)

[v0.3.0] - 2026-02-23

Added

  • ContactAttachmentPayload.Phone() — extracts phone number from VCFInfo (vCard TEL field)

[v0.2.2] - 2026-02-15

Added

  • Button type open_app: NewOpenAppButton(text, webAppURL) constructor and Button.WebApp field for launching mini-apps inside the messenger
  • 5 new update types: BotStoppedUpdate, DialogMutedUpdate, DialogUnmutedUpdate, DialogClearedUpdate, DialogRemovedUpdate — with constants, Go structs, and JSON round-trip tests

[v0.2.1] - 2026-02-15

Fixed

  • Upload Content-Length: doUpload now buffers multipart body in memory instead of streaming via io.Pipe — the Max Bot API requires a Content-Length header, which was missing with pipe-based streaming (HTTP 406: "File size is unknown")

[v0.2.0] - 2026-02-14

Fixed

  • Optional null handling: Optional[T].UnmarshalJSON now treats JSON null as unset (Set=false) instead of Set=true with zero value — prevents accidental field overwrites when round-tripping API responses
  • Nil body panic: SendMessage and SendMessageToUser no longer panic when body is nil
  • Upload goroutine leak: doUpload now closes the pipe reader on all exit paths, preventing goroutine leaks on network errors
  • Upload timeout: doUpload now applies the client's default timeout when the context has no deadline, matching do() behavior
  • Long polling timeout: GetUpdates no longer races http.Client.Timeout against the server-side polling timeout — timeouts are now managed via context with an automatic 5s buffer on top of the server-side duration
  • JSON serialization: NewMessageBody.Attachments changed from omitempty to omitzero — empty slice []AttachmentRequest{} is now serialized as "attachments":[] instead of being omitted, allowing inline keyboard removal

Added

  • Attachment interface and MessageBody.ParseAttachments() — type-safe parsing of response attachments via discriminator map (all 11 types: image, video, audio, file, sticker, contact, share, location, data, inline_keyboard, reply_keyboard); unknown types are skipped for forward compatibility
  • Type-safe button constructors: NewCallbackButton, NewCallbackButtonWithIntent, NewLinkButton, NewRequestContactButton, NewRequestGeoLocationButton, NewChatButton, NewMessageButton
  • ErrPollDeadline — returned when the context deadline is too short for the requested polling timeout
  • Optional[T], Some[T]() — generic optional type with three-state JSON semantics (unset / zero value / value), replaces *string/*bool pointers in request types
  • Type aliases: OptString, OptBool, OptInt64

Changed

  • NewMessageBody.Text: *stringOptString
  • NewMessageBody.Notify: *boolOptBool
  • NewMessageBody.Format: *TextFormatOptional[TextFormat]
  • BotPatch.Name, .FirstName, .Description: *stringOptString
  • ChatPatch.Title, .Pin: *stringOptString
  • ChatPatch.Notify: *boolOptBool
  • CallbackAnswer.Notification: *stringOptString
  • PinMessageBody.Notify: *boolOptBool
  • Button.ChatDescription, .StartPayload: *stringOptString
  • Button.UUID: *int64OptInt64
  • ReplyButton.Payload: *stringOptString
  • AttachmentRequest.DirectUserID: *int64OptInt64
  • PhotoAttachmentRequestPayload.URL, .Token: *stringOptString
  • ContactAttachmentRequestPayload.Name, .VCFInfo, .VCFPhone: *stringOptString
  • ContactAttachmentRequestPayload.ContactID: *int64OptInt64
  • ShareAttachmentPayload.URL, .Token: *stringOptString

[v0.1.1] - 2026-02-14

Fixed

  • Query params: message_ids and types are now comma-separated (style: simple) as required by the OpenAPI schema
  • URL-encoding: GetChatByLink and GetMessageByID now escape special characters in path via url.PathEscape
  • Security: token is sent via Authorization header instead of access_token query parameter — prevents token leaking into proxy and CDN logs
  • Tests: requestCount in upload tests replaced with atomic.Int32 to eliminate race condition
  • Options: WithHTTPClient now makes a shallow copy — WithTimeout no longer mutates the external *http.Client
  • Types: Button.UUID changed from *int to *int64 for consistency with other ID fields
  • Leak fix: doUpload — added pr.Close() on request creation error
  • Types: interface{} replaced with any throughout (AttachmentRequest.Payload, do() signature)
  • Types: VideoURLs fields renamed to idiomatic Go (MP4_1080MP41080, etc.); JSON tags unchanged
  • Types: UserIdsListUserIDsList (Go naming convention for acronyms)
  • Types: User.LastName and User.Username changed from string to *string (nullable in API)
  • Types: NewMessageBody.Text changed from string to *stringnil means "keep existing text" on edit, "" means "clear text"
  • Types: GetAdmins now returns *ChatAdminsList instead of *ChatMembersList
  • Types: BotCommand.Description changed from string to *string (nullable in schema)
  • Types: ContactAttachmentRequestPayload.Name changed from string to *string (nullable in schema)
  • Code quality: isTimeout uses errors.As instead of direct type assertion (handles wrapped errors)

Added

  • Endpoints: SetAdmins (POST /chats/{chatId}/members/admins), RemoveAdmin (DELETE /chats/{chatId}/members/admins/{userId}), GetVideoDetails (GET /videos/{videoToken})
  • Params: DisableLinkPreview field on NewMessageBody (sent as query param, not JSON)
  • Params: from/to (time range filter) in GetMessages via new GetMessagesOpts
  • Params: user_ids in GetMembers via new GetMembersOpts
  • Opts: GetChatsOpts struct for GetChats pagination parameters
  • Opts: GetUpdatesOpts struct for GetUpdates long-polling parameters
  • Type-safe attachment constructors: NewPhotoAttachment, NewVideoAttachment, NewAudioAttachment, NewFileAttachment, NewStickerAttachment, NewContactAttachment, NewShareAttachment, NewInlineKeyboardAttachment, NewLocationAttachment
  • Tests: TestGetMessagesWithIDs, TestGetChatByLink, TestGetMembership, TestUnpinMessage, TestGetPinnedMessage, types_test.go (all 9 attachment constructors)