Skip to content

chore: update Telegram Bot API to v9.6 (06d02f9988ff)#173

Open
mr-linch wants to merge 1 commit intomainfrom
auto/update-telegram-api
Open

chore: update Telegram Bot API to v9.6 (06d02f9988ff)#173
mr-linch wants to merge 1 commit intomainfrom
auto/update-telegram-api

Conversation

@mr-linch
Copy link
Copy Markdown
Owner

@mr-linch mr-linch commented Mar 1, 2026

Automated update of Telegram Bot API specification.

  • Version: 9.6
  • Hash: 06d02f9988ff

This PR was created automatically by the autogen workflow.

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai bot commented Mar 1, 2026

Reviewer's Guide

Updates the embedded Telegram Bot API spec and generated Go types/methods from Bot API 9.4 to 9.5, adding support for date_time message entities, member tags and related permissions/admin rights, the new setChatMemberTag method, and reflecting loosened restrictions on sendMessageDraft and media group identifiers.

Sequence diagram for setChatMemberTag API call

sequenceDiagram
    actor BotDeveloper
    participant Client
    participant SetChatMemberTagCall
    participant TelegramBotAPI as TelegramBotAPI95

    BotDeveloper->>Client: SetChatMemberTag(chatID, userID)
    activate Client
    Client->>SetChatMemberTagCall: NewSetChatMemberTagCall(chatID, userID)
    activate SetChatMemberTagCall
    SetChatMemberTagCall-->>Client: SetChatMemberTagCall
    deactivate SetChatMemberTagCall
    Client-->>BotDeveloper: SetChatMemberTagCall
    deactivate Client

    BotDeveloper->>SetChatMemberTagCall: Tag(tag)
    activate SetChatMemberTagCall
    SetChatMemberTagCall->>TelegramBotAPI: HTTP request setChatMemberTag
    TelegramBotAPI-->>SetChatMemberTagCall: Boolean result
    deactivate SetChatMemberTagCall

    SetChatMemberTagCall-->>BotDeveloper: Success or error
Loading

Class diagram for updated Telegram message and member tag types

classDiagram
    class Client {
        +SetChatMemberTag(chatID PeerID, userID UserID) SetChatMemberTagCall
    }

    class SetChatMemberTagCall {
        +ChatID(chatID PeerID) SetChatMemberTagCall
        +UserID(userID UserID) SetChatMemberTagCall
        +Tag(tag string) SetChatMemberTagCall
    }

    class PromoteChatMemberCall {
        +CanManageTags(canManageTags bool) PromoteChatMemberCall
    }

    class Message {
        +SenderTag string
        +Type() MessageType
    }

    class MessageEntity {
        +Type MessageEntityType
        +UnixTime UnixTime
        +DateTimeFormat string
    }

    class MessageEntityType {
        <<enum>>
        +MessageEntityTypeUnknown
        +MessageEntityTypeMention
        +MessageEntityTypeHashtag
        +MessageEntityTypeCashtag
        +MessageEntityTypeBotCommand
        +MessageEntityTypeURL
        +MessageEntityTypeEmail
        +MessageEntityTypePhoneNumber
        +MessageEntityTypeBold
        +MessageEntityTypeItalic
        +MessageEntityTypeUnderline
        +MessageEntityTypeStrikethrough
        +MessageEntityTypeSpoiler
        +MessageEntityTypeBlockquote
        +MessageEntityTypeExpandableBlockquote
        +MessageEntityTypeCode
        +MessageEntityTypePre
        +MessageEntityTypeTextLink
        +MessageEntityTypeTextMention
        +MessageEntityTypeCustomEmoji
        +MessageEntityTypeDateTime
        +String() string
        +UnmarshalText(b []byte) error
        +IsUnknown() bool
    }

    class MessageType {
        <<enum>>
        +MessageTypeUnknown
        +MessageTypeSenderTag
        +MessageTypeText
        +MessageTypeAnimation
        +MessageTypeAudio
        +MessageTypeDocument
        +MessageTypePhoto
        +MessageTypeSticker
        +MessageTypeVideo
        +MessageTypeVideoNote
        +MessageTypeVoice
        +MessageTypeContact
        +MessageTypeDice
        +MessageTypeGame
        +MessageTypePoll
        +MessageTypeVenue
        +MessageTypeLocation
        +MessageTypeNewChatMembers
        +MessageTypeLeftChatMember
        +MessageTypeNewChatTitle
        +MessageTypeNewChatPhoto
        +MessageTypeDeleteChatPhoto
        +MessageTypeGroupChatCreated
        +MessageTypeSupergroupChatCreated
        +MessageTypeChannelChatCreated
        +MessageTypeMessageAutoDeleteTimerChanged
        +MessageTypeMigrateToChatID
        +MessageTypeMigrateFromChatID
        +MessageTypePinnedMessage
        +MessageTypeInvoice
        +MessageTypeSuccessfulPayment
        +MessageTypeUserShared
        +MessageTypeChatShared
        +MessageTypeConnectedWebsite
        +MessageTypeWriteAccessAllowed
        +MessageTypePassportData
        +MessageTypeProximityAlertTriggered
        +MessageTypeForumTopicCreated
        +MessageTypeForumTopicEdited
        +MessageTypeForumTopicClosed
        +MessageTypeForumTopicReopened
        +MessageTypeGeneralForumTopicHidden
        +MessageTypeGeneralForumTopicUnhidden
        +MessageTypeGiveawayCreated
        +MessageTypeGiveaway
        +MessageTypeGiveawayWinners
        +MessageTypeGiveawayCompleted
        +MessageTypeVideoChatScheduled
        +MessageTypeVideoChatStarted
        +MessageTypeVideoChatEnded
        +MessageTypeVideoChatParticipantsInvited
        +MessageTypeWebAppData
        +String() string
        +IsUnknown() bool
    }

    class ChatAdministratorRights {
        +CanManageChat bool
        +CanDeleteMessages bool
        +CanManageVideoChats bool
        +CanRestrictMembers bool
        +CanPromoteMembers bool
        +CanChangeInfo bool
        +CanInviteUsers bool
        +CanPostStories bool
        +CanEditStories bool
        +CanDeleteStories bool
        +CanPostMessages bool
        +CanEditMessages bool
        +CanPinMessages bool
        +CanManageTopics bool
        +CanManageDirectMessages bool
        +CanManageTags bool
    }

    class ChatMemberAdministrator {
        +User User
        +CanBeEdited bool
        +IsAnonymous bool
        +CanManageChat bool
        +CanDeleteMessages bool
        +CanManageVideoChats bool
        +CanRestrictMembers bool
        +CanPromoteMembers bool
        +CanChangeInfo bool
        +CanInviteUsers bool
        +CanPostStories bool
        +CanEditStories bool
        +CanDeleteStories bool
        +CanPostMessages bool
        +CanEditMessages bool
        +CanPinMessages bool
        +CanManageTopics bool
        +CanManageDirectMessages bool
        +CanManageTags bool
        +CustomTitle string
    }

    class ChatMemberMember {
        +Tag string
        +User User
        +UntilDate UnixTime
    }

    class ChatMemberRestricted {
        +Tag string
        +User User
        +IsMember bool
        +CanSendMessages bool
        +CanSendAudios bool
        +CanSendDocuments bool
        +CanSendPhotos bool
        +CanSendVideos bool
        +CanSendVideoNotes bool
        +CanSendVoiceNotes bool
        +CanSendPolls bool
        +CanSendOtherMessages bool
        +CanAddWebPagePreviews bool
        +CanEditTag bool
        +CanChangeInfo bool
        +CanInviteUsers bool
        +CanPinMessages bool
        +CanManageTopics bool
        +UntilDate UnixTime
    }

    class ChatPermissions {
        +CanSendMessages bool
        +CanSendAudios bool
        +CanSendDocuments bool
        +CanSendPhotos bool
        +CanSendVideos bool
        +CanSendVideoNotes bool
        +CanSendVoiceNotes bool
        +CanSendPolls bool
        +CanSendOtherMessages bool
        +CanAddWebPagePreviews bool
        +CanEditTag bool
        +CanChangeInfo bool
        +CanInviteUsers bool
        +CanPinMessages bool
        +CanManageTopics bool
    }

    class User {
    }

    class PeerID {
    }

    class UserID {
    }

    Client --> SetChatMemberTagCall : creates
    PromoteChatMemberCall --> ChatAdministratorRights : configures permissions
    Message --> MessageEntity : contains
    Message --> MessageType : uses
    MessageEntity --> MessageEntityType : uses
    ChatMemberAdministrator --> User : wraps
    ChatMemberMember --> User : wraps
    ChatMemberRestricted --> User : wraps
    ChatMemberAdministrator --> ChatAdministratorRights : corresponds
    ChatPermissions --> ChatMemberRestricted : defines
    ChatPermissions --> ChatMemberMember : defines
    ChatPermissions --> ChatMemberAdministrator : defines
    SetChatMemberTagCall --> PeerID : uses
    SetChatMemberTagCall --> UserID : uses
    Client --> PromoteChatMemberCall : uses
Loading

Flow diagram for Message.Type with new sender_tag type

flowchart TD
    A[Message.Type called] --> B{SenderTag != empty}
    B -- yes --> C[Return MessageTypeSenderTag]
    B -- no --> D{Text != empty}
    D -- yes --> E[Return MessageTypeText]
    D -- no --> F{Animation != nil}
    F -- yes --> G[Return MessageTypeAnimation]
    F -- no --> H{Audio != nil}
    H -- yes --> I[Return MessageTypeAudio]
    H -- no --> J{Other message fields checks}
    J -- match known --> K[Return corresponding MessageType]
    J -- no match --> L[Return MessageTypeUnknown]
Loading

File-Level Changes

Change Details Files
Update embedded Bot API HTML/YAML specs to 9.5, including new date_time entities, member tags/permissions, and sendMessageDraft semantics.
  • Add a March 1, 2026 Bot API 9.5 changelog entry to the HTML spec, summarizing new types, fields, and methods.
  • Extend MessageEntity docs to include the new date_time type plus unix_time and date_time_format fields and add a dedicated date-time entity formatting section with examples for MarkdownV2 and HTML.
  • Document new tag/can_edit_tag/can_manage_tags fields on ChatMember*, ChatPermissions, ChatAdministratorRights, and promoteChatMember, including the new setChatMemberTag method.
  • Clarify wording for media_group_id (scoped to chat) and remove the forum-topic-only restriction from sendMessageDraft in the specs.
_spec/api.html
_spec/api.yaml
Regenerate Go types and client methods to match the 9.5 spec (date_time entity support, sender tags, admin/member permissions, new method).
  • Bump generated headers in methods_gen.go to Bot API 9.5 metadata (version, date, hash).
  • Update SendMessageDraftCall documentation string to match the relaxed spec text.
  • Add CanManageTags fluent setter to PromoteChatMemberCall to expose the new can_manage_tags parameter.
  • Introduce SetChatMemberTagCall with constructor, client helper, and setters for chat_id, user_id, and tag, wiring it to the setChatMemberTag API method.
  • Extend Message with SenderTag field and classify messages with a new MessageTypeSenderTag in the Message.Type() switch.
  • Extend MessageEntity with MessageEntityTypeDateTime enum plus UnixTime and DateTimeFormat fields, updating string/unmarshal helpers and All list.
  • Add CanManageTags to ChatAdministratorRights and ChatMemberAdministrator, Tag to ChatMemberMember/ChatMemberRestricted, and CanEditTag to ChatMemberRestricted and ChatPermissions to reflect new permissions.
methods_gen.go
types_gen.go
Align public README badge with Bot API 9.5 release.
  • Update README Telegram Bot API badge text, date, and spec anchor to reference version 9.5 released on March 1, 2026.
README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Treating sender_tag as its own MessageType (and checking it first in Message.Type()) means any message that has both text/media and a sender tag will now be classified as sender_tag instead of its primary content type, which is likely not what consumers expect; consider leaving sender_tag as metadata only and not part of MessageType (or at least not short‑circuiting before text/media).
  • In the YAML spec for setChatMemberTag, the tag parameter is described as optional in the HTML but is not explicitly marked optional: true; aligning this flag with the upstream spec will avoid tools or generators misinterpreting it as required.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Treating `sender_tag` as its own `MessageType` (and checking it first in `Message.Type()`) means any message that has both text/media and a sender tag will now be classified as `sender_tag` instead of its primary content type, which is likely not what consumers expect; consider leaving `sender_tag` as metadata only and not part of `MessageType` (or at least not short‑circuiting before text/media).
- In the YAML spec for `setChatMemberTag`, the `tag` parameter is described as optional in the HTML but is not explicitly marked `optional: true`; aligning this flag with the upstream spec will avoid tools or generators misinterpreting it as required.

## Individual Comments

### Comment 1
<location path="types_gen.go" line_range="10815" />
<code_context>
+	// Type returns the MessageType of this Message.
</code_context>
<issue_to_address>
**issue (bug_risk):** Using SenderTag as the highest-priority MessageType is likely to misclassify regular messages

Because the `MessageTypeSenderTag` case now appears first in `Message.Type()`, any supergroup message with a non-empty `SenderTag` will be classified as `MessageTypeSenderTag`, even when it has text, media, etc. This shifts `Type()` from describing the primary payload to describing metadata, and can break existing callers that assume `Type()` reflects the main content. I’d suggest either:

- Keeping the original content-based priority and handling `sender_tag` via a separate helper or secondary classification, or
- Limiting `MessageTypeSenderTag` to messages that are exclusively tag-change events, if supported by the spec.

At minimum, consider moving this case after the concrete content types so content-bearing messages remain classified by their payload.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread types_gen.go
// Type returns the MessageType of this Message.
func (v *Message) Type() MessageType {
switch {
case v.SenderTag != "":
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Using SenderTag as the highest-priority MessageType is likely to misclassify regular messages

Because the MessageTypeSenderTag case now appears first in Message.Type(), any supergroup message with a non-empty SenderTag will be classified as MessageTypeSenderTag, even when it has text, media, etc. This shifts Type() from describing the primary payload to describing metadata, and can break existing callers that assume Type() reflects the main content. I’d suggest either:

  • Keeping the original content-based priority and handling sender_tag via a separate helper or secondary classification, or
  • Limiting MessageTypeSenderTag to messages that are exclusively tag-change events, if supported by the spec.

At minimum, consider moving this case after the concrete content types so content-bearing messages remain classified by their payload.

@mr-linch
Copy link
Copy Markdown
Owner Author

mr-linch commented Mar 2, 2026

@copilot fix issues

Please address the comments from this code review:

Overall Comments

  • Treating sender_tag as its own MessageType (and checking it first in Message.Type()) means any message that has both text/media and a sender tag will now be classified as sender_tag instead of its primary content type, which is likely not what consumers expect; consider leaving sender_tag as metadata only and not part of MessageType (or at least not short‑circuiting before text/media).
  • In the YAML spec for setChatMemberTag, the tag parameter is described as optional in the HTML but is not explicitly marked optional: true; aligning this flag with the upstream spec will avoid tools or generators misinterpreting it as required.

Individual Comments

Comment 1

+ // Type returns the MessageType of this Message. **issue (bug_risk):** Using SenderTag as the highest-priority MessageType is likely to misclassify regular messages

Because the MessageTypeSenderTag case now appears first in Message.Type(), any supergroup message with a non-empty SenderTag will be classified as MessageTypeSenderTag, even when it has text, media, etc. This shifts Type() from describing the primary payload to describing metadata, and can break existing callers that assume Type() reflects the main content. I’d suggest either:

  • Keeping the original content-based priority and handling sender_tag via a separate helper or secondary classification, or
  • Limiting MessageTypeSenderTag to messages that are exclusively tag-change events, if supported by the spec.

At minimum, consider moving this case after the concrete content types so content-bearing messages remain classified by their payload.
</issue_to_address>

Copy link
Copy Markdown

Copilot AI commented Mar 2, 2026

@mr-linch I've opened a new pull request, #174, to work on those changes. Once the pull request is ready, I'll request review from you.

@mr-linch mr-linch force-pushed the auto/update-telegram-api branch from 1001a43 to 50e9d73 Compare March 3, 2026 08:11
@mr-linch mr-linch force-pushed the auto/update-telegram-api branch from 50e9d73 to f426e3b Compare April 4, 2026 08:36
@mr-linch mr-linch changed the title chore: update Telegram Bot API to v9.5 (798fa610d92f) chore: update Telegram Bot API to v9.6 (c5cbe31565f2) Apr 4, 2026
@mr-linch mr-linch force-pushed the auto/update-telegram-api branch from f426e3b to b6d0bd1 Compare April 7, 2026 08:56
@mr-linch mr-linch changed the title chore: update Telegram Bot API to v9.6 (c5cbe31565f2) chore: update Telegram Bot API to v9.6 (06d02f9988ff) Apr 7, 2026
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.

2 participants