From 5d3199dc21089fc8e1a056391e9356eb9d9e1272 Mon Sep 17 00:00:00 2001 From: ScuroNeko Date: Wed, 25 Mar 2026 18:20:20 +0300 Subject: [PATCH] fix(tgapi): accept string chat boost IDs --- CHANGELOG.md | 7 ++++++- tgapi/chat_types.go | 2 +- tgapi/types_test.go | 24 +++++++++++++++++++++++- utils/version.go | 4 ++-- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1e409a..714e5fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog -## Unreleased +## v1.0.0-rc.11 + +### Fixed +- `chat_boost` update decoding now accepts string `boost_id` values, matching the current Telegram Bot API schema and preventing polling failures on boosted-chat updates. + +## v1.0.0-rc.10 ### Added - `Plugin.AddUpdateHandler` for routing non-command Telegram updates by `tgapi.UpdateType`. diff --git a/tgapi/chat_types.go b/tgapi/chat_types.go index 2bdda56..d8d263e 100644 --- a/tgapi/chat_types.go +++ b/tgapi/chat_types.go @@ -224,7 +224,7 @@ type ChatBoostSource struct { // ChatBoost represents a boost added to a chat. // See https://core.telegram.org/bots/api#chatboost type ChatBoost struct { - BoostID int `json:"boost_id"` + BoostID string `json:"boost_id"` AddDate int `json:"add_date"` ExpirationDate int `json:"expiration_date"` Source ChatBoostSource `json:"source"` diff --git a/tgapi/types_test.go b/tgapi/types_test.go index bbdada5..6a72d98 100644 --- a/tgapi/types_test.go +++ b/tgapi/types_test.go @@ -37,9 +37,28 @@ func TestUpdateUnmarshalSetsType(t *testing.T) { }`, want: UpdateTypeCallbackQuery, }, + { + name: "chat boost", + body: `{ + "update_id": 3, + "chat_boost": { + "chat": {"id": -1001, "type": "supergroup", "title": "Boosted"}, + "boost": { + "boost_id": "boost-1", + "add_date": 1735689600, + "expiration_date": 1738291600, + "source": { + "source": "premium", + "user": {"id": 1, "is_bot": false, "first_name": "Test"} + } + } + } + }`, + want: UpdateTypeChatBoost, + }, { name: "unknown", - body: `{"update_id":3}`, + body: `{"update_id":4}`, want: UpdateTypeUnknown, }, } @@ -53,6 +72,9 @@ func TestUpdateUnmarshalSetsType(t *testing.T) { if update.Type != tt.want { t.Fatalf("unexpected update type: got %q want %q", update.Type, tt.want) } + if tt.want == UpdateTypeChatBoost && update.ChatBoost.Boost.BoostID != "boost-1" { + t.Fatalf("unexpected boost id: got %q want %q", update.ChatBoost.Boost.BoostID, "boost-1") + } }) } } diff --git a/utils/version.go b/utils/version.go index f2e6a5f..81a081e 100644 --- a/utils/version.go +++ b/utils/version.go @@ -2,7 +2,7 @@ package utils const ( // VersionString is the module version string. - VersionString = "1.0.0-rc.10" + VersionString = "1.0.0-rc.11" // VersionMajor is the module major version. VersionMajor = 1 // VersionMinor is the module minor version. @@ -10,5 +10,5 @@ const ( // VersionPatch is the module patch version. VersionPatch = 0 // VersionBeta is the prerelease counter for the current version. - VersionBeta = 10 + VersionBeta = 11 )