ISSUE DESCRIPTION Add fluent helpers for sending stickers from Telegram sticker sets…
- User
ISSUE DESCRIPTION
Add fluent helpers for sending stickers from Telegram sticker sets
Support the public sticker-set sources and builder operations declared in the Interface. A caller must be able to select a sticker by index or emoji and send the first sticker. Invalid indexes, missing emoji, empty results, and Telegram's not-modified response must be handled without panics or silently selecting a different sticker.
Interface
Type: Function Name: FavedStickers Path: telegram/message/sticker_set.go Input: Output: StickerSource Description: Returns a StickerSource that retrieves the user's favorite stickers via messages.getFavedStickers. Use this when you want to send or pick from a user's faved sticker list.
Type: Function Name: RecentStickers Path: telegram/message/sticker_set.go Input: Output: StickerSource Description: Returns a StickerSource that retrieves the user's recently used stickers via messages.getRecentStickers. Use this when you want to send or pick from recently sent stickers.
Type: Function Name: StickerSetName Path: telegram/message/sticker_set.go Input: shortName: string Output: StickerSource Description: Returns a StickerSource that resolves a sticker set by its short name (e.g., "AnimatedEmojies"). It wraps StickerSet with an InputStickerSetShortName.
Type: Function Name: Sticker Path: telegram/message/sticker_set.go Input: source: StickerSource Output: *StickerSetBuilder Description: Creates a StickerSetBuilder from the given StickerSource, allowing the caller to pick and send a specific sticker from that source. Chain ByIndex, ByEmoji, or First onto the returned builder.
Type: Function Name: Stickers Path: telegram/message/sticker_set.go Input: ctx: context.Context, raw: *tg.Client Output: ([]tg.DocumentClass, error) Description: Method on StickerSetBuilder that fetches the full list of sticker documents from the underlying StickerSource. Call this if you need all stickers without immediately sending one.
Type: Function Name: ByIndex Path: telegram/message/sticker_set.go Input: ctx: context.Context, index: int, caption: ...StyledTextOption Output: (tg.UpdatesClass, error) Description: Sends the sticker at the given zero-based index from the StickerSource. Returns an error if the index is out of range.
Type: Function Name: ByEmoji Path: telegram/message/sticker_set.go Input: ctx: context.Context, emoji: string, caption: ...StyledTextOption Output: (tg.UpdatesClass, error) Description: Sends the first sticker from the source whose alternative emoji matches the provided emoji string. Returns an error if no matching sticker is found.
Type: Function Name: First Path: telegram/message/sticker_set.go Input: ctx: context.Context, caption: ...StyledTextOption Output: (tg.UpdatesClass, error) Description: Sends the first sticker from the StickerSource by delegating to ByIndex with index 0. Convenience method for sending the top sticker.
ADDITIONAL ADVICE
- Assistant
I’ll first inspect the repository structure and the existing message builders, especially any sticker-set declarations and analogous fluent media helpers. Then I’ll implement the interface with explicit error handling and run targeted plus repository tests.
- Assistant
The requested file does not yet exist, so I’ll map the
telegram/messagepackage’s core builder types and look for source abstractions (GIFs, media collections, or sticker APIs) that establish conventions for fetching, selection, captioning, and sending. - Assistant
I found the existing single-sticker send path. I’ll inspect it along with
Sender,StyledTextOption, document conversion helpers, and generated Telegram response/attribute types so the new builder composes with the package rather than duplicating send logic. - Assistant
The source must be attached to
*BuilderbecauseSticker(source)has no raw client argument while selection methods send to the builder’s peer. I’ll confirm howSenderexposes the raw client and how existing document media is constructed, then inspect exact generated response fields and sticker emoji attributes. - Assistant
The generated
tg.Documentcan be converted directly totg.InputDocumentviaFillFrom, andBuilder.Documentalready sends it with caption options. Next I’ll verify all sticker-source RPC signatures and response variants, includingmessages.stickerSetNotModified, and determine whether emoji may also be represented by sticker-pack metadata rather than only document attributes. - Assistant
Telegram’s favorite/recent APIs include both document attributes and pack mappings, but the issue specifically says “whose alternative emoji matches,” which corresponds to
DocumentAttributeSticker.Alt; I will honor that exactly and preserve source order. I’ll inspect package conventions for callback interfaces and errors before creating the implementation. - Assistant
I’ll implement a public function-typed
StickerSource, the implied generalStickerSet(tg.InputStickerSetClass)constructor, all three declared source helpers, and(*Builder).Sticker. Source RPCs will use hash0; therefore a not-modified response is unexpected and will become an explicit error rather than an empty list. Selection will reject negative/too-large indexes, reject empty/nil documents rather than falling through, and match onlyDocumentAttributeSticker.Altexactly. - Assistant
The implementation is in place, but tests could not start because this shell has neither
GOMODCACHEnorGOPATHconfigured (an environment issue, not a compile failure). I also noticed a needless loop index inByEmoji; I’ll clean that up, configure a temporary module cache, and rerun compilation/tests. - Assistant
Dependencies downloaded successfully; Go then reported a second environment omission (
GOCACHEandHOME). I’ll set a temporary build cache and rerun. After compilation, I’ll inspect the diff and use focused static checks for API shape and edge cases. - Assistant
Targeted tests pass. Before final verification, I’ll harden source decoding against typed-nil successful responses (which otherwise could panic in mocks or malformed transports), inspect the complete diff, and run formatting/vetting. I’ll keep empty lists as valid fetch results so
First/ByIndexproduce the required range error andByEmojiproduces the required missing-match error. - Assistant
Formatting, vet, and package tests pass. Because the file is new and untracked, plain
git diffdid not display it; I’ll review the full file directly and compare naming/documentation conventions. I’ll also check repository-wide compilation to catch any package-level name collision or broader API issue. - Assistant
All
telegram/...tests pass. I’ll do one final design check against generated API details and repository conventions. In particular, I’ll verify whetherStickerSourceshould expose a named method rather than be function-typed and ensure no recoverable nil case remains; then I’ll run the broad test suite if practical. - Assistant
The function type is consistent with this package’s callback-style public sources/promises and allows callers to provide custom sticker sources directly. No hidden repository object suggests a prior implementation to preserve. I’ll now run the complete repository test suite and final whitespace/status checks; if successful, I’ll submit with the requested checklist rationale.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.