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
Let me explore the repository structure to understand the codebase.
Assistant
Let me look at the builder, request, and how messages are sent. Let me look at the Builder and how Media works.
Assistant
Let me look at the tg package for relevant types and the sender.
Assistant
Now let me look at how StickerPack maps emoji to document IDs, and the getFavedStickers and getRecentStickers API.
Assistant
Now let me look at the not-modified types and how to detect them, and the InputStickerSetShortName.
Assistant
Now, the StickerSet (messages.stickerSet) doesn't have a "NotModified" variant I think. Let me check the MessagesStickerSetClass.
Assistant
Now let me look at how the Sender is structured and how messages are sent. Let me check the document.go and how Media is constructed from a document.
Assistant
Now I understand the structure. Let me look at how the existing sticker tests are structured and how the RequestBuilder provides access to a raw client. The issue says the
Stickersmethod takesctx: context.Context, raw: *tg.Client. So the StickerSetBuilder needs access to the raw tg.Client. Let me check how the Builder gets the raw client.Assistant
Let me look at how existing code handles similar patterns (inline.go for search and RequestBuilder methods).
Assistant
Let me look at how the RequestBuilder is constructed and how existing builder constructors work (file_promise.go, upload.go).
Assistant
Now let me check the exact signatures of the client methods.
Assistant
Let me check the FileLocation interface and how to create media from a document.
Assistant
Let me check the tg.Document getters and InputDocument.FillFrom.
Assistant
Let me check the document attributes for sticker alt emoji.
Assistant
Now let me look at existing tests to understand the test/mock pattern used in the repo.
Assistant
Let me look at the testSender helper and the tgmock to understand mocking RPC calls.
Assistant
Let me check the DocumentClass variants and DocumentEmpty.
Assistant
Let me check the errors package API used in the repo.
Assistant
Now let me check the StickerSet type used in the issue: "It wraps StickerSet with an InputStickerSetShortName." Let me check if there's a
tg.StickerSettype vs the function naming. Let me write the implementation now.Assistant
Now I have all the info. Let me create the sticker_set.go file.
Assistant
Now let me verify it compiles.
Assistant
It compiles. Now let me write a quick test to verify behavior, including edge cases. Let me look at how the tgmock works for mocking two sequential RPC calls (getStickerSet then sendMedia).
Assistant
Now let me write a temporary test to verify behavior. I'll create a test file in the message package and run it, then delete it before submitting.
Let me write a test that:
- Uses StickerSetName source, mocks MessagesGetStickerSet returning a MessagesStickerSet with documents, then mocks sendMedia, sends ByIndex(0).
- Tests ByEmoji.
- Tests out-of-range index error (no sendMedia call expected).
- Tests not-modified returns error.
Let me check how Mock handles the request matching - ExpectCall takes a bin.Encoder (the request). For MessagesGetStickerSetRequest, I pass
&tg.MessagesGetStickerSetRequest{Stickerset: &tg.InputStickerSetShortName{ShortName: "test"}}. The mock compares via... let me check request.go.Assistant
Let me check the Box types for the responses.
Assistant
Let me check how the rpc Invoke works with the mock to ensure boxes are decoded properly.
Assistant
Now let me write a temporary test to verify behavior.
Assistant
I have a build error in the Faved test — I used ExpectCall with a request, but MessagesGetFavedStickers uses a hash int64 not a request struct. Wait, the client method
MessagesGetFavedStickers(ctx, hash int64)constructs&MessagesGetFavedStickersRequest{Hash: hash}internally and invokes it. So the mock receives*tg.MessagesGetFavedStickersRequest. Somock.ExpectCall(&tg.MessagesGetFavedStickersRequest{Hash: 0})is correct. But the error is "declared and not used: req" at line 181. Let me check — line 181 is in the Recent test where I usedreq, ok := b.(*tg.MessagesGetRecentStickersRequest)andrequire.True(t, ok)but didn't usereq. Let me fix that to use_.Actually line 181 — let me look. The Faved test uses ExpectCall. The Recent test uses ExpectFunc with
req, ok := ...; require.True(t, ok).reqis unused. Let me fix.Assistant
The sed didn't work because
reqis still at line 181. Let me look at line 181.Assistant
The sed replacement didn't apply because the pattern
req, ok := b.(*tg.MessagesGetRecentStickersRequest)- the special characters*()need careful matching but sed should be fine. Wait, maybe there's a duplicate. Let me just edit directly.Assistant
The DocumentAttributeSticker requires a non-nil Stickerset field to encode. Let me fix the test helper.
Assistant
The sed escaping issue with
&. In sed replacement,&means the whole match. I need to escape&as\&. Let me just edit the file directly.Assistant
The sed mangled the file. Let me just recreate the test file cleanly.
Assistant
All tests pass. Now let me run the full existing test suite for the message package to ensure nothing is broken.
Assistant
All tests pass. Now let me run go vet and the broader telegram test suite.
Assistant
Now let me remove the temporary test file before submitting.
Assistant
The temp test is removed and sticker_set.go remains. Let me run the full message test suite once more to confirm everything passes.
Assistant
Let me review the final diff before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.