Fix Bot API request serialization parity gaps - #82
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a set of request-serialization gaps found while comparing the library against the current Telegram Bot API request contract and behavior in other connectors.
sendPaidMedia.mediaas a JSON array, as required by the Bot API, while keepingNewPaidMedia(..., *InputPaidMedia)source-compatible for single-item usage.PaidMediaConfig.MediaItemsandNewPaidMediaGroupfor the official 1-10 paid media item shape.InputSticker.stickeras the file string expected by Telegram:file_id/URL for remote files orattach://...for multipart uploads.FileIDand URL sticker values do not overwrite the JSONInputStickerobject during request preparation.falsevalues foranswerShippingQuery.ok,answerPreCheckoutQuery.ok, andeditUserStarSubscription.is_canceled.business_connection_id, zeroreply_parameters, and zerolink_preview_optionsobjects from shared base configs.Params.AddInterfaceskip typed nil slices/maps/interfaces instead of serializing them asnull, while preserving explicit non-nil empty slices as[].sendMessageDraft,setUserEmojiStatus,setCustomEmojiStickerSetThumbnail,editForumTopic,setMyName,setMyDescription, andsetMyShortDescription.Compatibility
This is intended to be source-compatible for existing callers:
NewPaidMediaandPaidMediaConfig.Mediacallers continue to compile; their request payload now matches the official array shape.AddInterfaceno longer emitsnullfor typed nil slices/maps/interfaces. Explicit empty slices still serialize as[], matching the API contract for list values.References Checked
sendPaidMedia.mediais an array ofInputPaidMediaitems.InputSticker.stickeris a string acceptingfile_id, URL, orattach://<file_attach_name>.sendPaidMediamodeled withmediaas a list/array and optional business parameters omitted when absent.Verification
go test ./...go vet ./...