chore: update Telegram Bot API to v9.6 (06d02f9988ff)#173
chore: update Telegram Bot API to v9.6 (06d02f9988ff)#173
Conversation
Reviewer's GuideUpdates 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 callsequenceDiagram
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
Class diagram for updated Telegram message and member tag typesclassDiagram
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
Flow diagram for Message.Type with new sender_tag typeflowchart 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]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Treating
sender_tagas its ownMessageType(and checking it first inMessage.Type()) means any message that has both text/media and a sender tag will now be classified assender_taginstead of its primary content type, which is likely not what consumers expect; consider leavingsender_tagas metadata only and not part ofMessageType(or at least not short‑circuiting before text/media). - In the YAML spec for
setChatMemberTag, thetagparameter is described as optional in the HTML but is not explicitly markedoptional: 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| // Type returns the MessageType of this Message. | ||
| func (v *Message) Type() MessageType { | ||
| switch { | ||
| case v.SenderTag != "": |
There was a problem hiding this comment.
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_tagvia a separate helper or secondary classification, or - Limiting
MessageTypeSenderTagto 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.
|
@copilot fix issues Please address the comments from this code review: Overall Comments
Individual CommentsComment 1+ // Type returns the MessageType of this Message. **issue (bug_risk):** Using SenderTag as the highest-priority MessageType is likely to misclassify regular messagesBecause the
At minimum, consider moving this case after the concrete content types so content-bearing messages remain classified by their payload. |
1001a43 to
50e9d73
Compare
50e9d73 to
f426e3b
Compare
f426e3b to
b6d0bd1
Compare
Automated update of Telegram Bot API specification.
This PR was created automatically by the autogen workflow.