Advanced

Stickers

Stickers are documents grouped into named sets. gogram exposes a small high-level surface for send/create/edit and the raw TL methods for the rest (install, uninstall, fetch).

Sticker sets

Each sticker set has a short name (AnimatedEmojies, CryptocurrencyEmojis) and a numeric id. Sets contain up to 120 stickers, each a document with a sticker attribute (and optionally an emoji mapping).

Sending a sticker

The simplest path is to forward by file id (no upload required):

client.SendMedia(peerID, "CAACAgIAAxkBA...long-sticker-id...")
client.SendMedia(peerID, "CAACAgIAAxkBA...long-sticker-id...")

Pass a sticker's file id (you got it from an incoming message or a sticker set lookup) as the media argument to SendMedia. Animated and video stickers use the same method โ€” the file id encodes the sticker type.

Fetching a set

set, err := client.MessagesGetStickerSet(&telegram.MessagesGetStickerSetParams{
	Stickerset: &telegram.InputStickerSetShortName{ShortName: "AnimatedEmojies"},
})
if obj, ok := set.(*telegram.MessagesStickerSetObj); ok {
	for _, doc := range obj.Documents {
		fmt.Println(doc)
	}
}
set, err := client.MessagesGetStickerSet(&telegram.MessagesGetStickerSetParams{
	Stickerset: &telegram.InputStickerSetShortName{ShortName: "AnimatedEmojies"},
})
if obj, ok := set.(*telegram.MessagesStickerSetObj); ok {
	for _, doc := range obj.Documents {
		fmt.Println(doc)
	}
}

There is no high-level helper; the raw TL call takes an InputStickerSet which can be InputStickerSetShortName (by name), InputStickerSetID (by numeric id + access hash), or one of the InputStickerSetAnimatedEmoji-style built-in refs. The response includes set metadata, every sticker document, and per-document emoji packs.

Installing and removing

ref := &telegram.InputStickerSetShortName{ShortName: "AnimatedEmojies"}

// install (add to keyboard):
client.MessagesInstallStickerSet(&telegram.MessagesInstallStickerSetParams{
	Stickerset: ref,
	Archived:   false,
})

// archive without removing:
client.MessagesInstallStickerSet(&telegram.MessagesInstallStickerSetParams{
	Stickerset: ref,
	Archived:   true,
})

// uninstall:
client.MessagesUninstallStickerSet(&telegram.MessagesUninstallStickerSetParams{
	Stickerset: ref,
})
ref := &telegram.InputStickerSetShortName{ShortName: "AnimatedEmojies"}

// install (add to keyboard):
client.MessagesInstallStickerSet(&telegram.MessagesInstallStickerSetParams{
	Stickerset: ref,
	Archived:   false,
})

// archive without removing:
client.MessagesInstallStickerSet(&telegram.MessagesInstallStickerSetParams{
	Stickerset: ref,
	Archived:   true,
})

// uninstall:
client.MessagesUninstallStickerSet(&telegram.MessagesUninstallStickerSetParams{
	Stickerset: ref,
})

On a user account these put the set in the user's installed list. Bots can install sets they created.

Creating a sticker set

set, err := client.CreateStickerSet(
	ownerID,             // any: userID / username / peer
	"My Pack",           // title
	"my_pack_by_bot",    // short name, must end in _by_<botusername> for bot-owned sets
	[]telegram.StickerInput{
		{Document: doc1, Emoji: "๐Ÿ˜€"},
		{Document: doc2, Emoji: "๐Ÿ˜Ž"},
	},
)
set, err := client.CreateStickerSet(
	ownerID,             // any: userID / username / peer
	"My Pack",           // title
	"my_pack_by_bot",    // short name, must end in _by_<botusername> for bot-owned sets
	[]telegram.StickerInput{
		{Document: doc1, Emoji: "๐Ÿ˜€"},
		{Document: doc2, Emoji: "๐Ÿ˜Ž"},
	},
)

CreateStickerSet takes the owner (any peer form), title, short name, and a slice of StickerInput. For bot-owned sets the short name must end in _by_<botusername>. Options struct (CreateStickerSetOptions) toggles kind (regular / mask / custom emoji), text colour, software attribution, and thumbnail.

To add a sticker after creation: AddSticker(set, StickerInput). To remove: RemoveSticker(inputDoc). To reorder: MoveSticker(inputDoc, position). To edit an existing sticker's emoji or mask: EditSticker(inputDoc, emoji, keywords, mask). To rename or delete the whole set: RenameStickerSet(set, title), DeleteStickerSet(set).

Custom emoji sets

Premium custom emoji are a special sticker-set kind. Same methods, with Kind: telegram.StickerKindEmojis on CreateStickerSetOptions. Entries become inline custom emoji in messages via the MessageEntityCustomEmoji entity carrying the document id.