Skip to content
TheChatArchiveThe Chat Archive
fable-5· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

Add fluent helpers for sending stickers from Telegram sticker sets Support the public…

  1. User

    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.

  2. Assistant

    Now I have the full picture. Writing the implementation:

  3. Assistant

    Build passes. Now the tests:

  4. Assistant

    Test fixture issue — DocumentAttributeSticker.Stickerset can't be nil when encoding:

  5. Assistant

    All pass. Now the full package and lint:

  6. Assistant

    Done. The audio.go formatting issue is pre-existing in the committed tree, unrelated to this change; my new files are gofmt-clean and go vet passes.

    Summary

    New file telegram/message/sticker_set.go — fluent helpers for sending stickers from sticker sets:

    Sources (StickerSource is func(ctx, *tg.Client) ([]tg.DocumentClass, error)):

    • FavedStickers() — via messages.getFavedStickers
    • RecentStickers() — via messages.getRecentStickers
    • StickerSet(set tg.InputStickerSetClass) — via messages.getStickerSet
    • StickerSetName(shortName) — wraps StickerSet with &tg.InputStickerSetShortName{...}

    Builder ((*Builder).Sticker(source) *StickerSetBuilder, chains off sender.To(peer)):

    • Stickers(ctx, raw) — fetches the full document list (also guards a nil source)
    • ByIndex(ctx, index, caption...) — bounds-checked; index < 0 || index >= len returns a descriptive error
    • ByEmoji(ctx, emoji, caption...) — matches DocumentAttributeSticker.Alt; returns an error if no sticker matches (skips empty documents, never falls back to a different sticker)
    • First(ctx, caption...) — delegates to ByIndex(ctx, 0, ...); empty result surfaces as an out-of-range error, no panic

    Edge handling: *NotModified responses from all three RPCs surface as unexpected type %T errors via AsModified(); tg.DocumentEmpty at the selected index is an error rather than silently sending something else. Sending reuses the existing Document(...) media path so captions/styling and builder options (silent, reply, schedule, …) all apply.

    Tests (sticker_set_test.go, tgmock-based like the rest of the package, run with -race): send by name/index/emoji, out-of-range indexes (-1, len), empty-document selection, empty set via First, missing emoji, not-modified for all three sources, and the raw Stickers accessor — all passing, full ./telegram/message/... suite green.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.