telebot: github.com/tucnak/telebot Index | Files

package telebot

import "github.com/tucnak/telebot"

Package telebot is a framework for Telegram bots.

Example:

package main

import (
	"time"
	tb "gopkg.in/tucnak/telebot.v2"
)

func main() {
	b, err := tb.NewBot(tb.Settings{
		Token: "TOKEN_HERE",
		Poller: &tb.LongPoller{Timeout: 10 * time.Second},
	})

	if err != nil {
		return
	}

	b.Handle(tb.OnText, func(m *tb.Message) {
		b.Send(m.Sender, "hello world")
	})

	b.Start()
}

Index

Package Files

admin.go api.go bot.go callbacks.go chat.go data_payments.go editable.go file.go filters.go inline.go inline_types.go input_types.go media.go message.go options.go payments.go poller.go sendable.go stickers.go telebot.go util.go webhook.go

Constants

const (
    // Basic message handlers.
    //
    // Handler: func(*Message)
    OnText              = "\atext"
    OnPhoto             = "\aphoto"
    OnAudio             = "\aaudio"
    OnDocument          = "\adocument"
    OnSticker           = "\asticker"
    OnVideo             = "\avideo"
    OnVoice             = "\avoice"
    OnVideoNote         = "\avideo_note"
    OnContact           = "\acontact"
    OnLocation          = "\alocation"
    OnVenue             = "\avenue"
    OnEdited            = "\aedited"
    OnPinned            = "\apinned"
    OnChannelPost       = "\achan_post"
    OnEditedChannelPost = "\achan_edited_post"

    // Will fire when bot is added to a group.
    OnAddedToGroup = "\aadded_to_group"
    // Group events:
    OnUserJoined        = "\auser_joined"
    OnUserLeft          = "\auser_left"
    OnNewGroupTitle     = "\anew_chat_title"
    OnNewGroupPhoto     = "\anew_chat_photo"
    OnGroupPhotoDeleted = "\achat_photo_del"

    // Migration happens when group switches to
    // a super group. You might want to update
    // your internal references to this chat
    // upon switching as its ID will change.
    //
    // Handler: func(from, to int64)
    OnMigration = "\amigration"

    // Will fire on callback requests.
    //
    // Handler: func(*Callback)
    OnCallback = "\acallback"

    // Will fire on incoming inline queries.
    //
    // Handler: func(*Query)
    OnQuery = "\aquery"

    // Will fire on chosen inline results.
    //
    // Handler: func(*ChosenInlineResult)
    OnChosenInlineResult = "\achosen_inline_result"

    // Will fire on PreCheckoutQuery.
    //
    // Handler: func(*PreCheckoutQuery)
    OnCheckout = "\apre_checkout_query"
)

These are one of the possible events Handle() can deal with.

For convenience, all Telebot-provided endpoints start with an "alert" character \a.

const DefaultApiURL = "https://api.telegram.org"

Variables

var (
    ErrCouldNotUpdate = errors.New("telebot: could not fetch new updates")
)
var SupportedCurrencies = map[string]Currency{}

func Forever Uses

func Forever() int64

Forever is a Unixtime of "forever" banning.

type Album Uses

type Album []InputMedia

Album lets you group multiple media (so-called InputMedia) into a single messsage.

On older clients albums look like N regular messages.

type ArticleResult Uses

type ArticleResult struct {
    ResultBase

    // Title of the result.
    Title string `json:"title"`

    // Message text. Shortcut (and mutually exclusive to) specifying
    // InputMessageContent.
    Text string `json:"message_text,omitempty"`

    // Optional. URL of the result.
    URL string `json:"url,omitempty"`

    // Optional. Pass True, if you don't want the URL to be shown in the message.
    HideURL bool `json:"hide_url,omitempty"`

    // Optional. Short description of the result.
    Description string `json:"description,omitempty"`

    // Optional. URL of the thumbnail for the result.
    ThumbURL string `json:"thumb_url,omitempty"`
}

ArticleResult represents a link to an article or web page. See also: https://core.telegram.org/bots/api#inlinequeryresultarticle

type Audio Uses

type Audio struct {
    File

    // Duration of the recording in seconds as defined by sender.
    Duration int `json:"duration,omitempty"`

    // (Optional)
    Caption   string `json:"caption,omitempty"`
    Title     string `json:"title,omitempty"`
    Performer string `json:"performer,omitempty"`
    MIME      string `json:"mime_type,omitempty"`
}

Audio object represents an audio file.

func (*Audio) Send Uses

func (a *Audio) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type AudioResult Uses

type AudioResult struct {
    ResultBase

    // Title.
    Title string `json:"title"`

    // A valid URL for the audio file.
    URL string `json:"audio_url"`

    // Optional. Performer.
    Performer string `json:"performer,omitempty"`

    // Optional. Audio duration in seconds.
    Duration int `json:"audio_duration,omitempty"`

    // If Cache != "", it'll be used instead
    Cache string `json:"audio_file_id,omitempty"`
}

AudioResult represents a link to an mp3 audio file.

type Bot Uses

type Bot struct {
    Me      *User
    Token   string
    URL     string
    Updates chan Update
    Poller  Poller
    // contains filtered or unexported fields
}

Bot represents a separate Telegram bot instance.

func NewBot Uses

func NewBot(pref Settings) (*Bot, error)

NewBot does try to build a Bot with token `token`, which is a secret API key assigned to particular bot.

func (*Bot) Accept Uses

func (b *Bot) Accept(query *PreCheckoutQuery, errorMessage ...string) error

Accept finalizes the deal.

func (*Bot) AdminsOf Uses

func (b *Bot) AdminsOf(chat *Chat) ([]ChatMember, error)

AdminsOf return a member list of chat admins.

On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.

func (*Bot) Answer Uses

func (b *Bot) Answer(query *Query, response *QueryResponse) error

Answer sends a response for a given inline query. A query can only be responded to once, subsequent attempts to respond to the same query will result in an error.

func (*Bot) Ban Uses

func (b *Bot) Ban(chat *Chat, member *ChatMember) error

Ban will ban user from chat until `member.RestrictedUntil`.

func (*Bot) ChatByID Uses

func (b *Bot) ChatByID(id string) (*Chat, error)

ChatByID fetches chat info of its ID.

Including current name of the user for one-on-one conversations, current username of a user, group or channel, etc.

Returns a Chat object on success.

func (*Bot) ChatMemberOf Uses

func (b *Bot) ChatMemberOf(chat *Chat, user *User) (*ChatMember, error)

ChatMemberOf return information about a member of a chat.

Returns a ChatMember object on success.

func (*Bot) Delete Uses

func (b *Bot) Delete(message Editable) error

Delete removes the message, including service messages, with the following limitations:

* A message can only be deleted if it was sent less than 48 hours ago.
* Bots can delete outgoing messages in groups and supergroups.
* Bots granted can_post_messages permissions can delete outgoing
  messages in channels.
* If the bot is an administrator of a group, it can delete any message there.
* If the bot has can_delete_messages permission in a supergroup or a
  channel, it can delete any message there.

func (*Bot) DeleteGroupPhoto Uses

func (b *Bot) DeleteGroupPhoto(chat *Chat) error

DeleteGroupPhoto should be used to just remove group photo.

func (*Bot) DeleteGroupStickerSet Uses

func (b *Bot) DeleteGroupStickerSet(chat *Chat) error

DeleteGroupStickerSet should be used to just remove group sticker set.

func (*Bot) Download Uses

func (b *Bot) Download(f *File, localFilename string) error

Download saves the file from Telegram servers locally.

Maximum file size to download is 20 MB.

func (*Bot) Edit Uses

func (b *Bot) Edit(message Editable, what interface{}, options ...interface{}) (*Message, error)

Edit is magic, it lets you change already sent message.

Use cases:

b.Edit(msg, msg.Text, newMarkup)
b.Edit(msg, "new <b>text</b>", tb.ModeHTML)

// Edit live location:
b.Edit(liveMsg, tb.Location{42.1337, 69.4242})

func (*Bot) EditCaption Uses

func (b *Bot) EditCaption(originalMsg Editable, caption string) (*Message, error)

EditCaption used to edit already sent photo caption with known recepient and message id.

On success, returns edited message object

func (*Bot) FileByID Uses

func (b *Bot) FileByID(fileID string) (File, error)

FileByID returns full file object including File.FilePath, allowing you to download the file from the server.

Usually, Telegram-provided File objects miss FilePath so you might need to perform an additional request to fetch them.

func (*Bot) FileURLByID Uses

func (b *Bot) FileURLByID(fileID string) (string, error)

FileURLByID returns direct url for files using FileId which you can get from File object

func (*Bot) Forward Uses

func (b *Bot) Forward(to Recipient, what *Message, options ...interface{}) (*Message, error)

Forward behaves just like Send() but of all options it only supports Silent (see Bots API).

This function will panic upon unsupported payloads and options!

func (b *Bot) GetInviteLink(chat *Chat) (string, error)

GetInviteLink should be used to export chat's invite link.

func (*Bot) Handle Uses

func (b *Bot) Handle(endpoint interface{}, handler interface{})

Handle lets you set the handler for some command name or one of the supported endpoints.

Example:

b.handle("/help", func (m *tb.Message) {})
b.handle(tb.OnEdited, func (m *tb.Message) {})
b.handle(tb.OnQuery, func (q *tb.Query) {})

// make a hook for one of your preserved (by-pointer)
// inline buttons.
b.handle(&inlineButton, func (c *tb.Callback) {})

func (*Bot) Leave Uses

func (b *Bot) Leave(chat *Chat) error

Leave makes bot leave a group, supergroup or channel.

func (*Bot) Len Uses

func (b *Bot) Len(chat *Chat) (int, error)

Len return the number of members in a chat.

func (*Bot) Notify Uses

func (b *Bot) Notify(recipient Recipient, action ChatAction) error

Notify updates the chat action for recipient.

Chat action is a status message that recipient would see where you typically see "Harry is typing" status message. The only difference is that bots' chat actions live only for 5 seconds and die just once the client recieves a message from the bot.

Currently, Telegram supports only a narrow range of possible actions, these are aligned as constants of this package.

func (*Bot) Pin Uses

func (b *Bot) Pin(message Editable, options ...interface{}) error

Use this method to pin a message in a supergroup or a channel.

It supports telebot.Silent option.

func (*Bot) ProfilePhotosOf Uses

func (b *Bot) ProfilePhotosOf(user *User) ([]Photo, error)

ProfilePhotosOf return list of profile pictures for a user.

func (*Bot) Promote Uses

func (b *Bot) Promote(chat *Chat, member *ChatMember) error

Promote lets you update member's admin rights, such as:

* can change info
* can post messages
* can edit messages
* can delete messages
* can invite users
* can restrict members
* can pin messages
* can promote members

func (*Bot) Raw Uses

func (b *Bot) Raw(method string, payload interface{}) ([]byte, error)

Raw lets you call any method of Bot API manually.

func (*Bot) Reply Uses

func (b *Bot) Reply(to *Message, what interface{}, options ...interface{}) (*Message, error)

Reply behaves just like Send() with an exception of "reply-to" indicator.

func (*Bot) Respond Uses

func (b *Bot) Respond(callback *Callback, responseOptional ...*CallbackResponse) error

Respond sends a response for a given callback query. A callback can only be responded to once, subsequent attempts to respond to the same callback will result in an error.

Example:

bot.Respond(c)
bot.Respond(c, response)

func (*Bot) Restrict Uses

func (b *Bot) Restrict(chat *Chat, member *ChatMember) error

Restrict let's you restrict a subset of member's rights until member.RestrictedUntil, such as:

* can send messages
* can send media
* can send other
* can add web page previews

func (*Bot) Send Uses

func (b *Bot) Send(to Recipient, what interface{}, options ...interface{}) (*Message, error)

Send accepts 2+ arguments, starting with destination chat, followed by some Sendable (or string!) and optional send options.

Note: since most arguments are of type interface{}, but have pointer

method recievers, make sure to pass them by-pointer, NOT by-value.

What is a send option exactly? It can be one of the following types:

- *SendOptions (the actual object accepted by Telegram API)
- *ReplyMarkup (a component of SendOptions)
- Option (a shorcut flag for popular options)
- ParseMode (HTML, Markdown, etc)

This function will panic upon unsupported payloads and options!

func (*Bot) SendAlbum Uses

func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Message, error)

SendAlbum is used when sending multiple instances of media as a single message (so-called album).

From all existing options, it only supports telebot.Silent.

func (*Bot) SetGroupDescription Uses

func (b *Bot) SetGroupDescription(chat *Chat, description string) error

SetGroupDescription should be used to update group title.

func (*Bot) SetGroupPhoto Uses

func (b *Bot) SetGroupPhoto(chat *Chat, p *Photo) error

SetGroupPhoto should be used to update group photo.

func (*Bot) SetGroupStickerSet Uses

func (b *Bot) SetGroupStickerSet(chat *Chat, setName string) error

SetGroupStickerSet should be used to update group's group sticker set.

func (*Bot) SetGroupTitle Uses

func (b *Bot) SetGroupTitle(chat *Chat, newTitle string) error

SetChatTitle should be used to update group title.

func (*Bot) Start Uses

func (b *Bot) Start()

Start brings bot into motion by consuming incoming updates (see Bot.Updates channel).

func (*Bot) Stop Uses

func (b *Bot) Stop()

Stop gracefully shuts the poller down.

func (*Bot) StopLiveLocation Uses

func (b *Bot) StopLiveLocation(message Editable, options ...interface{}) (*Message, error)

StopLiveLocation should be called to stop broadcasting live message location before Location.LivePeriod expires.

It supports telebot.ReplyMarkup.

func (*Bot) Unban Uses

func (b *Bot) Unban(chat *Chat, user *User) error

Unban will unban user from chat, who would have thought eh?

func (*Bot) Unpin Uses

func (b *Bot) Unpin(chat *Chat) error

Use this method to unpin a message in a supergroup or a channel.

It supports telebot.Silent option.

type Callback Uses

type Callback struct {
    ID  string `json:"id"`

    // For message sent to channels, Sender may be empty
    Sender *User `json:"from"`

    // Message will be set if the button that originated the query
    // was attached to a message sent by a bot.
    Message *Message `json:"message"`

    // MessageID will be set if the button was attached to a message
    // sent via the bot in inline mode.
    MessageID string `json:"inline_message_id"`

    // Data associated with the callback button. Be aware that
    // a bad client can send arbitrary data in this field.
    Data string `json:"data"`
}

Callback object represents a query from a callback button in an inline keyboard.

type CallbackEndpoint Uses

type CallbackEndpoint interface {
    CallbackUnique() string
}

CallbackEndpoint is an interface any element capable of responding to a callback `\f<unique>`.

type CallbackResponse Uses

type CallbackResponse struct {
    // The ID of the callback to which this is a response.
    //
    // Note: Telebot sets this field automatically!
    CallbackID string `json:"callback_query_id"`

    // Text of the notification. If not specified, nothing will be
    // shown to the user.
    Text string `json:"text,omitempty"`

    // (Optional) If true, an alert will be shown by the client instead
    // of a notification at the top of the chat screen. Defaults to false.
    ShowAlert bool `json:"show_alert,omitempty"`

    // (Optional) URL that will be opened by the user's client.
    // If you have created a Game and accepted the conditions via
    // @BotFather, specify the URL that opens your game.
    //
    // Note: this will only work if the query comes from a game
    // callback button. Otherwise, you may use deep-linking:
    // https://telegram.me/your_bot?start=XXXX
    URL string `json:"url,omitempty"`
}

CallbackResponse builds a response to a Callback query.

See also: https://core.telegram.org/bots/api#answerCallbackQuery

type Chain Uses

type Chain struct {
    MiddlewarePoller

    // (Filter | FilterFunc | func(*Update) bool)
    Filters []interface{}
}

Chain is a chain of middle

func NewChain Uses

func NewChain(parent Poller) *Chain

func (*Chain) Add Uses

func (c *Chain) Add(filter interface{})

Add accepts either Filter interface or FilterFunc

type Chat Uses

type Chat struct {
    ID  int64 `json:"id"`

    // See telebot.ChatType and consts.
    Type ChatType `json:"type"`

    // Won't be there for ChatPrivate.
    Title string `json:"title"`

    FirstName string `json:"first_name"`
    LastName  string `json:"last_name"`
    Username  string `json:"username"`
}

Chat object represents a Telegram user, bot, group or a channel.

func (*Chat) Recipient Uses

func (c *Chat) Recipient() string

Recipient returns chat ID (see Recipient interface).

type ChatAction Uses

type ChatAction string

ChatAction is a client-side status indicating bot activity.

const (
    Typing            ChatAction = "typing"
    UploadingPhoto    ChatAction = "upload_photo"
    UploadingVideo    ChatAction = "upload_video"
    UploadingAudio    ChatAction = "upload_audio"
    UploadingDocument ChatAction = "upload_document"
    UploadingVNote    ChatAction = "upload_video_note"
    RecordingVideo    ChatAction = "record_video"
    RecordingAudio    ChatAction = "record_audio"
    FindingLocation   ChatAction = "find_location"
)

type ChatMember Uses

type ChatMember struct {
    Rights

    User *User        `json:"user"`
    Role MemberStatus `json:"status"`

    // Date when restrictions will be lifted for the user, unix time.
    //
    // If user is restricted for more than 366 days or less than
    // 30 seconds from the current time, they are considered to be
    // restricted forever.
    //
    // Use tb.Forever().
    //
    RestrictedUntil int64 `json:"until_date,omitempty"`
}

ChatMember object represents information about a single chat member.

type ChatType Uses

type ChatType string

ChatType represents one of the possible chat types.

const (
    ChatPrivate        ChatType = "private"
    ChatGroup          ChatType = "group"
    ChatSuperGroup     ChatType = "supergroup"
    ChatChannel        ChatType = "channel"
    ChatChannelPrivate ChatType = "privatechannel"
)

type ChosenInlineResult Uses

type ChosenInlineResult struct {
    ResultID string `json:"result_id"`
    Query    string `json:"query"`
    // Inline messages only!
    MessageID string `json:"inline_message_id"`

    From     User      `json:"from"`
    Location *Location `json:"location,omitempty"`
}

ChosenInlineResult represents a result of an inline query that was chosen by the user and sent to their chat partner.

type Contact Uses

type Contact struct {
    PhoneNumber string `json:"phone_number"`
    FirstName   string `json:"first_name"`

    // (Optional)
    LastName string `json:"last_name"`
    UserID   int    `json:"user_id,omitempty"`
}

Contact object represents a contact to Telegram user

type ContactResult Uses

type ContactResult struct {
    ResultBase

    // Contact's phone number.
    PhoneNumber string `json:"phone_number"`

    // Contact's first name.
    FirstName string `json:"first_name"`

    // Optional. Contact's last name.
    LastName string `json:"last_name,omitempty"`

    // Optional. URL of the thumbnail for the result.
    ThumbURL string `json:"thumb_url,omitempty"`
}

ContentResult represents a contact with a phone number. See also: https://core.telegram.org/bots/api#inlinequeryresultcontact

type Currency Uses

type Currency struct {
    Code         string      `json:"code"`
    Title        string      `json:"title"`
    Symbol       string      `json:"symbol"`
    Native       string      `json:"native"`
    ThousandsSep string      `json:"thousands_sep"`
    DecimalSep   string      `json:"decimal_sep"`
    SymbolLeft   bool        `json:"symbol_left"`
    SpaceBetween bool        `json:"space_between"`
    Exp          int         `json:"exp"`
    MinAmount    interface{} `json:"min_amount"`
    MaxAmount    interface{} `json:"max_amount"`
}

func (Currency) FromTotal Uses

func (c Currency) FromTotal(total int) float64

func (Currency) ToTotal Uses

func (c Currency) ToTotal(total float64) int

type Document Uses

type Document struct {
    File

    // Original filename as defined by sender.
    FileName string `json:"file_name"`

    // (Optional)
    Thumbnail *Photo `json:"thumb,omitempty"`
    Caption   string `json:"caption,omitempty"`
    MIME      string `json:"mime_type"`
}

Document object represents a general file (as opposed to Photo or Audio). Telegram users can send files of any type of up to 1.5 GB in size.

func (*Document) Send Uses

func (d *Document) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type DocumentResult Uses

type DocumentResult struct {
    ResultBase

    // Title for the result.
    Title string `json:"title"`

    // A valid URL for the file
    URL string `json:"document_url"`

    // Mime type of the content of the file, either “application/pdf” or
    // “application/zip”.
    MIME string `json:"mime_type"`

    // Optional. Caption of the document to be sent, 0-200 characters.
    Caption string `json:"caption,omitempty"`

    // Optional. Short description of the result.
    Description string `json:"description,omitempty"`

    // Optional. URL of the thumbnail (jpeg only) for the file.
    ThumbURL string `json:"thumb_url,omitempty"`

    // If Cache != "", it'll be used instead
    Cache string `json:"document_file_id,omitempty"`
}

DocumentResult represents a link to a file. See also: https://core.telegram.org/bots/api#inlinequeryresultdocument

type Editable Uses

type Editable interface {
    // MessageSig is a "message signature".
    //
    // For inline messages, return chatID = 0.
    MessageSig() (messageID string, chatID int64)
}

Editable is an interface for all objects that provide "message signature", a pair of 32-bit message ID and 64-bit chat ID, both required for edit operations.

Use case: DB model struct for messages to-be edited with, say two collums: msg_id,chat_id could easily implement MessageSig() making instances of stored messages editable.

type EntityType Uses

type EntityType string

EntityType is a MessageEntity type.

const (
    EntityMention   EntityType = "mention"
    EntityTMention  EntityType = "text_mention"
    EntityHashtag   EntityType = "hashtag"
    EntityCommand   EntityType = "bot_command"
    EntityURL       EntityType = "url"
    EntityEmail     EntityType = "email"
    EntityBold      EntityType = "bold"
    EntityItalic    EntityType = "italic"
    EntityCode      EntityType = "code"
    EntityCodeBlock EntityType = "pre"
    EntityTextLink  EntityType = "text_link"
)

type File Uses

type File struct {
    FileID   string `json:"file_id"`
    FileSize int    `json:"file_size"`

    // file on telegram server https://core.telegram.org/bots/api#file
    FilePath string `json:"file_path"`

    // file on local file system.
    FileLocal string `json:"file_local"`

    // file on the internet
    FileURL string `json:"file_url"`

    // file backed with io.Reader
    FileReader io.Reader `json:"-"`
}

File object represents any sort of file.

func FromDisk Uses

func FromDisk(filename string) File

FromDisk constructs a new local (on-disk) file object.

Note, it returns File, not *File for a very good reason: in telebot, File is pretty much an embeddable struct, so upon uploading media you'll need to set embedded File with something. NewFile() returning File makes it a one-liner.

photo := &tb.Photo{File: tb.FromDisk("chicken.jpg")}

func FromReader Uses

func FromReader(reader io.Reader) File

FromReader constructs a new file from io.Reader.

Note, it returns File, not *File for a very good reason: in telebot, File is pretty much an embeddable struct, so upon uploading media you'll need to set embedded File with something. NewFile() returning File makes it a one-liner.

photo := &tb.Photo{File: tb.FromReader(bytes.NewReader(...))}

func FromURL Uses

func FromURL(url string) File

FromURL constructs a new file on provided HTTP URL.

Note, it returns File, not *File for a very good reason: in telebot, File is pretty much an embeddable struct, so upon uploading media you'll need to set embedded File with something. NewFile() returning File makes it a one-liner.

photo := &tb.Photo{File: tb.FromURL("https://site.com/picture.jpg")}

func (*File) InCloud Uses

func (f *File) InCloud() bool

InCloud tells whether the file is present on Telegram servers.

func (*File) OnDisk Uses

func (f *File) OnDisk() bool

OnDisk will return true if file is present on disk.

type Filter Uses

type Filter interface {
    Filter(*Update) bool
}

Filter is some thing that does filtering for incoming updates.

Return false if you wish to sieve the update out.

type FilterFunc Uses

type FilterFunc func(*Update) bool

FilterFunc is basically a lightweight version of Filter.

type GifResult Uses

type GifResult struct {
    ResultBase

    // A valid URL for the GIF file. File size must not exceed 1MB.
    URL string `json:"gif_url"`

    // Optional. Width of the GIF.
    Width int `json:"gif_width,omitempty"`

    // Optional. Height of the GIF.
    Height int `json:"gif_height,omitempty"`

    // Optional. Title for the result.
    Title string `json:"title,omitempty"`

    // Optional. Caption of the GIF file to be sent, 0-200 characters.
    Caption string `json:"caption,omitempty"`

    // URL of the static thumbnail for the result (jpeg or gif).
    ThumbURL string `json:"thumb_url"`

    // If Cache != "", it'll be used instead
    Cache string `json:"gif_file_id,omitempty"`
}

GifResult represents a link to an animated GIF file. See also: https://core.telegram.org/bots/api#inlinequeryresultgif

type InlineButton Uses

type InlineButton struct {
    // Unique slagish name for this kind of button,
    // try to be as specific as possible.
    //
    // It will be used as a callback endpoint.
    Unique string `json:"unique,omitempty"`

    Text        string `json:"text"`
    URL         string `json:"url,omitempty"`
    Data        string `json:"callback_data,omitempty"`
    InlineQuery string `json:"switch_inline_query,omitempty"`

    Action func(*Callback) `json:"-"`
}

InlineButton represents a button displayed in the message.

func (*InlineButton) CallbackUnique Uses

func (t *InlineButton) CallbackUnique() string

CallbackUnique returns InlineButto.Unique.

type InlineKeyboardMarkup Uses

type InlineKeyboardMarkup struct {
    // Array of button rows, each represented by
    // an Array of KeyboardButton objects.
    InlineKeyboard [][]InlineButton `json:"inline_keyboard,omitempty"`
}

InlineKeyboardMarkup represents an inline keyboard that appears right next to the message it belongs to.

type InputContactMessageContent Uses

type InputContactMessageContent struct {
    // Contact's phone number.
    PhoneNumber string `json:"phone_number"`

    // Contact's first name.
    FirstName string `json:"first_name"`

    // Optional. Contact's last name.
    LastName string `json:"last_name,omitempty"`
}

InputContactMessageContent represents the content of a contact message to be sent as the result of an inline query. See also: https://core.telegram.org/bots/api#inputcontactmessagecontent

func (*InputContactMessageContent) IsInputMessageContent Uses

func (input *InputContactMessageContent) IsInputMessageContent() bool

type InputLocationMessageContent Uses

type InputLocationMessageContent struct {
    Lat float32 `json:"latitude"`
    Lng float32 `json:"longitude"`
}

InputLocationMessageContent represents the content of a location message to be sent as the result of an inline query. See also: https://core.telegram.org/bots/api#inputlocationmessagecontent

func (*InputLocationMessageContent) IsInputMessageContent Uses

func (input *InputLocationMessageContent) IsInputMessageContent() bool

type InputMedia Uses

type InputMedia interface {
    // As some files must be uploaded (instead of referencing)
    // outer layers of Telebot require it.
    MediaFile() *File
}

InputMedia is a generic type for all kinds of media you can put into an album.

type InputMessageContent Uses

type InputMessageContent interface {
    IsInputMessageContent() bool
}

InputMessageContent objects represent the content of a message to be sent as a result of an inline query. See also: https://core.telegram.org/bots/api#inputmessagecontent

type InputTextMessageContent Uses

type InputTextMessageContent struct {
    // Text of the message to be sent, 1-4096 characters.
    Text string `json:"message_text"`

    // Optional. Send Markdown or HTML, if you want Telegram apps to show
    // bold, italic, fixed-width text or inline URLs in your bot's message.
    ParseMode string `json:"parse_mode,omitempty"`

    // Optional. Disables link previews for links in the sent message.
    DisablePreview bool `json:"disable_web_page_preview"`
}

InputTextMessageContent represents the content of a text message to be sent as the result of an inline query. See also: https://core.telegram.org/bots/api#inputtextmessagecontent

func (*InputTextMessageContent) IsInputMessageContent Uses

func (input *InputTextMessageContent) IsInputMessageContent() bool

type InputVenueMessageContent Uses

type InputVenueMessageContent struct {
    Lat float32 `json:"latitude"`
    Lng float32 `json:"longitude"`

    // Name of the venue.
    Title string `json:"title"`

    // Address of the venue.
    Address string `json:"address"`

    // Optional. Foursquare identifier of the venue, if known.
    FoursquareID string `json:"foursquare_id,omitempty"`
}

InputVenueMessageContent represents the content of a venue message to be sent as the result of an inline query. See also: https://core.telegram.org/bots/api#inputvenuemessagecontent

func (*InputVenueMessageContent) IsInputMessageContent Uses

func (input *InputVenueMessageContent) IsInputMessageContent() bool

type Invoice Uses

type Invoice struct {
    // Product name, 1-32 characters.
    Title string `json:"title"`

    // Product description, 1-255 characters.
    Description string `json:"description"`

    // Custom payload, required, 1-128 bytes.
    Payload string `json:"payload"`

    // Unique deep-linking parameter that can be used to
    // generate this invoice when used as a start parameter.
    Start string `json:"start_parameter"`

    // Provider token to use.
    Token string `json:"provider_token"`

    Currency string `json:"currency"`

    Prices []Price `json:"prices"`
}

func (*Invoice) Send Uses

func (i *Invoice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type Location Uses

type Location struct {
    // Latitude
    Lat float32 `json:"latitude"`
    // Longitude
    Lng float32 `json:"longitude"`

    // Period in seconds for which the location will be updated
    // (see Live Locations, should be between 60 and 86400.)
    LivePeriod int `json:"live_period,omitempty"`
}

Location object represents geographic position.

func (*Location) Send Uses

func (x *Location) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type LocationResult Uses

type LocationResult struct {
    ResultBase

    Location

    // Location title.
    Title string `json:"title"`

    // Optional. Url of the thumbnail for the result.
    ThumbURL string `json:"thumb_url,omitempty"`
}

LocationResult represents a location on a map. See also: https://core.telegram.org/bots/api#inlinequeryresultlocation

type LongPoller Uses

type LongPoller struct {
    Timeout time.Duration

    LastUpdateID int
}

LongPoller is a classic LongPoller with timeout.

func (*LongPoller) Poll Uses

func (p *LongPoller) Poll(b *Bot, dest chan Update, stop chan struct{})

Poll does long polling.

type MaskFeature Uses

type MaskFeature string

MaskFeature defines sticker mask position.

const (
    FeatureForehead MaskFeature = "forehead"
    FeatureEyes     MaskFeature = "eyes"
    FeatureMouth    MaskFeature = "mouth"
    FeatureChin     MaskFeature = "chin"
)

type MaskPosition Uses

type MaskPosition struct {
    Feature MaskFeature `json:"point"`
    XShift  float32     `json:"x_shift"`
    YShift  float32     `json:"y_shift"`
    Scale   float32     `json:"scale"`
}

MaskPosition describes the position on faces where a mask should be placed by default.

type MemberStatus Uses

type MemberStatus string

MemberStatus is one's chat status

const (
    Creator       MemberStatus = "creator"
    Administrator MemberStatus = "administrator"
    Member        MemberStatus = "member"
    Restricted    MemberStatus = "restricted"
    Left          MemberStatus = "left"
    Kicked        MemberStatus = "kicked"
)

type Message Uses

type Message struct {
    ID  int `json:"message_id"`

    // For message sent to channels, Sender will be nil
    Sender *User `json:"from"`

    // Unixtime, use Message.Time() to get time.Time
    Unixtime int64 `json:"date"`

    // Conversation the message belongs to.
    Chat *Chat `json:"chat"`

    // For forwarded messages, sender of the original message.
    OriginalSender *User `json:"forward_from"`

    // For forwarded messages, chat of the original message when
    // forwarded from a channel.
    OriginalChat *Chat `json:"forward_from_chat"`

    // For forwarded messages, unixtime of the original message.
    OriginalUnixtime int `json:"forward_date"`

    // For replies, ReplyTo represents the original message.
    //
    // Note that the Message object in this field will not
    // contain further ReplyTo fields even if it
    // itself is a reply.
    ReplyTo *Message `json:"reply_to_message"`

    // (Optional) Time of last edit in Unix
    LastEdit int64 `json:"edit_date"`

    // AlbumID is the unique identifier of a media message group
    // this message belongs to.
    AlbumID string `json:"media_group_id"`

    // Author signature (in channels).
    Signature string `json:"author_signature"`

    // For a text message, the actual UTF-8 text of the message.
    Text string `json:"text"`

    // For registered commands, will contain the string payload:
    //
    // Ex: `/command <payload>` or `/command@botname <payload>`
    Payload string `json:"-"`

    // For text messages, special entities like usernames, URLs, bot commands,
    // etc. that appear in the text.
    Entities []MessageEntity `json:"entities,omitempty"`

    // Some messages containing media, may as well have a caption.
    Caption string `json:"caption,omitempty"`

    // For messages with a caption, special entities like usernames, URLs,
    // bot commands, etc. that appear in the caption.
    CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`

    // For an audio recording, information about it.
    Audio *Audio `json:"audio"`

    // For a gneral file, information about it.
    Document *Document `json:"document"`

    // For a photo, all available sizes (thumbnails).
    Photo *Photo `json:"photo"`

    // For a sticker, information about it.
    Sticker *Sticker `json:"sticker"`

    // For a voice message, information about it.
    Voice *Voice `json:"voice"`

    // For a video note, information about it.
    VideoNote *VideoNote `json:"video_note"`

    // For a video, information about it.
    Video *Video `json:"video"`

    // For a contact, contact information itself.
    Contact *Contact `json:"contact"`

    // For a location, its longitude and latitude.
    Location *Location `json:"location"`

    // For a venue, information about it.
    Venue *Venue `json:"venue"`

    // For a service message, represents a user,
    // that just got added to chat, this message came from.
    //
    // Sender leads to User, capable of invite.
    //
    // UserJoined might be the Bot itself.
    UserJoined *User `json:"new_chat_member"`

    // For a service message, represents a user,
    // that just left chat, this message came from.
    //
    // If user was kicked, Sender leads to a User,
    // capable of this kick.
    //
    // UserLeft might be the Bot itself.
    UserLeft *User `json:"left_chat_member"`

    // For a service message, represents a new title
    // for chat this message came from.
    //
    // Sender would lead to a User, capable of change.
    NewGroupTitle string `json:"new_chat_title"`

    // For a service message, represents all available
    // thumbnails of the new chat photo.
    //
    // Sender would lead to a User, capable of change.
    NewGroupPhoto *Photo `json:"new_chat_photo"`

    // For a service message, new members that were added to
    // the group or supergroup and information about them
    // (the bot itself may be one of these members).
    UsersJoined []User `json:"new_chat_members"`

    // For a service message, true if chat photo just
    // got removed.
    //
    // Sender would lead to a User, capable of change.
    GroupPhotoDeleted bool `json:"delete_chat_photo"`

    // For a service message, true if group has been created.
    //
    // You would recieve such a message if you are one of
    // initial group chat members.
    //
    // Sender would lead to creator of the chat.
    GroupCreated bool `json:"group_chat_created"`

    // For a service message, true if super group has been created.
    //
    // You would recieve such a message if you are one of
    // initial group chat members.
    //
    // Sender would lead to creator of the chat.
    SuperGroupCreated bool `json:"supergroup_chat_created"`

    // For a service message, true if channel has been created.
    //
    // You would recieve such a message if you are one of
    // initial channel administrators.
    //
    // Sender would lead to creator of the chat.
    ChannelCreated bool `json:"channel_chat_created"`

    // For a service message, the destination (super group) you
    // migrated to.
    //
    // You would recieve such a message when your chat has migrated
    // to a super group.
    //
    // Sender would lead to creator of the migration.
    MigrateTo int64 `json:"migrate_to_chat_id"`

    // For a service message, the Origin (normal group) you migrated
    // from.
    //
    // You would recieve such a message when your chat has migrated
    // to a super group.
    //
    // Sender would lead to creator of the migration.
    MigrateFrom int64 `json:"migrate_from_chat_id"`

    // Specified message was pinned. Note that the Message object
    // in this field will not contain further ReplyTo fields even
    // if it is itself a reply.
    PinnedMessage *Message `json:"pinned_message"`
}

Message object represents a message.

func (*Message) FromChannel Uses

func (m *Message) FromChannel() bool

FromChannel returns true, if message came from a channel.

func (*Message) FromGroup Uses

func (m *Message) FromGroup() bool

FromGroup returns true, if message came from a group OR a super group.

func (*Message) IsForwarded Uses

func (m *Message) IsForwarded() bool

IsForwarded says whether message is forwarded copy of another message or not.

func (*Message) IsReply Uses

func (m *Message) IsReply() bool

IsReply says whether message is a reply to another message.

func (*Message) IsService Uses

func (m *Message) IsService() bool

IsService returns true, if message is a service message, returns false otherwise.

Service messages are automatically sent messages, which typically occur on some global action. For instance, when anyone leaves the chat or chat title changes.

func (*Message) LastEdited Uses

func (m *Message) LastEdited() time.Time

LastEdited returns time.Time of last edit.

func (*Message) MessageSig Uses

func (m *Message) MessageSig() (string, int64)

MessageSig satisfies Editable interface (see Editable.)

func (*Message) Private Uses

func (m *Message) Private() bool

Private returns true, if it's a personal message.

func (*Message) Time Uses

func (m *Message) Time() time.Time

Time returns the moment of message creation in local time.

type MessageEntity Uses

type MessageEntity struct {
    // Specifies entity type.
    Type EntityType `json:"type"`

    // Offset in UTF-16 code units to the start of the entity.
    Offset int `json:"offset"`

    // Length of the entity in UTF-16 code units.
    Length int `json:"length"`

    // (Optional) For EntityTextLink entity type only.
    //
    // URL will be opened after user taps on the text.
    URL string `json:"url,omitempty"`

    // (Optional) For EntityTMention entity type only.
    User *User `json:"user,omitempty"`
}

MessageEntity object represents "special" parts of text messages, including hashtags, usernames, URLs, etc.

type MiddlewarePoller Uses

type MiddlewarePoller struct {
    Capacity int // Default: 1
    Poller   Poller
    Filter   func(*Update) bool
}

MiddlewarePoller is a special kind of poller that acts like a filter for updates. It could be used for spam handling, banning or whatever.

For heavy middleware, use increased capacity.

func NewMiddlewarePoller Uses

func NewMiddlewarePoller(original Poller, filter func(*Update) bool) *MiddlewarePoller

NewMiddlewarePoller wait for it... constructs a new middleware poller.

func (*MiddlewarePoller) Poll Uses

func (p *MiddlewarePoller) Poll(b *Bot, dest chan Update, stop chan struct{})

Poll sieves updates through middleware filter.

type Mpeg4GifResult Uses

type Mpeg4GifResult struct {
    ResultBase

    // A valid URL for the MP4 file.
    URL string `json:"mpeg4_url"`

    // Optional. Video width.
    Width int `json:"mpeg4_width,omitempty"`

    // Optional. Video height.
    Height int `json:"mpeg4_height,omitempty"`

    // URL of the static thumbnail (jpeg or gif) for the result.
    ThumbURL string `json:"thumb_url,omitempty"`

    // Optional. Title for the result.
    Title string `json:"title,omitempty"`

    // Optional. Caption of the MPEG-4 file to be sent, 0-200 characters.
    Caption string `json:"caption,omitempty"`

    // If Cache != "", it'll be used instead
    Cache string `json:"mpeg4_file_id,omitempty"`
}

ResultMpeg4Gif represents a link to a video animation (H.264/MPEG-4 AVC video without sound). See also: https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif

type Option Uses

type Option int

Option is a shorcut flag type for certain message features (so-called options). It means that instead of passing fully-fledged SendOptions* to Send(), you can use these flags instead.

Supported options are defined as iota-constants.

const (
    // NoPreview = SendOptions.DisableWebPagePreview
    NoPreview Option = iota

    // Silent = SendOptions.DisableNotification
    Silent

    // ForceReply = ReplyMarkup.ForceReply
    ForceReply

    // OneTimeKeyboard = ReplyMarkup.OneTimeKeyboard
    OneTimeKeyboard
)

type ParseMode Uses

type ParseMode string

ParseMode determines the way client applications treat the text of the message

const (
    ModeDefault  ParseMode = ""
    ModeMarkdown ParseMode = "Markdown"
    ModeHTML     ParseMode = "HTML"
)

type Photo Uses

type Photo struct {
    File

    Width  int `json:"width"`
    Height int `json:"height"`

    // (Optional)
    Caption string `json:"caption,omitempty"`
}

Photo object represents a single photo file.

func (*Photo) MediaFile Uses

func (p *Photo) MediaFile() *File

MediaFile returns &Photo.File

func (*Photo) Send Uses

func (p *Photo) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

func (*Photo) UnmarshalJSON Uses

func (p *Photo) UnmarshalJSON(jsonStr []byte) error

UnmarshalJSON is custom unmarshaller required to abstract away the hassle of treating different thumbnail sizes. Instead, Telebot chooses the hi-res one and just sticks to it.

I really do find it a beautiful solution.

type PhotoResult Uses

type PhotoResult struct {
    ResultBase

    // A valid URL of the photo. Photo must be in jpeg format.
    // Photo size must not exceed 5MB.
    URL string `json:"photo_url"`

    // Optional. Width of the photo.
    Width int `json:"photo_width,omitempty"`

    // Optional. Height of the photo.
    Height int `json:"photo_height,omitempty"`

    // Optional. Title for the result.
    Title string `json:"title,omitempty"`

    // Optional. Short description of the result.
    Description string `json:"description,omitempty"`

    // Optional. Caption of the photo to be sent, 0-200 characters.
    Caption string `json:"caption,omitempty"`

    // URL of the thumbnail for the photo.
    ThumbURL string `json:"thumb_url"`

    // If Cache != "", it'll be used instead
    Cache string `json:"photo_file_id,omitempty"`
}

ResultResult represents a link to a photo. See also: https://core.telegram.org/bots/api#inlinequeryresultphoto

type Poller Uses

type Poller interface {
    // Poll is supposed to take the bot object
    // subscription channel and start polling
    // for Updates immediately.
    //
    // Poller must listen for stop constantly and close
    // it as soon as it's done polling.
    Poll(b *Bot, updates chan Update, stop chan struct{})
}

Poller is a provider of Updates.

All pollers must implement Poll(), which accepts bot pointer and subscription channel and start polling synchronously straight away.

type PreCheckoutQuery Uses

type PreCheckoutQuery struct {
    ID       string `json:"id"`
    Sender   *User  `json:"from"`
    Currency string `json:"currency"`
    Total    int    `json:"total_amount"`
    Payload  string `json:"invoice_payload"`
}

type Price Uses

type Price struct {
    Label  string `json:"label"`
    Amount int    `json:"amount"`
}

type Query Uses

type Query struct {
    // Unique identifier for this query. 1-64 bytes.
    ID  string `json:"id"`

    // Sender.
    From User `json:"from"`

    // Sender location, only for bots that request user location.
    Location *Location `json:"location"`

    // Text of the query (up to 512 characters).
    Text string `json:"query"`

    // Offset of the results to be returned, can be controlled by the bot.
    Offset string `json:"offset"`
}

Query is an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.

type QueryResponse Uses

type QueryResponse struct {
    // The ID of the query to which this is a response.
    //
    // Note: Telebot sets this field automatically!
    QueryID string `json:"inline_query_id"`

    // The results for the inline query.
    Results Results `json:"results"`

    // (Optional) The maximum amount of time in seconds that the result
    // of the inline query may be cached on the server.
    CacheTime int `json:"cache_time,omitempty"`

    // (Optional) Pass True, if results may be cached on the server side
    // only for the user that sent the query. By default, results may
    // be returned to any user who sends the same query.
    IsPersonal bool `json:"is_personal"`

    // (Optional) Pass the offset that a client should send in the next
    // query with the same text to receive more results. Pass an empty
    // string if there are no more results or if you don‘t support
    // pagination. Offset length can’t exceed 64 bytes.
    NextOffset string `json:"next_offset"`

    // (Optional) If passed, clients will display a button with specified
    // text that switches the user to a private chat with the bot and sends
    // the bot a start message with the parameter switch_pm_parameter.
    SwitchPMText string `json:"switch_pm_text,omitempty"`

    // (Optional) Parameter for the start message sent to the bot when user
    // presses the switch button.
    SwitchPMParameter string `json:"switch_pm_parameter,omitempty"`
}

QueryResponse builds a response to an inline Query. See also: https://core.telegram.org/bots/api#answerinlinequery

type Recipient Uses

type Recipient interface {
    // Must return legit Telegram chat_id or username
    Recipient() string
}

Recipient is any possible endpoint you can send messages to: either user, group or a channel.

type ReplyButton Uses

type ReplyButton struct {
    Text string `json:"text"`

    Contact  bool `json:"request_contact,omitempty"`
    Location bool `json:"request_location,omitempty"`

    Action func(*Callback) `json:"-"`
}

ReplyButton represents a button displayed in reply-keyboard.

Set either Contact or Location to true in order to request sensitive info, such as user's phone number or current location. (Available in private chats only.)

func (*ReplyButton) CallbackUnique Uses

func (t *ReplyButton) CallbackUnique() string

CallbackUnique returns KeyboardButton.Text.

type ReplyMarkup Uses

type ReplyMarkup struct {
    // InlineKeyboard is a grid of InlineButtons displayed in the message.
    //
    // Note: DO NOT confuse with ReplyKeyboard and other keyboard properties!
    InlineKeyboard [][]InlineButton `json:"inline_keyboard,omitempty"`

    // ReplyKeyboard is a grid, consisting of keyboard buttons.
    //
    // Note: you don't need to set HideCustomKeyboard field to show custom keyboard.
    ReplyKeyboard [][]ReplyButton `json:"keyboard,omitempty"`

    // ForceReply forces Telegram clients to display
    // a reply interface to the user (act as if the user
    // has selected the bot‘s message and tapped "Reply").
    ForceReply bool `json:"force_reply,omitempty"`

    // Requests clients to resize the keyboard vertically for optimal fit
    // (e.g. make the keyboard smaller if there are just two rows of buttons).
    //
    // Defaults to false, in which case the custom keyboard is always of the
    // same height as the app's standard keyboard.
    ResizeReplyKeyboard bool `json:"resize_keyboard,omitempty"`

    // Requests clients to hide the reply keyboard as soon as it's been used.
    //
    // Defaults to false.
    OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`

    // Requests clients to remove the reply keyboard.
    //
    // Dafaults to false.
    ReplyKeyboardRemove bool `json:"remove_keyboard,omitempty"`

    // Use this param if you want to force reply from
    // specific users only.
    //
    // Targets:
    // 1) Users that are @mentioned in the text of the Message object;
    // 2) If the bot's message is a reply (has SendOptions.ReplyTo),
    //       sender of the original message.
    Selective bool `json:"selective,omitempty"`
}

ReplyMarkup controls two convenient options for bot-user communications such as reply keyboard and inline "keyboard" (a grid of buttons as a part of the message).

type Result Uses

type Result interface {
    ResultID() string
    SetResultID(string)
    Process()
}

Result represents one result of an inline query.

type ResultBase Uses

type ResultBase struct {
    // Unique identifier for this result, 1-64 Bytes.
    // If left unspecified, a 64-bit FNV-1 hash will be calculated
    ID  string `json:"id"`

    // Ignore. This field gets set automatically.
    Type string `json:"type"`

    // Optional. Content of the message to be sent.
    Content *InputMessageContent `json:"input_message_content,omitempty"`

    // Optional. Inline keyboard attached to the message.
    ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}

ResultBase must be embedded into all IQRs.

func (*ResultBase) Process Uses

func (r *ResultBase) Process()

func (*ResultBase) ResultID Uses

func (r *ResultBase) ResultID() string

ResultID returns ResultBase.ID.

func (*ResultBase) SetResultID Uses

func (r *ResultBase) SetResultID(id string)

SetResultID sets ResultBase.ID.

type Results Uses

type Results []Result

Results is a slice wrapper for convenient marshalling.

func (Results) MarshalJSON Uses

func (results Results) MarshalJSON() ([]byte, error)

MarshalJSON makes sure IQRs have proper IDs and Type variables set.

type Rights Uses

type Rights struct {
    CanBeEdited        bool `json:"can_be_edited,omitempty"`             // 1
    CanChangeInfo      bool `json:"can_change_info,omitempty"`           // 2
    CanPostMessages    bool `json:"can_post_messages,omitempty"`         // 3
    CanEditMessages    bool `json:"can_edit_messages,omitempty"`         // 4
    CanDeleteMessages  bool `json:"can_delete_messages,omitempty"`       // 5
    CanInviteUsers     bool `json:"can_invite_users,omitempty"`          // 6
    CanRestrictMembers bool `json:"can_restrict_members,omitempty"`      // 7
    CanPinMessages     bool `json:"can_pin_messages,omitempty"`          // 8
    CanPromoteMembers  bool `json:"can_promote_members,omitempty"`       // 9
    CanSendMessages    bool `json:"can_send_messages,omitempty"`         // 10
    CanSendMedia       bool `json:"can_send_media_messages,omitempty"`   // 11
    CanSendOther       bool `json:"can_send_other_messages,omitempty"`   // 12
    CanAddPreviews     bool `json:"can_add_web_page_previews,omitempty"` // 13
}

Rights is a list of privileges available to chat members.

func AdminRights Uses

func AdminRights() Rights

AdminRights could be used to promote user to admin.

func NoRestrictions Uses

func NoRestrictions() Rights

NoRestrictions should be used when un-restricting or un-promoting user.

	   member.Rights = NoRestrictions()
    bot.Restrict(chat, member)

func NoRights Uses

func NoRights() Rights

NoRights is the default Rights{}

type SendOptions Uses

type SendOptions struct {
    // If the message is a reply, original message.
    ReplyTo *Message

    // See ReplyMarkup struct definition.
    ReplyMarkup *ReplyMarkup

    // For text messages, disables previews for links in this message.
    DisableWebPagePreview bool

    // Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
    DisableNotification bool

    // ParseMode controls how client apps render your message.
    ParseMode ParseMode
}

SendOptions has most complete control over in what way the message must be sent, providing an API-complete set of custom properties and options.

Despite its power, SendOptions is rather inconvenient to use all the way through bot logic, so you might want to consider storing and re-using it somewhere or be using Option flags instead.

type Sendable Uses

type Sendable interface {
    Send(*Bot, Recipient, *SendOptions) (*Message, error)
}

Sendable is any object that can send itself.

This is pretty cool, since it lets bots implement custom Sendables for complex kind of media or chat objects spanning across multiple messages.

type Settings Uses

type Settings struct {
    // Telegram API Url
    URL string

    // Telegram token
    Token string

    // Updates channel capacity
    Updates int // Default: 100

    // Poller is the provider of Updates.
    Poller Poller

    // Reporter is a callback function that will get called
    // on any panics recovered from endpoint handlers.
    Reporter func(error)

    // HTTP Client used to make requests to telegram api
    Client *http.Client
}

Settings represents a utility struct for passing certain properties of a bot around and is required to make bots.

type Sticker Uses

type Sticker struct {
    File

    Width  int `json:"width"`
    Height int `json:"height"`

    Thumbnail    *Photo        `json:"thumb,omitempty"`
    Emoji        string        `json:"emoji,omitempty"`
    SetName      string        `json:"set_name,omitempty"`
    MaskPosition *MaskPosition `json:"mask_position,omitempty"`
}

Sticker object represents a WebP image, so-called sticker.

func (*Sticker) Send Uses

func (s *Sticker) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type StickerResult Uses

type StickerResult struct {
    ResultBase

    // If Cache != "", it'll be used instead
    Cache string `json:"sticker_file_id,omitempty"`
}

StickerResult represents an inline cached sticker response.

type StoredMessage Uses

type StoredMessage struct {
    MessageID string `sql:"message_id" json:"message_id"`
    ChatID    int64  `sql:"chat_id" json:"chat_id"`
}

StoredMessage is an example struct suitable for being stored in the database as-is or being embedded into a larger struct, which is often the case (you might want to store some metadata alongside, or might not.)

func (StoredMessage) MessageSig Uses

func (x StoredMessage) MessageSig() (string, int64)

type Update Uses

type Update struct {
    ID  int `json:"update_id"`

    Message           *Message  `json:"message,omitempty"`
    EditedMessage     *Message  `json:"edited_message,omitempty"`
    ChannelPost       *Message  `json:"channel_post,omitempty"`
    EditedChannelPost *Message  `json:"edited_channel_post,omitempty"`
    Callback          *Callback `json:"callback_query,omitempty"`
    Query             *Query    `json:"inline_query,omitempty"`

    ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`

    PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
}

Update object represents an incoming update.

type User Uses

type User struct {
    ID  int `json:"id"`

    FirstName    string `json:"first_name"`
    LastName     string `json:"last_name"`
    Username     string `json:"username"`
    LanguageCode string `json:"language_code"`
}

User object represents a Telegram user, bot

func (*User) Recipient Uses

func (u *User) Recipient() string

Recipient returns user ID (see Recipient interface).

type Venue Uses

type Venue struct {
    Location Location `json:"location"`
    Title    string   `json:"title"`
    Address  string   `json:"address"`

    // (Optional)
    FoursquareID   string `json:"foursquare_id,omitempty"`
    FoursquareType string `json:"foursquare_type,omitempty"`
}

Venue object represents a venue location with name, address and optional foursquare ID.

func (*Venue) Send Uses

func (v *Venue) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type VenueResult Uses

type VenueResult struct {
    ResultBase

    Location

    // Title of the venue.
    Title string `json:"title"`

    // Address of the venue.
    Address string `json:"address"`

    // Optional. Foursquare identifier of the venue if known.
    FoursquareID string `json:"foursquare_id,omitempty"`

    // Optional. URL of the thumbnail for the result.
    ThumbURL string `json:"thumb_url,omitempty"`
}

VenueResult represents a venue. See also: https://core.telegram.org/bots/api#inlinequeryresultvenue

type Video Uses

type Video struct {
    File

    Width  int `json:"width"`
    Height int `json:"height"`

    Duration int `json:"duration,omitempty"`

    // (Optional)
    Caption           string `json:"caption,omitempty"`
    Thumbnail         *Photo `json:"thumb,omitempty"`
    SupportsStreaming bool   `json:"supports_streaming,omitempty"`
    MIME              string `json:"mime_type,omitempty"`
}

Video object represents a video file.

func (*Video) MediaFile Uses

func (v *Video) MediaFile() *File

MediaFile returns &Video.File

func (*Video) Send Uses

func (v *Video) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type VideoNote Uses

type VideoNote struct {
    File

    // Duration of the recording in seconds as defined by sender.
    Duration int `json:"duration"`

    // (Optional)
    Thumbnail *Photo `json:"thumb,omitempty"`
    Length    int    `json:"length,omitempty"`
}

VideoNote represents a video message (available in Telegram apps as of v.4.0).

func (*VideoNote) Send Uses

func (v *VideoNote) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type VideoResult Uses

type VideoResult struct {
    ResultBase

    // A valid URL for the embedded video player or video file.
    URL string `json:"video_url"`

    // Mime type of the content of video url, “text/html” or “video/mp4”.
    MIME string `json:"mime_type"`

    // URL of the thumbnail (jpeg only) for the video.
    ThumbURL string `json:"thumb_url"`

    // Title for the result.
    Title string `json:"title"`

    // Optional. Caption of the video to be sent, 0-200 characters.
    Caption string `json:"caption,omitempty"`

    // Optional. Video width.
    Width int `json:"video_width,omitempty"`

    // Optional. Video height.
    Height int `json:"video_height,omitempty"`

    // Optional. Video duration in seconds.
    Duration int `json:"video_duration,omitempty"`

    // Optional. Short description of the result.
    Description string `json:"description,omitempty"`

    // If Cache != "", it'll be used instead
    Cache string `json:"video_file_id,omitempty"`
}

VideoResult represents a link to a page containing an embedded video player or a video file. See also: https://core.telegram.org/bots/api#inlinequeryresultvideo

type Voice Uses

type Voice struct {
    File

    // Duration of the recording in seconds as defined by sender.
    Duration int `json:"duration"`

    // (Optional)
    MIME string `json:"mime_type,omitempty"`
}

Voice object represents a voice note.

func (*Voice) Send Uses

func (v *Voice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)

Send delivers media through bot b to recipient.

type VoiceResult Uses

type VoiceResult struct {
    ResultBase

    // A valid URL for the voice recording.
    URL string `json:"voice_url"`

    // Recording title.
    Title string `json:"title"`

    // Optional. Recording duration in seconds.
    Duration int `json:"voice_duration"`

    // If Cache != "", it'll be used instead
    Cache string `json:"voice_file_id,omitempty"`
}

VoiceResult represents a link to a voice recording in an .ogg container encoded with OPUS.

See also: https://core.telegram.org/bots/api#inlinequeryresultvoice

type Webhook Uses

type Webhook struct {
    Listen   string
    TLS      *WebhookTLS
    Endpoint *WebhookEndpoint
    // contains filtered or unexported fields
}

A Webhook configures the poller for webhooks. It opens a port on the given listen adress. If TLS is filled, the listener will use the key and cert to open a secure port. Otherwise it will use plain HTTP. If you have a loadbalancer ore other infrastructure in front of your service, you must fill the Endpoint structure so this poller will send this data to telegram. If you leave these values empty, your local adress will be sent to telegram which is mostly not what you want (at least while developing). If you have a single instance of your bot you should consider to use the LongPoller instead of a WebHook. You can also leave the Listen field empty. In this case it is up to the caller to add the Webhook to a http-mux.

func (*Webhook) Poll Uses

func (h *Webhook) Poll(b *Bot, dest chan Update, stop chan struct{})

func (*Webhook) ServeHTTP Uses

func (h *Webhook) ServeHTTP(w http.ResponseWriter, r *http.Request)

The handler simply reads the update from the body of the requests and writes them to the update channel.

type WebhookEndpoint Uses

type WebhookEndpoint struct {
    PublicURL string
    Cert      string
}

A WebhookEndpoint describes the endpoint to which telegram will send its requests. This must be a public URL and can be a loadbalancer or something similar. If the endpoint uses TLS and the certificate is selfsigned you have to add the certificate path of this certificate so telegram will trust it. This field can be ignored if you have a trusted certifcate (letsencrypt, ...).

type WebhookTLS Uses

type WebhookTLS struct {
    Key  string
    Cert string
}

A WebhookTLS specifies the path to a key and a cert so the poller can open a TLS listener

Package telebot imports 16 packages (graph) and is imported by 35 packages. Updated 2019-02-13. Refresh now. Tools for package owners.