b.Send() must implement the Sendable interface. This lets you define custom compound types that send themselves across multiple messages.
The Sendable interface
Sendable to b.Send() calls its Send method directly:
Built-in sendable types
Photo
A JPEG/PNG/WebP image. Supports
Caption, HasSpoiler, CaptionAbove.Audio
An MP3/M4A file. Supports
Title, Performer, Duration, Thumbnail.Video
A video file. Supports
Width, Height, Duration, Streaming, Cover.Document
A generic file. Supports
FileName, Thumbnail, DisableTypeDetection.Voice
An OGG voice note. Supports
Caption, Duration.VideoNote
A round video note. Supports
Duration, Length, Thumbnail.Animation
A GIF or MP4 without sound. Requires
FileName to send as animation.Sticker
A WebP/animated sticker. Supports
Emoji.Location
Geographic coordinates with optional live tracking (
LivePeriod).Venue
A location with name, address and optional Foursquare/Google Place ID.
Contact
A phone contact with
PhoneNumber, FirstName, optionally VCard.Dice
An animated dice. Available types:
Cube, Dart, Ball, Goal, Slot, Bowl.Poll
A poll with
PollRegular or PollQuiz type.Game
A Telegram game identified by
Name (short name).Invoice
A payment invoice. See the Payments guide.
The Recipient interface
Anything with aRecipient() string method can receive messages. Telebot implements this for *User and *Chat:
*tele.User, *tele.Chat, or any custom type that implements the interface:
SendOptions
SendOptions gives full control over how a message is delivered:
Option flags:
Option flags
| Flag | Equivalent SendOptions field |
|---|---|
tele.Silent | DisableNotification: true |
tele.NoPreview | DisableWebPagePreview: true |
tele.Protected | Protected: true |
tele.AllowWithoutReply | AllowWithoutReply: true |
tele.ForceReply | ReplyMarkup.ForceReply: true |
tele.OneTimeKeyboard | ReplyMarkup.OneTimeKeyboard: true |
tele.RemoveKeyboard | ReplyMarkup.RemoveKeyboard: true |
Parse modes
Control how Telegram renders message text:Settings to avoid repeating it on every send:
Albums
Album is a []Inputtable slice. Send it with b.SendAlbum():
Only the first album item can have a caption.
SendAlbum only respects the tele.Silent option.Custom Sendable
ImplementSendable to create reusable compound message types: