Messages

Media & albums

One call to send a photo, a video, a document, a voice note, an album, or a sticker. The argument types decide what gets sent.

SendMedia

client.SendMedia(peerID, "./photo.jpg", &telegram.MediaOptions{
	Caption: "view from the office",
})
client.SendMedia(peerID, "./photo.jpg", &telegram.MediaOptions{
	Caption: "view from the office",
})

gogram looks at the input, figures out the media type, uploads if necessary, and submits the right InputMedia* constructor. From your side it is one call regardless of whether you are sending a 50 KB JPEG or a 1.5 GB video.

What you can pass

The Media any parameter is intentionally loose:

  • A file path on disk ("./photo.jpg"). gogram opens, hashes for dedup, uploads, and submits the resulting InputFile.
  • An http:// or https:// URL. Telegram fetches it server-side — no upload bandwidth from you. The downside is no progress info.
  • A raw []byte with the file content already in memory.
  • An io.Reader — gogram chunk-uploads as it reads.
  • A previously-uploaded file id (the base64 string Telegram assigns). Reuses the existing upload without re-sending bytes.
  • An already-constructed InputMedia for full control.

MediaOptions

MediaOptions is a superset of SendOptions. The interesting extras:

MimeType string
Override the auto-detected MIME. Useful when sending raw bytes with no extension.
FileName string
The name Telegram shows for documents. Defaults to the local file name.
ForceDocument bool
Send as an attachment instead of an inline photo/video preview.
Thumb any
Custom thumbnail. Accepts the same types as Media.
Spoiler bool
Hide the media behind a spoiler overlay until tapped.
TTL int32
Self-destruct timer in seconds (private chats only).
NoSoundVideo bool
Mark a video as silent so clients play it without audio decoding.
VideoCover / VideoTimestamp
Custom poster frame and start-time hint.
SkipHash bool
Skip the dedup hash lookup. Forces a fresh upload even if Telegram already has the same bytes.
client.SendMedia(peerID, "./report.pdf", &telegram.MediaOptions{
	ForceDocument: true,
	FileName:      "Q3-report.pdf",
	Caption:       "the long version",
})
client.SendMedia(peerID, "./report.pdf", &telegram.MediaOptions{
	ForceDocument: true,
	FileName:      "Q3-report.pdf",
	Caption:       "the long version",
})

Albums

An album groups 2 to 10 photos/videos under a single bubble. Telegram requires every item to be the same kind (all photos, all videos, or a mix of the two; documents and audio have their own album types).

client.SendAlbum(peerID, []any{
	"./a.jpg",
	"./b.jpg",
	"./c.jpg",
}, &telegram.MediaOptions{
	Caption: "trip photos",
})
client.SendAlbum(peerID, []any{
	"./a.jpg",
	"./b.jpg",
	"./c.jpg",
}, &telegram.MediaOptions{
	Caption: "trip photos",
})

gogram uploads every item in parallel using exported senders, then submits one messages.sendMultiMedia. The return value is a slice of *NewMessage.

Per-item captions: pass Caption as a []string on MediaOptions. Per-item options (different spoilers, different file names) need pre-constructed InputMedia objects.

Stickers

Stickers are documents with a specific MIME type and attribute. The simplest way is to forward an existing sticker by file id; the other is to use the stickers helpers for set lookups.

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

Dice

Animated dice, slot machine, basketball — the server picks the outcome and animates it on every client. The value comes back on the returned *NewMessage.

client.SendDice(peerID, "🎲")
client.SendDice(peerID, "🎲")