Skip to content

feat: Support Bot API 9.6 & 10.0, multipart fixes — closes #279 #280, fixes #273 #274 #271 #277#281

Open
Zoomish wants to merge 7 commits into
go-telegram:mainfrom
Zoomish:bot-api-support
Open

feat: Support Bot API 9.6 & 10.0, multipart fixes — closes #279 #280, fixes #273 #274 #271 #277#281
Zoomish wants to merge 7 commits into
go-telegram:mainfrom
Zoomish:bot-api-support

Conversation

@Zoomish
Copy link
Copy Markdown

@Zoomish Zoomish commented May 11, 2026

Summary

This PR brings the client in line with Bot API 9.6 (April 3, 2026) and Bot API 10.0 (May 8, 2026), fixes several open bugs, and adjusts request building where the API now expects different shapes or extra attachments.

Bot API 9.6 - managed bots & polls ( #279 )

  • User: can_manage_bots.
  • Keyboard: KeyboardButtonRequestManagedBot (request_id, optional suggested_name, suggested_username) and KeyboardButton.request_managed_bot.
  • Updates: Update.managed_bot as ManagedBotUpdated (includes user and bot per API).
  • Messages: managed_bot_created (ManagedBotCreated), poll_option_added / poll_option_deleted with structures matching the API (poll_message, option_persistent_id, option_text, option_text_entities).
  • Methods: getManagedBotToken, replaceManagedBotToken (returns new token string), savePreparedKeyboardButton (user_id + KeyboardButton), response type PreparedKeyboardButton with id only; parameter JSON uses documented field names (e.g. user_id for managed-bot calls).
  • Polls: Poll / PollOption / PollAnswer updated for quizzes with multiple correct answers (correct_option_ids), optional revoting, descriptions, persistent_id / option_persistent_ids, option attribution and addition_date; SendPollParams extended (correct_option_ids, description/media/explanation fields, members_only, country_codes, revote/shuffle/add-options/hide-results flags, etc.).
  • Replies: ReplyParameters.poll_option_id and Message.reply_to_poll_option_id use string persistent identifiers as in the API.

Bot API 10.0 - guest mode, reactions admin, polls/media, live photos, access settings ( #280 )

  • Guest mode: User.supports_guest_queries; Message guest fields (guest_bot_caller_user, guest_bot_caller_chat, guest_query_id); Update.guest_message; answerGuestQuery with guest_query_id + result (InlineQueryResult); SentGuestMessage with inline_message_id.
  • Chat permissions / members: can_react_to_messages on ChatPermissions and ChatMemberRestricted; getChatAdministrators gains optional return_bots.
  • Reactions moderation: deleteMessageReaction (chat_id, message_id, optional user_id, actor_chat_id) and deleteAllMessageReactions (chat_id, optional user_id, actor_chat_id) - aligned with the current method tables (not the older reaction / message_id mistake).
  • Polls & media: PollMedia; Poll / PollOption incoming media fields; SendPollParams media / explanation_media via InputMedia (InputPollMedia union); InputPollOption embeds typed media in JSON via custom marshal; new InputMediaSticker, InputMediaLocation, InputMediaVenue; existing InputMediaLivePhoto completed (photo, has_spoiler, attachments for multipart).
  • Live photos: sendLivePhoto (live_photo + photo files, captions, etc.); LivePhoto and paid variants (PaidMediaLivePhoto, InputPaidMediaLivePhoto) for sending/receiving; Message / ExternalReplyInfo live_photo; multipart builder handles a second attach:// for live-photo payloads where needed.
  • Service messages: JSON keys for scheduled video chats use video_chat_* (replacing deprecated voice_chat_* keys on Message).
  • Managed bot access & DMs: BotAccessSettings; getManagedBotAccessSettings / setManagedBotAccessSettings; getUserPersonalChatMessages (user_id, required limit).

Bugfixes & ergonomics

Breaking changes

  • Poll / SendPollParams: correct_option_idcorrect_option_ids ([]int).
  • Reaction deletion methods: parameter sets replaced with API-accurate user_id / actor_chat_id (and deleteAllMessageReactions no longer takes message_id).
  • Poll option service payloads & reply IDs: PollOptionAdded / PollOptionDeleted reshaped; poll_option_id / reply_to_poll_option_id are strings.
  • Message: service fields for video chats use video_chat_* JSON keys.
  • Various *Params: stricter or wider chat-id types (int64, any) - callers passing channel/usernames or large IDs should verify compile-time types.

Test plan - 3/3 ✅

  • go build ./...
  • go vet ./...
  • go test ./...

Zoomish added 6 commits May 10, 2026 21:01
…rams.go for consistency with Telegram Bot API
- Introduced InputMediaLivePhoto type for handling live photo media in messages.
- Updated buildRequestForm to support InputMediaLivePhoto.
- Enhanced poll structures to include new fields for media and persistent IDs.
- Added new methods for managing bot tokens and guest queries in the Bot API.
- Updated chat permissions and user models to include new capabilities related to bot management and guest queries.
@Zoomish Zoomish changed the title feat: Support Bot API 9.6 & 10.0, multipart fixes — closes #279 #280, fixes #273 #274 #271 #277 feat: Support Bot API 9.6 & 10.0, multipart fixes - closes #279 #280, fixes #273 #274 #271 #277 May 11, 2026
@Zoomish Zoomish changed the title feat: Support Bot API 9.6 & 10.0, multipart fixes - closes #279 #280, fixes #273 #274 #271 #277 feat: Support Bot API 9.6 & 10.0, multipart fixes — closes #279 #280, fixes #273 #274 #271 #277 May 11, 2026
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 22.85714% with 108 lines in your changes missing coverage. Please review.
✅ Project coverage is 44.50%. Comparing base (f20f4ff) to head (f3b5003).

Files with missing lines Patch % Lines
models/input_media.go 0.00% 52 Missing ⚠️
methods.go 0.00% 40 Missing ⚠️
build_request_form.go 42.85% 10 Missing and 2 partials ⚠️
models/poll.go 77.77% 2 Missing and 2 partials ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #281      +/-   ##
==========================================
- Coverage   45.50%   44.50%   -1.01%     
==========================================
  Files          29       30       +1     
  Lines        2138     2274     +136     
==========================================
+ Hits          973     1012      +39     
- Misses       1111     1205      +94     
- Partials       54       57       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@negasus negasus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please, use gofmt before send PR

Comment thread models/chat.go
Comment thread models/message.go Outdated
Comment thread bot.go Outdated
- Removed the BotID method from the Bot struct, simplifying the token parsing logic.
- Updated the ID method to directly parse the bot ID from the token.
- Deleted the TestBot_BotID test case as it is no longer applicable.
- Made minor formatting adjustments in various model files for consistency.
@Zoomish Zoomish requested a review from negasus May 13, 2026 23:44
@Zoomish
Copy link
Copy Markdown
Author

Zoomish commented May 13, 2026

Also, please, use gofmt before send PR

Done — ran gofmt on the whole tree and pushed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants