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 existing message builders to understand the expected abstractions and conventions, then implement the declared sticker-set API and run targeted plus broader tests.
- Assistant
The target file does not yet exist, so I’ll inspect the
telegram/messagepackage’s source interfaces, media builders, styled text handling, and generated Telegram RPC result types before designing the new implementation. - Assistant
I found an existing
stickers.gofor uploaded stickers only. Next I’ll read it alongside the core builder/media/document code and generated result class definitions to ensure sending uses the package’s normal pipeline and that every RPC variant—includingNotModified—is explicitly handled. - Assistant
The new source abstraction must be callable with
context.Contextand*tg.Client, while sending belongs to an existing destination-bound*message.Builder. I’ll inspectSender/request construction and exact generated getters/attribute layouts, then define a small exported source interface and adapters that preserve Telegram result semantics. - Assistant
For emoji matching, the authoritative value is each document’s
DocumentAttributeSticker.Alt; pack-level emoticons are not reliably one-to-one. I’ll verify document conversion helpers and generated class APIs, and search repository conventions for callable public source interfaces and error wording. - Assistant
A key API detail is receiver placement: a package-level
Sticker(source)cannot send because it has no destination, while this package’s fluent send helpers are methods on*Builder(the receiver is omitted from the issue’s input list). I’ll inspect analogous fluent helpers such asUploadandWebPageto mirror that shape; I’ll also check git history/tree state for any partial declaration elsewhere. - Assistant
The closest repository pattern uses function-valued option/source types, which keeps custom sources easy to provide. Before coding, I’ll inspect those definitions and the
tg.Clientconstruction used by tests so I can create a temporary RPC-backed verification without adding prohibited test files. - Assistant
I’ll implement
StickerSourceas an interface with aStickersmethod (matching the public fetching operation), provideStickerSetplus the three requested constructors, and add(*Builder).Stickerreturning a destination-bound fluent builder. Selection will validate before indexing, reject empty documents rather than falling through, compare exactAltstrings, and return explicit errors for allNotModifiedvariants. - Assistant
The implementation is in place, but the environment has
GOMODCACHE/GOPATHexplicitly unset, so tests did not compile yet. Before rerunning with a temporary per-command Go cache, I’ll harden typed/nil document handling (interface method calls on nil values could panic), then compile and inspect diagnostics. - Assistant
Dependencies downloaded successfully; compilation is now blocked only because
GOCACHEis also unset. I’ll set all Go cache paths for the command and run the targeted package tests. - Assistant
Targeted tests pass. I’ll now inspect the package’s mock RPC pattern and run a temporary external program (outside the repository, so no tests are added) to exercise source fetching, exact emoji selection, index errors, empty results, and
NotModifiedhandling through real generated RPC dispatch. - Assistant
tgmockis tied totesting.T, so for the temporary script I’ll implement the smallbin.Invokerinterface directly. The script will assert generated request types and return boxed Telegram responses, allowing end-to-end verification without touching repository tests. - Assistant
I can simplify the script by testing
StickerSetBuilder.Stickersagainst RPC responses and use a custom publicStickerSourcefor selection/send. I’ll inspect the update box type, then run assertions covering successful first/exact-emoji sends and each failure mode. - Assistant
I’ll execute the temporary verification now. It will fail loudly if index bounds fetch/send unexpectedly, if emoji matching selects a later/different value, if empty results do not error, or if
NotModifiedis treated as data. - Assistant
The temporary end-to-end checks pass. I noticed one additional malformed-input edge case: an interface can contain a typed-nil sticker attribute, so emoji selection should guard that pointer before reading
Alt. I’ll fix that, add nil-client checks directly to each public source to prevent standalone source calls from panicking, then run formatting, vet/targeted tests, and inspect the diff. - Assistant
Formatting, targeted tests, vet, and whitespace checks all pass. Because the new file is untracked, ordinary
git diffdid not display it; I’ll review the complete file directly and run a broadertelegram/...test suite to catch integration issues outside the message subpackages.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.