Documentation ¶
Overview ¶
Package telebot is a framework for Telegram bots.
Example:
package main import ( "time" tele "github.com/teknologi-umum/captcha/internal/telebot" ) func main() { b, err := tele.NewBot(tele.Settings{ Token: "...", Poller: &tele.LongPoller{Timeout: 10 * time.Second}, }) if err != nil { return } b.Handle("/start", func(c tele.Context) error { return c.Send("Hello world!") }) b.Start() }
Index ¶
- Constants
- Variables
- func Err(s string) error
- func Flag(b bool) *bool
- func Forever() int64
- type Album
- type Animation
- type ArticleResult
- type Audio
- type AudioResult
- type AutoDeleteTimer
- type Bot
- func (b *Bot) Accept(ctx context.Context, query *PreCheckoutQuery, errorMessage ...string) error
- func (b *Bot) AddSticker(ctx context.Context, to Recipient, s StickerSet) error
- func (b *Bot) AdminsOf(ctx context.Context, chat *Chat) ([]ChatMember, error)
- func (b *Bot) Answer(ctx context.Context, query *Query, resp *QueryResponse) error
- func (b *Bot) AnswerWebApp(ctx context.Context, query *Query, r Result) (*WebAppMessage, error)
- func (b *Bot) ApproveJoinRequest(ctx context.Context, chat Recipient, user *User) error
- func (b *Bot) Ban(ctx context.Context, chat *Chat, member *ChatMember, revokeMessages ...bool) error
- func (b *Bot) BanSenderChat(ctx context.Context, chat *Chat, sender Recipient) error
- func (b *Bot) ChatByID(ctx context.Context, id int64) (*Chat, error)
- func (b *Bot) ChatByUsername(ctx context.Context, name string) (*Chat, error)
- func (b *Bot) ChatMemberOf(ctx context.Context, chat, user Recipient) (*ChatMember, error)
- func (b *Bot) Close(ctx context.Context) (bool, error)
- func (b *Bot) CloseGeneralTopic(ctx context.Context, chat *Chat) error
- func (b *Bot) CloseTopic(ctx context.Context, chat *Chat, topic *Topic) error
- func (b *Bot) Commands(ctx context.Context, opts ...interface{}) ([]Command, error)
- func (b *Bot) Copy(ctx context.Context, to Recipient, msg Editable, options ...interface{}) (*Message, error)
- func (b *Bot) CreateInviteLink(ctx context.Context, chat Recipient, link *ChatInviteLink) (*ChatInviteLink, error)
- func (b *Bot) CreateInvoiceLink(ctx context.Context, i Invoice) (string, error)
- func (b *Bot) CreateStickerSet(ctx context.Context, to Recipient, s StickerSet) error
- func (b *Bot) CreateTopic(ctx context.Context, chat *Chat, topic *Topic) (*Topic, error)
- func (b *Bot) CustomEmojiStickers(ctx context.Context, ids []string) ([]Sticker, error)
- func (b *Bot) DeclineJoinRequest(ctx context.Context, chat Recipient, user *User) error
- func (b *Bot) DefaultRights(ctx context.Context, forChannels bool) (*Rights, error)
- func (b *Bot) Delete(ctx context.Context, msg Editable) error
- func (b *Bot) DeleteBulk(ctx context.Context, msgs []Editable) error
- func (b *Bot) DeleteCommands(ctx context.Context, opts ...interface{}) error
- func (b *Bot) DeleteGroupPhoto(ctx context.Context, chat *Chat) error
- func (b *Bot) DeleteGroupStickerSet(ctx context.Context, chat *Chat) error
- func (b *Bot) DeleteSticker(ctx context.Context, sticker string) error
- func (b *Bot) DeleteTopic(ctx context.Context, chat *Chat, topic *Topic) error
- func (b *Bot) Download(ctx context.Context, file *File, localFilename string) error
- func (b *Bot) Edit(ctx context.Context, msg Editable, what interface{}, opts ...interface{}) (*Message, error)
- func (b *Bot) EditCaption(ctx context.Context, msg Editable, caption string, opts ...interface{}) (*Message, error)
- func (b *Bot) EditGeneralTopic(ctx context.Context, chat *Chat, topic *Topic) error
- func (b *Bot) EditInviteLink(ctx context.Context, chat Recipient, link *ChatInviteLink) (*ChatInviteLink, error)
- func (b *Bot) EditMedia(ctx context.Context, msg Editable, media Inputtable, opts ...interface{}) (*Message, error)
- func (b *Bot) EditReplyMarkup(ctx context.Context, msg Editable, markup *ReplyMarkup) (*Message, error)
- func (b *Bot) EditTopic(ctx context.Context, chat *Chat, topic *Topic) error
- func (b *Bot) File(ctx context.Context, file *File) (io.ReadCloser, error)
- func (b *Bot) FileByID(ctx context.Context, fileID string) (File, error)
- func (b *Bot) Forward(ctx context.Context, to Recipient, msg Editable, opts ...interface{}) (*Message, error)
- func (b *Bot) GameScores(ctx context.Context, user Recipient, msg Editable) ([]GameHighScore, error)
- func (b *Bot) Group() *Group
- func (b *Bot) Handle(endpoint interface{}, h HandlerFunc, m ...MiddlewareFunc)
- func (b *Bot) HideGeneralTopic(ctx context.Context, chat *Chat) error
- func (b *Bot) InviteLink(ctx context.Context, chat *Chat) (string, error)
- func (b *Bot) Leave(ctx context.Context, chat *Chat) error
- func (b *Bot) Len(ctx context.Context, chat *Chat) (int, error)
- func (b *Bot) Logout(ctx context.Context) (bool, error)
- func (b *Bot) MenuButton(ctx context.Context, chat *User) (*MenuButton, error)
- func (b *Bot) NewContext(u Update) Context
- func (b *Bot) NewMarkup() *ReplyMarkup
- func (b *Bot) Notify(ctx context.Context, to Recipient, action ChatAction, threadID ...int) error
- func (b *Bot) OnError(err error, c Context)
- func (b *Bot) Pin(ctx context.Context, msg Editable, opts ...interface{}) error
- func (b *Bot) ProcessUpdate(u Update)
- func (b *Bot) ProfilePhotosOf(ctx context.Context, user *User) ([]Photo, error)
- func (b *Bot) Promote(ctx context.Context, chat *Chat, member *ChatMember) error
- func (b *Bot) Raw(ctx context.Context, method string, payload interface{}) ([]byte, error)
- func (b *Bot) RemoveWebhook(ctx context.Context, dropPending ...bool) error
- func (b *Bot) ReopenGeneralTopic(ctx context.Context, chat *Chat) error
- func (b *Bot) ReopenTopic(ctx context.Context, chat *Chat, topic *Topic) error
- func (b *Bot) Reply(ctx context.Context, to *Message, what interface{}, opts ...interface{}) (*Message, error)
- func (b *Bot) Respond(ctx context.Context, c *Callback, resp ...*CallbackResponse) error
- func (b *Bot) Restrict(ctx context.Context, chat *Chat, member *ChatMember) error
- func (b *Bot) RevokeInviteLink(ctx context.Context, chat Recipient, link string) (*ChatInviteLink, error)
- func (b *Bot) Send(ctx context.Context, to Recipient, what interface{}, opts ...interface{}) (*Message, error)
- func (b *Bot) SendAlbum(ctx context.Context, to Recipient, a Album, opts ...interface{}) ([]Message, error)
- func (b *Bot) SetAdminTitle(ctx context.Context, chat *Chat, user *User, title string) error
- func (b *Bot) SetCommands(ctx context.Context, opts ...interface{}) error
- func (b *Bot) SetDefaultRights(ctx context.Context, rights Rights, forChannels bool) error
- func (b *Bot) SetGameScore(ctx context.Context, user Recipient, msg Editable, score GameHighScore) (*Message, error)
- func (b *Bot) SetGroupDescription(ctx context.Context, chat *Chat, description string) error
- func (b *Bot) SetGroupPermissions(ctx context.Context, chat *Chat, perms Rights) error
- func (b *Bot) SetGroupPhoto(ctx context.Context, chat *Chat, p *Photo) error
- func (b *Bot) SetGroupStickerSet(ctx context.Context, chat *Chat, setName string) error
- func (b *Bot) SetGroupTitle(ctx context.Context, chat *Chat, title string) error
- func (b *Bot) SetMenuButton(ctx context.Context, chat *User, mb interface{}) error
- func (b *Bot) SetMessageReaction(ctx context.Context, msg Editable, emoji string) error
- func (b *Bot) SetStickerPosition(ctx context.Context, sticker string, position int) error
- func (b *Bot) SetStickerSetThumb(ctx context.Context, to Recipient, s StickerSet) error
- func (b *Bot) SetWebhook(ctx context.Context, w *Webhook) error
- func (b *Bot) Ship(ctx context.Context, query *ShippingQuery, what ...interface{}) error
- func (b *Bot) Start()
- func (b *Bot) StickerSet(ctx context.Context, name string) (*StickerSet, error)
- func (b *Bot) Stop()
- func (b *Bot) StopLiveLocation(ctx context.Context, msg Editable, opts ...interface{}) (*Message, error)
- func (b *Bot) StopPoll(ctx context.Context, msg Editable, opts ...interface{}) (*Poll, error)
- func (b *Bot) TopicIconStickers(ctx context.Context) ([]Sticker, error)
- func (b *Bot) Unban(ctx context.Context, chat *Chat, user *User, forBanned ...bool) error
- func (b *Bot) UnbanSenderChat(ctx context.Context, chat *Chat, sender Recipient) error
- func (b *Bot) UnhideGeneralTopic(ctx context.Context, chat *Chat) error
- func (b *Bot) Unpin(ctx context.Context, chat *Chat, messageID ...int) error
- func (b *Bot) UnpinAll(ctx context.Context, chat *Chat) error
- func (b *Bot) UnpinAllTopicMessages(ctx context.Context, chat *Chat, topic *Topic) error
- func (b *Bot) UploadSticker(ctx context.Context, to Recipient, png *File) (*File, error)
- func (b *Bot) Use(middleware ...MiddlewareFunc)
- func (b *Bot) Webhook(ctx context.Context) (*Webhook, error)
- type Btn
- type Callback
- type CallbackEndpoint
- type CallbackResponse
- type Chat
- type ChatAction
- type ChatID
- type ChatInviteLink
- type ChatJoinRequest
- type ChatLocation
- type ChatMember
- type ChatMemberUpdate
- type ChatPhoto
- type ChatType
- type Command
- type CommandParams
- type CommandScope
- type CommandScopeType
- type Contact
- type ContactResult
- type Context
- type Currency
- type Dice
- type DiceType
- type Document
- type DocumentResult
- type Editable
- type Entities
- type EntityType
- type Error
- type File
- type FloodError
- type Game
- type GameHighScore
- type GifResult
- type Group
- type GroupError
- type HandlerFunc
- type InlineButton
- type InlineResult
- type InputContactMessageContent
- type InputLocationMessageContent
- type InputMedia
- type InputMessageContent
- type InputTextMessageContent
- type InputVenueMessageContent
- type Inputtable
- type Invoice
- type Location
- type LocationResult
- type Login
- type LongPoller
- type M
- type MaskFeature
- type MaskPosition
- type Media
- type MemberStatus
- type MenuButton
- type MenuButtonType
- type Message
- func (m *Message) EntityText(e MessageEntity) string
- func (m *Message) FromChannel() bool
- func (m *Message) FromGroup() bool
- func (m *Message) IsForwarded() bool
- func (m *Message) IsReply() bool
- func (m *Message) IsService() bool
- func (m *Message) LastEdited() time.Time
- func (m *Message) Media() Media
- func (m *Message) MessageSig() (string, int64)
- func (m *Message) Private() bool
- func (m *Message) Time() time.Time
- type MessageEntity
- type MiddlewareFunc
- type MiddlewarePoller
- type Mpeg4GifResult
- type Option
- type Order
- type ParseMode
- type Payment
- type Photo
- type PhotoResult
- type Poll
- type PollAnswer
- type PollOption
- type PollType
- type Poller
- type PreCheckoutQuery
- type Price
- type ProximityAlert
- type Query
- type QueryResponse
- type Recipient
- type RecipientShared
- type ReplyButton
- type ReplyMarkup
- func (r *ReplyMarkup) Chat(text string, chat *ReplyRecipient) Btn
- func (r *ReplyMarkup) Contact(text string) Btn
- func (r *ReplyMarkup) Data(text, unique string, data ...string) Btn
- func (r *ReplyMarkup) Inline(rows ...Row)
- func (r *ReplyMarkup) Location(text string) Btn
- func (r *ReplyMarkup) Login(text string, login *Login) Btn
- func (r *ReplyMarkup) Poll(text string, poll PollType) Btn
- func (r *ReplyMarkup) Query(text, query string) Btn
- func (r *ReplyMarkup) QueryChat(text, query string) Btn
- func (r *ReplyMarkup) Reply(rows ...Row)
- func (r *ReplyMarkup) Row(many ...Btn) Row
- func (r *ReplyMarkup) Split(max int, btns []Btn) []Row
- func (r *ReplyMarkup) Text(text string) Btn
- func (r *ReplyMarkup) URL(text, url string) Btn
- func (r *ReplyMarkup) User(text string, user *ReplyRecipient) Btn
- func (r *ReplyMarkup) WebApp(text string, app *WebApp) Btn
- type ReplyRecipient
- type Result
- type ResultBase
- type Results
- type Rights
- type Row
- type SendOptions
- type Sendable
- type Settings
- type ShippingAddress
- type ShippingOption
- type ShippingQuery
- type Sticker
- type StickerResult
- type StickerSet
- type StickerSetType
- type StoredMessage
- type Topic
- type Update
- type User
- type Venue
- type VenueResult
- type Video
- type VideoChatEnded
- type VideoChatParticipants
- type VideoChatScheduled
- type VideoChatStarted
- type VideoNote
- type VideoResult
- type Voice
- type VoiceResult
- type WebApp
- type WebAppData
- type WebAppMessage
- type Webhook
- type WebhookEndpoint
- type WebhookTLS
- type WriteAccessAllowed
Constants ¶
const ( StickerRegular = "regular" StickerMask = "mask" StickerCustomEmoji = "custom_emoji" )
const ( // Basic message handlers. OnText = "\atext" OnEdited = "\aedited" OnPhoto = "\aphoto" OnAudio = "\aaudio" OnAnimation = "\aanimation" OnDocument = "\adocument" OnSticker = "\asticker" OnVideo = "\avideo" OnVoice = "\avoice" OnVideoNote = "\avideo_note" OnContact = "\acontact" OnLocation = "\alocation" OnVenue = "\avenue" OnDice = "\adice" OnInvoice = "\ainvoice" OnPayment = "\apayment" OnGame = "\agame" OnPoll = "\apoll" OnPollAnswer = "\apoll_answer" OnPinned = "\apinned" OnChannelPost = "\achannel_post" OnEditedChannelPost = "\aedited_channel_post" OnTopicCreated = "\atopic_created" OnTopicReopened = "\atopic_reopened" OnTopicClosed = "\atopic_closed" OnTopicEdited = "\atopic_edited" OnGeneralTopicHidden = "\ageneral_topic_hidden" OnWriteAccessAllowed = "\awrite_access_allowed" OnAddedToGroup = "\aadded_to_group" OnUserJoined = "\auser_joined" OnUserLeft = "\auser_left" OnNewGroupTitle = "\anew_chat_title" OnNewGroupPhoto = "\anew_chat_photo" OnGroupPhotoDeleted = "\achat_photo_deleted" OnGroupCreated = "\agroup_created" OnSuperGroupCreated = "\asupergroup_created" OnChannelCreated = "\achannel_created" // OnMigration happens when group switches to // a supergroup. You might want to update // your internal references to this chat // upon switching as its ID will change. OnMigration = "\amigration" OnMedia = "\amedia" OnCallback = "\acallback" OnQuery = "\aquery" OnInlineResult = "\ainline_result" OnShipping = "\ashipping_query" OnCheckout = "\apre_checkout_query" OnMyChatMember = "\amy_chat_member" OnChatMember = "\achat_member" OnChatJoinRequest = "\achat_join_request" OnProximityAlert = "\aproximity_alert_triggered" OnAutoDeleteTimer = "\amessage_auto_delete_timer_changed" OnWebApp = "\aweb_app" OnVideoChatStarted = "\avideo_chat_started" OnVideoChatEnded = "\avideo_chat_ended" OnVideoChatParticipants = "\avideo_chat_participants_invited" OnVideoChatScheduled = "\avideo_chat_scheduled" )
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 ( ErrTooLarge = NewError(400, "Request Entity Too Large") ErrNotFound = NewError(404, "Not Found") ErrInternal = NewError(500, "Internal Server Error") )
General errors
var ( ErrBadButtonData = NewError(400, "Bad Request: BUTTON_DATA_INVALID") ErrBadUserID = NewError(400, "Bad Request: USER_ID_INVALID") ErrBadPollOptions = NewError(400, "Bad Request: expected an Array of String as options") ErrBadURLContent = NewError(400, "Bad Request: failed to get HTTP URL content") ErrCantEditMessage = NewError(400, "Bad Request: message can't be edited") ErrCantRemoveOwner = NewError(400, "Bad Request: can't remove chat owner") ErrCantUploadFile = NewError(400, "Bad Request: can't upload file by URL") ErrCantUseMediaInAlbum = NewError(400, "Bad Request: can't use the media of the specified type in the album") ErrChatAboutNotModified = NewError(400, "Bad Request: chat description is not modified") ErrChatNotFound = NewError(400, "Bad Request: chat not found") ErrEmptyChatID = NewError(400, "Bad Request: chat_id is empty") ErrEmptyMessage = NewError(400, "Bad Request: message must be non-empty") ErrEmptyText = NewError(400, "Bad Request: text is empty") ErrFailedImageProcess = NewError(400, "Bad Request: IMAGE_PROCESS_FAILED", "Image process failed") ErrGroupMigrated = NewError(400, "Bad Request: group chat was upgraded to a supergroup chat") ErrMessageNotModified = NewError(400, "Bad Request: message is not modified") ErrNoRightsToDelete = NewError(400, "Bad Request: message can't be deleted") ErrNoRightsToRestrict = NewError(400, "Bad Request: not enough rights to restrict/unrestrict chat member") ErrNoRightsToSend = NewError(400, "Bad Request: have no rights to send a message") ErrNoRightsToSendGifs = NewError(400, "Bad Request: CHAT_SEND_GIFS_FORBIDDEN", "sending GIFS is not allowed in this chat") ErrNoRightsToSendPhoto = NewError(400, "Bad Request: not enough rights to send photos to the chat") ErrNoRightsToSendStickers = NewError(400, "Bad Request: not enough rights to send stickers to the chat") ErrNotFoundToDelete = NewError(400, "Bad Request: message to delete not found") ErrNotFoundToForward = NewError(400, "Bad Request: message to forward not found") ErrNotFoundToReply = NewError(400, "Bad Request: reply message not found") ErrQueryTooOld = NewError(400, "Bad Request: query is too old and response timeout expired or query ID is invalid") ErrSameMessageContent = NewError(400, "Bad Request: message is not modified: specified new message content and reply markup are exactly the same as a current content and reply markup of the message") ErrStickerEmojisInvalid = NewError(400, "Bad Request: invalid sticker emojis") ErrStickerSetInvalid = NewError(400, "Bad Request: STICKERSET_INVALID", "Stickerset is invalid") ErrStickerSetInvalidName = NewError(400, "Bad Request: invalid sticker set name is specified") ErrStickerSetNameOccupied = NewError(400, "Bad Request: sticker set name is already occupied") ErrTooLongMarkup = NewError(400, "Bad Request: reply markup is too long") ErrTooLongMessage = NewError(400, "Bad Request: message is too long") ErrUserIsAdmin = NewError(400, "Bad Request: user is an administrator of the chat") ErrWrongFileID = NewError(400, "Bad Request: wrong file identifier/HTTP URL specified") ErrWrongFileIDCharacter = NewError(400, "Bad Request: wrong remote file id specified: Wrong character in the string") ErrWrongFileIDLength = NewError(400, "Bad Request: wrong remote file id specified: Wrong string length") ErrWrongFileIDPadding = NewError(400, "Bad Request: wrong remote file id specified: Wrong padding in the string") ErrWrongFileIDSymbol = NewError(400, "Bad Request: wrong remote file id specified: can't unserialize it. Wrong last symbol") ErrWrongTypeOfContent = NewError(400, "Bad Request: wrong type of the web page content") ErrWrongURL = NewError(400, "Bad Request: wrong HTTP URL specified") ErrForwardMessage = NewError(400, "Bad Request: administrators of the chat restricted message forwarding") ErrUserAlreadyParticipant = NewError(400, "Bad Request: USER_ALREADY_PARTICIPANT", "User is already a participant") ErrHideRequesterMissing = NewError(400, "Bad Request: HIDE_REQUESTER_MISSING") ErrChannelsTooMuch = NewError(400, "Bad Request: CHANNELS_TOO_MUCH") ErrChannelsTooMuchUser = NewError(400, "Bad Request: USER_CHANNELS_TOO_MUCH") )
Bad request errors
var ( ErrBlockedByUser = NewError(403, "Forbidden: bot was blocked by the user") ErrKickedFromGroup = NewError(403, "Forbidden: bot was kicked from the group chat") ErrKickedFromSuperGroup = NewError(403, "Forbidden: bot was kicked from the supergroup chat") ErrKickedFromChannel = NewError(403, "Forbidden: bot was kicked from the channel chat") ErrNotStartedByUser = NewError(403, "Forbidden: bot can't initiate conversation with a user") ErrUserIsDeactivated = NewError(403, "Forbidden: user is deactivated") )
Forbidden errors
var ( Cube = &Dice{Type: "🎲"} Dart = &Dice{Type: "🎯"} Ball = &Dice{Type: "🏀"} Goal = &Dice{Type: "⚽"} Slot = &Dice{Type: "🎰"} Bowl = &Dice{Type: "🎳"} )
var ( ErrBadRecipient = errors.New("telebot: recipient is nil") ErrUnsupportedWhat = errors.New("telebot: unsupported what argument") ErrCouldNotUpdate = errors.New("telebot: could not fetch new updates") ErrTrueResult = errors.New("telebot: result is True") ErrBadContext = errors.New("telebot: context does not contain message") )
var SupportedCurrencies = make(map[string]Currency)
Functions ¶
Types ¶
type Animation ¶
type Animation 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"` MIME string `json:"mime_type,omitempty"` FileName string `json:"file_name,omitempty"` }
Animation object represents a animation file.
func (*Animation) InputMedia ¶
func (a *Animation) InputMedia() InputMedia
type ArticleResult ¶
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"` // Optional. Width of the thumbnail for the result. ThumbWidth int `json:"thumb_width,omitempty"` // Optional. Height of the thumbnail for the result. ThumbHeight int `json:"thumb_height,omitempty"` }
ArticleResult represents a link to an article or web page.
type Audio ¶
type Audio struct { File Duration int `json:"duration,omitempty"` // (Optional) Caption string `json:"caption,omitempty"` Thumbnail *Photo `json:"thumb,omitempty"` Title string `json:"title,omitempty"` Performer string `json:"performer,omitempty"` MIME string `json:"mime_type,omitempty"` FileName string `json:"file_name,omitempty"` }
Audio object represents an audio file.
func (*Audio) InputMedia ¶
func (a *Audio) InputMedia() InputMedia
type AudioResult ¶
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"` // Optional. Caption, 0-1024 characters. Caption string `json:"caption,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 AutoDeleteTimer ¶
type AutoDeleteTimer struct {
Unixtime int `json:"message_auto_delete_time"`
}
AutoDeleteTimer represents a service message about a change in auto-delete timer settings.
type Bot ¶
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 ¶
NewBot does try to build a Bot with token `token`, which is a secret API key assigned to particular bot.
func (*Bot) AddSticker ¶
AddSticker adds a new sticker to the existing sticker set.
func (*Bot) AdminsOf ¶
AdminsOf returns 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 ¶
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) AnswerWebApp ¶
AnswerWebApp sends a response for a query from Web App and returns information about an inline message sent by a Web App on behalf of a user
func (*Bot) ApproveJoinRequest ¶
ApproveJoinRequest approves a chat join request.
func (*Bot) Ban ¶
func (b *Bot) Ban(ctx context.Context, chat *Chat, member *ChatMember, revokeMessages ...bool) error
Ban will ban user from chat until `member.RestrictedUntil`.
func (*Bot) BanSenderChat ¶
BanSenderChat will use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned, the owner of the banned chat won't be able to send messages on behalf of any of their channels.
func (*Bot) ChatByID ¶
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.
func (*Bot) ChatByUsername ¶
ChatByUsername fetches chat info by its username.
func (*Bot) ChatMemberOf ¶
ChatMemberOf returns information about a member of a chat.
func (*Bot) Close ¶
Close closes the bot instance before moving it from one local server to another.
func (*Bot) CloseGeneralTopic ¶
CloseGeneralTopic closes an open 'General' topic in a forum supergroup chat.
func (*Bot) CloseTopic ¶
CloseTopic closes an open topic in a forum supergroup chat.
func (*Bot) Commands ¶
Commands returns the current list of the bot's commands for the given scope and user language.
func (*Bot) Copy ¶
func (b *Bot) Copy(ctx context.Context, to Recipient, msg Editable, options ...interface{}) (*Message, error)
Copy behaves just like Forward() but the copied message doesn't have a link to the original message (see Bots API).
This function will panic upon nil Editable.
func (*Bot) CreateInviteLink ¶
func (b *Bot) CreateInviteLink(ctx context.Context, chat Recipient, link *ChatInviteLink) (*ChatInviteLink, error)
CreateInviteLink creates an additional invite link for a chat.
func (*Bot) CreateInvoiceLink ¶
CreateInvoiceLink creates a link for a payment invoice.
func (*Bot) CreateStickerSet ¶
CreateStickerSet creates a new sticker set.
func (*Bot) CreateTopic ¶
CreateTopic creates a topic in a forum supergroup chat.
func (*Bot) CustomEmojiStickers ¶
CustomEmojiStickers returns the information about custom emoji stickers by their ids.
func (*Bot) DeclineJoinRequest ¶
DeclineJoinRequest declines a chat join request.
func (*Bot) DefaultRights ¶
DefaultRights returns the current default administrator rights of the bot.
func (*Bot) Delete ¶
Delete removes the message, including service messages. This function will panic upon nil Editable.
- A message can only be deleted if it was sent less than 48 hours ago.
- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
- Bots can delete outgoing messages in private chats, groups, and supergroups.
- Bots can delete incoming messages in private chats.
- 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) DeleteCommands ¶
DeleteCommands deletes the list of the bot's commands for the given scope and user language.
func (*Bot) DeleteGroupPhoto ¶
DeleteGroupPhoto should be used to just remove group photo.
func (*Bot) DeleteGroupStickerSet ¶
DeleteGroupStickerSet should be used to just remove group sticker set.
func (*Bot) DeleteSticker ¶
DeleteSticker deletes a sticker from a set created by the bot.
func (*Bot) DeleteTopic ¶
DeleteTopic deletes a forum topic along with all its messages in a forum supergroup chat.
func (*Bot) Download ¶
Download saves the file from Telegram servers locally. Maximum file size to download is 20 MB.
func (*Bot) Edit ¶
func (b *Bot) Edit(ctx context.Context, msg Editable, what interface{}, opts ...interface{}) (*Message, error)
Edit is magic, it lets you change already sent message. This function will panic upon nil Editable.
If edited message is sent by the bot, returns it, otherwise returns nil and ErrTrueResult.
Use cases:
b.Edit(m, m.Text, newMarkup) b.Edit(m, "new <b>text</b>", tele.ModeHTML) b.Edit(m, &tele.ReplyMarkup{...}) b.Edit(m, &tele.Photo{File: ...}) b.Edit(m, tele.Location{42.1337, 69.4242}) b.Edit(c, "edit inline message from the callback") b.Edit(r, "edit message from chosen inline result")
func (*Bot) EditCaption ¶
func (b *Bot) EditCaption(ctx context.Context, msg Editable, caption string, opts ...interface{}) (*Message, error)
EditCaption edits already sent photo caption with known recipient and message id. This function will panic upon nil Editable.
If edited message is sent by the bot, returns it, otherwise returns nil and ErrTrueResult.
func (*Bot) EditGeneralTopic ¶
EditGeneralTopic edits name of the 'General' topic in a forum supergroup chat.
func (*Bot) EditInviteLink ¶
func (b *Bot) EditInviteLink(ctx context.Context, chat Recipient, link *ChatInviteLink) (*ChatInviteLink, error)
EditInviteLink edits a non-primary invite link created by the bot.
func (*Bot) EditMedia ¶
func (b *Bot) EditMedia(ctx context.Context, msg Editable, media Inputtable, opts ...interface{}) (*Message, error)
EditMedia edits already sent media with known recipient and message id. This function will panic upon nil Editable.
If edited message is sent by the bot, returns it, otherwise returns nil and ErrTrueResult.
Use cases:
b.EditMedia(m, &tele.Photo{File: tele.FromDisk("chicken.jpg")}) b.EditMedia(m, &tele.Video{File: tele.FromURL("http://video.mp4")})
func (*Bot) EditReplyMarkup ¶
func (b *Bot) EditReplyMarkup(ctx context.Context, msg Editable, markup *ReplyMarkup) (*Message, error)
EditReplyMarkup edits reply markup of already sent message. This function will panic upon nil Editable. Pass nil or empty ReplyMarkup to delete it from the message.
If edited message is sent by the bot, returns it, otherwise returns nil and ErrTrueResult.
func (*Bot) FileByID ¶
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) Forward ¶
func (b *Bot) Forward(ctx context.Context, to Recipient, msg Editable, opts ...interface{}) (*Message, error)
Forward behaves just like Send() but of all options it only supports Silent (see Bots API). This function will panic upon nil Editable.
func (*Bot) GameScores ¶
func (b *Bot) GameScores(ctx context.Context, user Recipient, msg Editable) ([]GameHighScore, error)
GameScores returns the score of the specified user and several of their neighbors in a game.
This function will panic upon nil Editable.
Currently, it returns scores for the target user, plus two of their closest neighbors on each side. Will also return the top three users if the user and his neighbors are not among them.
func (*Bot) Handle ¶
func (b *Bot) Handle(endpoint interface{}, h HandlerFunc, m ...MiddlewareFunc)
Handle lets you set the handler for some command name or one of the supported endpoints. It also applies middleware if such passed to the function.
Example:
b.Handle("/start", func (c tele.Context) error { return c.Reply("Hello!") }) b.Handle(&inlineButton, func (c tele.Context) error { return c.Respond(&tele.CallbackResponse{Text: "Hello!"}) })
Middleware usage:
b.Handle("/ban", onBan, middleware.Whitelist(ids...))
func (*Bot) HideGeneralTopic ¶
HideGeneralTopic hides the 'General' topic in a forum supergroup chat.
func (*Bot) InviteLink ¶
InviteLink should be used to export chat's invite link.
func (*Bot) Logout ¶
Logout logs out from the cloud Bot API server before launching the bot locally.
func (*Bot) MenuButton ¶
MenuButton returns the current value of the bot's menu button in a private chat, or the default menu button.
func (*Bot) NewContext ¶
NewContext returns a new native context object, field by the passed update.
func (*Bot) NewMarkup ¶
func (b *Bot) NewMarkup() *ReplyMarkup
NewMarkup simply returns newly created markup instance.
func (*Bot) Notify ¶
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 receives 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 ¶
Pin pins a message in a supergroup or a channel.
It supports Silent option. This function will panic upon nil Editable.
func (*Bot) ProcessUpdate ¶
ProcessUpdate processes a single incoming update. A started bot calls this function automatically.
func (*Bot) ProfilePhotosOf ¶
ProfilePhotosOf returns list of profile pictures for a user.
func (*Bot) Promote ¶
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 ¶
Raw lets you call any method of Bot API manually. It also handles API errors, so you only need to unwrap result field from json data.
func (*Bot) RemoveWebhook ¶
RemoveWebhook removes webhook integration.
func (*Bot) ReopenGeneralTopic ¶
ReopenGeneralTopic reopens a closed 'General' topic in a forum supergroup chat.
func (*Bot) ReopenTopic ¶
ReopenTopic reopens a closed topic in a forum supergroup chat.
func (*Bot) Reply ¶
func (b *Bot) Reply(ctx context.Context, to *Message, what interface{}, opts ...interface{}) (*Message, error)
Reply behaves just like Send() with an exception of "reply-to" indicator. This function will panic upon nil Message.
func (*Bot) Respond ¶
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:
b.Respond(c) b.Respond(c, response)
func (*Bot) Restrict ¶
Restrict lets 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) RevokeInviteLink ¶
func (b *Bot) RevokeInviteLink(ctx context.Context, chat Recipient, link string) (*ChatInviteLink, error)
RevokeInviteLink revokes an invite link created by the bot.
func (*Bot) Send ¶
func (b *Bot) Send(ctx context.Context, to Recipient, what interface{}, opts ...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 receivers, 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 shortcut flag for popular options)
- ParseMode (HTML, Markdown, etc)
func (*Bot) SendAlbum ¶
func (b *Bot) SendAlbum(ctx context.Context, to Recipient, a Album, opts ...interface{}) ([]Message, error)
SendAlbum sends multiple instances of media as a single message. To include the caption, make sure the first Inputtable of an album has it. From all existing options, it only supports tele.Silent.
func (*Bot) SetAdminTitle ¶
SetAdminTitle sets a custom title for an administrator. A title should be 0-16 characters length, emoji are not allowed.
func (*Bot) SetCommands ¶
SetCommands changes the list of the bot's commands.
func (*Bot) SetDefaultRights ¶
SetDefaultRights changes the default administrator rights requested by the bot when it's added as an administrator to groups or channels.
func (*Bot) SetGameScore ¶
func (b *Bot) SetGameScore(ctx context.Context, user Recipient, msg Editable, score GameHighScore) (*Message, error)
SetGameScore sets the score of the specified user in a game.
If the message was sent by the bot, returns the edited Message, otherwise returns nil and ErrTrueResult.
func (*Bot) SetGroupDescription ¶
SetGroupDescription should be used to update group description.
func (*Bot) SetGroupPermissions ¶
SetGroupPermissions sets default chat permissions for all members.
func (*Bot) SetGroupPhoto ¶
SetGroupPhoto should be used to update group photo.
func (*Bot) SetGroupStickerSet ¶
SetGroupStickerSet should be used to update group's group sticker set.
func (*Bot) SetGroupTitle ¶
SetGroupTitle should be used to update group title.
func (*Bot) SetMenuButton ¶
SetMenuButton changes the bot's menu button in a private chat, or the default menu button.
It accepts two kinds of menu button arguments:
- MenuButtonType for simple menu buttons (default, commands)
- MenuButton complete structure for web_app menu button type
func (*Bot) SetMessageReaction ¶
func (*Bot) SetStickerPosition ¶
SetStickerPosition moves a sticker in set to a specific position.
func (*Bot) SetStickerSetThumb ¶
SetStickerSetThumb sets a thumbnail of the sticker set. Animated thumbnails can be set for animated sticker sets only.
Thumbnail must be a PNG image, up to 128 kilobytes in size and have width and height exactly 100px, or a TGS animation up to 32 kilobytes in size.
Animated sticker set thumbnail can't be uploaded via HTTP URL.
func (*Bot) SetWebhook ¶
SetWebhook configures a bot to receive incoming updates via an outgoing webhook.
func (*Bot) Ship ¶
func (b *Bot) Ship(ctx context.Context, query *ShippingQuery, what ...interface{}) error
Ship replies to the shipping query, if you sent an invoice requesting an address and the parameter is_flexible was specified.
Example:
b.Ship(query) // OK b.Ship(query, opts...) // OK with options b.Ship(query, "Oops!") // Error message
func (*Bot) Start ¶
func (b *Bot) Start()
Start brings bot into motion by consuming incoming updates (see Bot.Updates channel).
func (*Bot) StickerSet ¶
StickerSet returns a sticker set on success.
func (*Bot) StopLiveLocation ¶
func (b *Bot) StopLiveLocation(ctx context.Context, msg Editable, opts ...interface{}) (*Message, error)
StopLiveLocation stops broadcasting live message location before Location.LivePeriod expires.
It supports ReplyMarkup. This function will panic upon nil Editable.
If the message is sent by the bot, returns it, otherwise returns nil and ErrTrueResult.
func (*Bot) StopPoll ¶
StopPoll stops a poll which was sent by the bot and returns the stopped Poll object with the final results.
It supports ReplyMarkup. This function will panic upon nil Editable.
func (*Bot) TopicIconStickers ¶
TopicIconStickers gets custom emoji stickers, which can be used as a forum topic icon by any user.
func (*Bot) Unban ¶
Unban will unban user from chat, who would have thought eh? forBanned does nothing if the user is not banned.
func (*Bot) UnbanSenderChat ¶
UnbanSenderChat will use this method to unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights.
func (*Bot) UnhideGeneralTopic ¶
UnhideGeneralTopic unhides the 'General' topic in a forum supergroup chat.
func (*Bot) Unpin ¶
Unpin unpins a message in a supergroup or a channel. It supports tb.Silent option.
func (*Bot) UnpinAll ¶
UnpinAll unpins all messages in a supergroup or a channel. It supports tb.Silent option.
func (*Bot) UnpinAllTopicMessages ¶
UnpinAllTopicMessages clears the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
func (*Bot) UploadSticker ¶
UploadSticker uploads a PNG file with a sticker for later use.
func (*Bot) Use ¶
func (b *Bot) Use(middleware ...MiddlewareFunc)
Use adds middleware to the global bot chain.
type Btn ¶
type Btn struct { Unique string `json:"unique,omitempty"` Text string `json:"text,omitempty"` URL string `json:"url,omitempty"` Data string `json:"callback_data,omitempty"` InlineQuery string `json:"switch_inline_query,omitempty"` InlineQueryChat string `json:"switch_inline_query_current_chat,omitempty"` Login *Login `json:"login_url,omitempty"` WebApp *WebApp `json:"web_app,omitempty"` Contact bool `json:"request_contact,omitempty"` Location bool `json:"request_location,omitempty"` Poll PollType `json:"request_poll,omitempty"` User *ReplyRecipient `json:"request_user,omitempty"` Chat *ReplyRecipient `json:"request_chat,omitempty"` }
Btn is a constructor button, which will later become either a reply, or an inline button.
func (*Btn) CallbackUnique ¶
CallbackUnique implements CallbackEndpoint.
func (Btn) Inline ¶
func (b Btn) Inline() *InlineButton
func (Btn) Reply ¶
func (b Btn) Reply() *ReplyButton
type Callback ¶
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"` // Unique displays an unique of the button from which the // callback was fired. Sets immediately before the handling, // while the Data field stores only with payload. Unique string `json:"-"` }
Callback object represents a query from a callback button in an inline keyboard.
func (*Callback) MessageSig ¶
MessageSig satisfies Editable interface.
type CallbackEndpoint ¶
type CallbackEndpoint interface {
CallbackUnique() string
}
CallbackEndpoint is an interface any element capable of responding to a callback `\f<unique>`.
type CallbackResponse ¶
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.
type Chat ¶
type Chat struct { ID int64 `json:"id"` // See 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"` // Returns only in getChat Bio string `json:"bio,omitempty"` Photo *ChatPhoto `json:"photo,omitempty"` Description string `json:"description,omitempty"` InviteLink string `json:"invite_link,omitempty"` PinnedMessage *Message `json:"pinned_message,omitempty"` Permissions *Rights `json:"permissions,omitempty"` SlowMode int `json:"slow_mode_delay,omitempty"` StickerSet string `json:"sticker_set_name,omitempty"` CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` LinkedChatID int64 `json:"linked_chat_id,omitempty"` ChatLocation *ChatLocation `json:"location,omitempty"` Private bool `json:"has_private_forwards,omitempty"` Protected bool `json:"has_protected_content,omitempty"` NoVoiceAndVideo bool `json:"has_restricted_voice_and_video_messages"` HiddenMembers bool `json:"has_hidden_members,omitempty"` AggressiveAntiSpam bool `json:"has_aggressive_anti_spam_enabled,omitempty"` }
Chat object represents a Telegram user, bot, group or a channel.
type ChatAction ¶
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" RecordingVNote ChatAction = "record_video_note" FindingLocation ChatAction = "find_location" ChoosingSticker ChatAction = "choose_sticker" )
type ChatID ¶
type ChatID int64
ChatID represents a chat or an user integer ID, which can be used as recipient in bot methods. It is very useful in cases where you have special group IDs, for example in your config, and don't want to wrap it into *tele.Chat every time you send messages.
Example:
group := tele.ChatID(-100756389456) b.Send(group, "Hello!") type Config struct { AdminGroup tele.ChatID `json:"admin_group"` } b.Send(conf.AdminGroup, "Hello!")
type ChatInviteLink ¶
type ChatInviteLink struct { // The invite link. InviteLink string `json:"invite_link"` // Invite link name. Name string `json:"name"` // The creator of the link. Creator *User `json:"creator"` // If the link is primary. IsPrimary bool `json:"is_primary"` // If the link is revoked. IsRevoked bool `json:"is_revoked"` // (Optional) Point in time when the link will expire, // use ExpireDate() to get time.Time. ExpireUnixtime int64 `json:"expire_date,omitempty"` // (Optional) Maximum number of users that can be members of // the chat simultaneously. MemberLimit int `json:"member_limit,omitempty"` // (Optional) True, if users joining the chat via the link need to // be approved by chat administrators. If True, member_limit can't be specified. JoinRequest bool `json:"creates_join_request"` // (Optional) Number of pending join requests created using this link. PendingCount int `json:"pending_join_request_count"` }
ChatInviteLink object represents an invite for a chat.
func (*ChatInviteLink) ExpireDate ¶
func (c *ChatInviteLink) ExpireDate() time.Time
ExpireDate returns the moment of the link expiration in local time.
type ChatJoinRequest ¶
type ChatJoinRequest struct { // Chat to which the request was sent. Chat *Chat `json:"chat"` // Sender is the user that sent the join request. Sender *User `json:"from"` // UserChatID is an ID of a private chat with the user // who sent the join request. The bot can use this ID // for 5 minutes to send messages until the join request // is processed, assuming no other administrator contacted the user. UserChatID int64 `json:"user_chat_id"` // Unixtime, use ChatJoinRequest.Time() to get time.Time. Unixtime int64 `json:"date"` // Bio of the user, optional. Bio string `json:"bio"` // InviteLink is the chat invite link that was used by //the user to send the join request, optional. InviteLink *ChatInviteLink `json:"invite_link"` }
ChatJoinRequest represents a join request sent to a chat.
func (ChatJoinRequest) Time ¶
func (r ChatJoinRequest) Time() time.Time
Time returns the moment of chat join request sending in local time.
type ChatLocation ¶
type ChatLocation struct { Location Location `json:"location,omitempty"` Address string `json:"address,omitempty"` }
ChatLocation represents a location to which a chat is connected.
type ChatMember ¶
type ChatMember struct { Rights User *User `json:"user"` Role MemberStatus `json:"status"` Title string `json:"custom_title"` Anonymous bool `json:"is_anonymous"` Member bool `json:"is_member,omitempty"` // 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 tele.Forever(). // RestrictedUntil int64 `json:"until_date,omitempty"` JoinToSend string `json:"join_to_send_messages"` JoinByRequest string `json:"join_by_request"` }
ChatMember object represents information about a single chat member.
type ChatMemberUpdate ¶
type ChatMemberUpdate struct { // Chat where the user belongs to. Chat *Chat `json:"chat"` // Sender which user the action was triggered. Sender *User `json:"from"` // Unixtime, use Date() to get time.Time. Unixtime int64 `json:"date"` // Previous information about the chat member. OldChatMember *ChatMember `json:"old_chat_member"` // New information about the chat member. NewChatMember *ChatMember `json:"new_chat_member"` // (Optional) InviteLink which was used by the user to // join the chat; for joining by invite link events only. InviteLink *ChatInviteLink `json:"invite_link"` }
ChatMemberUpdate object represents changes in the status of a chat member.
func (*ChatMemberUpdate) Time ¶
func (c *ChatMemberUpdate) Time() time.Time
Time returns the moment of the change in local time.
type ChatPhoto ¶
type ChatPhoto struct { // File identifiers of small (160x160) chat photo SmallFileID string `json:"small_file_id"` SmallUniqueID string `json:"small_file_unique_id"` // File identifiers of big (640x640) chat photo BigFileID string `json:"big_file_id"` BigUniqueID string `json:"big_file_unique_id"` }
ChatPhoto object represents a chat photo.
type Command ¶
type Command struct { // Text is a text of the command, 1-32 characters. // Can contain only lowercase English letters, digits and underscores. Text string `json:"command"` // Description of the command, 3-256 characters. Description string `json:"description"` }
Command represents a bot command.
type CommandParams ¶
type CommandParams struct { Commands []Command `json:"commands,omitempty"` Scope *CommandScope `json:"scope,omitempty"` LanguageCode string `json:"language_code,omitempty"` }
CommandParams controls parameters for commands-related methods (setMyCommands, deleteMyCommands and getMyCommands).
type CommandScope ¶
type CommandScope struct { Type CommandScopeType `json:"type"` ChatID int64 `json:"chat_id,omitempty"` UserID int64 `json:"user_id,omitempty"` }
CommandScope object represents a scope to which bot commands are applied.
type CommandScopeType ¶
type CommandScopeType = string
const ( CommandScopeDefault CommandScopeType = "default" CommandScopeAllPrivateChats CommandScopeType = "all_private_chats" CommandScopeAllGroupChats CommandScopeType = "all_group_chats" CommandScopeAllChatAdmin CommandScopeType = "all_chat_administrators" CommandScopeChat CommandScopeType = "chat" CommandScopeChatAdmin CommandScopeType = "chat_administrators" CommandScopeChatMember CommandScopeType = "chat_member" )
type Contact ¶
type Contact struct { PhoneNumber string `json:"phone_number"` FirstName string `json:"first_name"` // (Optional) LastName string `json:"last_name"` UserID int64 `json:"user_id,omitempty"` }
Contact object represents a contact to Telegram user.
type ContactResult ¶
type ContactResult struct { ResultBase // Contact's phone number. PhoneNumber string `json:"phone_number"` // Optional. Additional data about the contact in the form of a vCard, 0-2048 bytes. VCard string `json:"vcard,omitempty"` // 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"` // Optional. Width of the thumbnail for the result. ThumbWidth int `json:"thumb_width,omitempty"` // Optional. Height of the thumbnail for the result. ThumbHeight int `json:"thumb_height,omitempty"` }
ContactResult represents a contact with a phone number.
type Context ¶
type Context interface { // Bot returns the bot instance. Bot() *Bot // Update returns the original update. Update() Update // Message returns stored message if such presented. Message() *Message // Callback returns stored callback if such presented. Callback() *Callback // Query returns stored query if such presented. Query() *Query // InlineResult returns stored inline result if such presented. InlineResult() *InlineResult // ShippingQuery returns stored shipping query if such presented. ShippingQuery() *ShippingQuery // PreCheckoutQuery returns stored pre checkout query if such presented. PreCheckoutQuery() *PreCheckoutQuery // Poll returns stored poll if such presented. Poll() *Poll // PollAnswer returns stored poll answer if such presented. PollAnswer() *PollAnswer // ChatMember returns chat member changes. ChatMember() *ChatMemberUpdate // ChatJoinRequest returns the chat join request. ChatJoinRequest() *ChatJoinRequest // Migration returns both migration from and to chat IDs. Migration() (int64, int64) // Topic returns the topic changes. Topic() *Topic // Sender returns the current recipient, depending on the context type. // Returns nil if user is not presented. Sender() *User // Chat returns the current chat, depending on the context type. // Returns nil if chat is not presented. Chat() *Chat // Recipient combines both Sender and Chat functions. If there is no user // the chat will be returned. The native context cannot be without sender, // but it is useful in the case when the context created intentionally // by the NewContext constructor and have only Chat field inside. Recipient() Recipient // Text returns the message text, depending on the context type. // In the case when no related data presented, returns an empty string. Text() string // Entities returns the message entities, whether it's media caption's or the text's. // In the case when no entities presented, returns a nil. Entities() Entities // Data returns the current data, depending on the context type. // If the context contains command, returns its arguments string. // If the context contains payment, returns its payload. // In the case when no related data presented, returns an empty string. Data() string // Args returns a raw slice of command or callback arguments as strings. // The message arguments split by space, while the callback's ones by a "|" symbol. Args() []string // Send sends a message to the current recipient. // See Send from bot.go. Send(ctx context.Context, what interface{}, opts ...interface{}) error // SendAlbum sends an album to the current recipient. // See SendAlbum from bot.go. SendAlbum(ctx context.Context, a Album, opts ...interface{}) error // Reply replies to the current message. // See Reply from bot.go. Reply(ctx context.Context, what interface{}, opts ...interface{}) error // Forward forwards the given message to the current recipient. // See Forward from bot.go. Forward(ctx context.Context, msg Editable, opts ...interface{}) error // ForwardTo forwards the current message to the given recipient. // See Forward from bot.go ForwardTo(ctx context.Context, to Recipient, opts ...interface{}) error // Edit edits the current message. // See Edit from bot.go. Edit(ctx context.Context, what interface{}, opts ...interface{}) error // EditCaption edits the caption of the current message. // See EditCaption from bot.go. EditCaption(ctx context.Context, caption string, opts ...interface{}) error // EditOrSend edits the current message if the update is callback, // otherwise the content is sent to the chat as a separate message. EditOrSend(ctx context.Context, what interface{}, opts ...interface{}) error // EditOrReply edits the current message if the update is callback, // otherwise the content is replied as a separate message. EditOrReply(ctx context.Context, what interface{}, opts ...interface{}) error // Delete removes the current message. // See Delete from bot.go. Delete(ctx context.Context) error // DeleteAfter waits for the duration to elapse and then removes the // message. It handles an error automatically using b.OnError callback. // It returns a Timer that can be used to cancel the call using its Stop method. DeleteAfter(ctx context.Context, d time.Duration) *time.Timer // Notify updates the chat action for the current recipient. // See Notify from bot.go. Notify(ctx context.Context, action ChatAction) error // Ship replies to the current shipping query. // See Ship from bot.go. Ship(ctx context.Context, what ...interface{}) error // Accept finalizes the current deal. // See Accept from bot.go. Accept(ctx context.Context, errorMessage ...string) error // Answer sends a response to the current inline query. // See Answer from bot.go. Answer(ctx context.Context, resp *QueryResponse) error // Respond sends a response for the current callback query. // See Respond from bot.go. Respond(ctx context.Context, resp ...*CallbackResponse) error // Get retrieves data from the context. Get(key string) interface{} // Set saves data in the context. Set(key string, val interface{}) }
Context wraps an update and represents the context of current event.
type Currency ¶
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"` }
Currency contains information about supported currency for payments.
type Dice ¶
Dice object represents a dice with a random value from 1 to 6 for currently supported base emoji.
type Document ¶
type Document struct { File // (Optional) Thumbnail *Photo `json:"thumb,omitempty"` Caption string `json:"caption,omitempty"` MIME string `json:"mime_type"` FileName string `json:"file_name,omitempty"` DisableTypeDetection bool `json:"disable_content_type_detection,omitempty"` }
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) InputMedia ¶
func (d *Document) InputMedia() InputMedia
type DocumentResult ¶
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"` // Optional. Width of the thumbnail for the result. ThumbWidth int `json:"thumb_width,omitempty"` // Optional. Height of the thumbnail for the result. ThumbHeight int `json:"thumb_height,omitempty"` // If Cache != "", it'll be used instead Cache string `json:"document_file_id,omitempty"` }
DocumentResult represents a link to a file.
type Editable ¶
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 columns: msg_id,chat_id could easily implement MessageSig() making instances of stored messages editable.
type Entities ¶
type Entities []MessageEntity
Entities is used to set message's text entities as a send option.
type EntityType ¶
type EntityType string
EntityType is a MessageEntity type.
const ( EntityMention EntityType = "mention" EntityTMention EntityType = "text_mention" EntityHashtag EntityType = "hashtag" EntityCashtag EntityType = "cashtag" EntityCommand EntityType = "bot_command" EntityURL EntityType = "url" EntityEmail EntityType = "email" EntityPhone EntityType = "phone_number" EntityBold EntityType = "bold" EntityItalic EntityType = "italic" EntityUnderline EntityType = "underline" EntityStrikethrough EntityType = "strikethrough" EntityCode EntityType = "code" EntityCodeBlock EntityType = "pre" EntityTextLink EntityType = "text_link" EntitySpoiler EntityType = "spoiler" EntityCustomEmoji EntityType = "custom_emoji" )
type Error ¶
type File ¶
type File struct { FileID string `json:"file_id"` UniqueID string `json:"file_unique_id"` FileSize int64 `json:"file_size"` // FilePath is used for files on Telegram server. FilePath string `json:"file_path"` // FileLocal is used for files on local file system. FileLocal string `json:"file_local"` // FileURL is used for file on the internet. FileURL string `json:"file_url"` // FileReader is used for file backed with io.Reader. FileReader io.Reader `json:"-"` // contains filtered or unexported fields }
File object represents any sort of file.
func FromDisk ¶
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 := &tele.Photo{File: tele.FromDisk("chicken.jpg")}
func FromReader ¶
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 := &tele.Photo{File: tele.FromReader(bytes.NewReader(...))}
func FromURL ¶
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 := &tele.Photo{File: tele.FromURL("https://site.com/picture.jpg")}
type FloodError ¶
type FloodError struct { RetryAfter int // contains filtered or unexported fields }
type Game ¶
type Game struct { Name string `json:"game_short_name"` Title string `json:"title"` Description string `json:"description"` Photo *Photo `json:"photo"` // (Optional) Text string `json:"text"` Entities []MessageEntity `json:"text_entities"` Animation *Animation `json:"animation"` }
Game object represents a game. Their short names acts as unique identifiers.
type GameHighScore ¶
type GameHighScore struct { User *User `json:"user"` Position int `json:"position"` Score int `json:"score"` Force bool `json:"force"` NoEdit bool `json:"disable_edit_message"` }
GameHighScore object represents one row of the high scores table for a game.
type GifResult ¶
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. Duration of the GIF. Duration int `json:"gif_duration,omitempty"` // URL of the static thumbnail for the result (jpeg or gif). ThumbURL string `json:"thumb_url"` // Optional. MIME type of the thumbnail, must be one of // “image/jpeg”, “image/gif”, or “video/mp4”. ThumbMIME string `json:"thumb_mime_type,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"` // If Cache != "", it'll be used instead Cache string `json:"gif_file_id,omitempty"` }
GifResult represents a link to an animated GIF file.
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a separated group of handlers, united by the general middleware.
func (*Group) Handle ¶
func (g *Group) Handle(endpoint interface{}, h HandlerFunc, m ...MiddlewareFunc)
Handle adds endpoint handler to the bot, combining group's middleware with the optional given middleware.
func (*Group) Use ¶
func (g *Group) Use(middleware ...MiddlewareFunc)
Use adds middleware to the chain.
type GroupError ¶
type GroupError struct { MigratedTo int64 // contains filtered or unexported fields }
type HandlerFunc ¶
HandlerFunc represents a handler function, which is used to handle actual endpoints.
type InlineButton ¶
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"` InlineQueryChat string `json:"switch_inline_query_current_chat"` Login *Login `json:"login_url,omitempty"` WebApp *WebApp `json:"web_app,omitempty"` }
InlineButton represents a button displayed in the message.
func (*InlineButton) CallbackUnique ¶
func (t *InlineButton) CallbackUnique() string
CallbackUnique returns InlineButton.Unique.
func (*InlineButton) MarshalJSON ¶
func (t *InlineButton) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface. It needed to avoid InlineQueryChat and Login or WebApp fields conflict. If you have Login or WebApp field in your button, InlineQueryChat must be skipped.
func (*InlineButton) With ¶
func (t *InlineButton) With(data string) *InlineButton
With returns a copy of the button with data.
type InlineResult ¶
type InlineResult struct { Sender *User `json:"from"` Location *Location `json:"location,omitempty"` ResultID string `json:"result_id"` Query string `json:"query"` MessageID string `json:"inline_message_id"` // inline messages only! }
InlineResult represents a result of an inline query that was chosen by the user and sent to their chat partner.
func (*InlineResult) MessageSig ¶
func (ir *InlineResult) MessageSig() (string, int64)
MessageSig satisfies Editable interface.
type InputContactMessageContent ¶
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.
func (*InputContactMessageContent) IsInputMessageContent ¶
func (input *InputContactMessageContent) IsInputMessageContent() bool
type InputLocationMessageContent ¶
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.
func (*InputLocationMessageContent) IsInputMessageContent ¶
func (input *InputLocationMessageContent) IsInputMessageContent() bool
type InputMedia ¶
type InputMedia struct { Type string `json:"type"` Media string `json:"media"` Caption string `json:"caption"` Thumbnail string `json:"thumb,omitempty"` ParseMode string `json:"parse_mode,omitempty"` Entities Entities `json:"caption_entities,omitempty"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` Duration int `json:"duration,omitempty"` Title string `json:"title,omitempty"` Performer string `json:"performer,omitempty"` Streaming bool `json:"supports_streaming,omitempty"` DisableTypeDetection bool `json:"disable_content_type_detection,omitempty"` HasSpoiler bool `json:"is_spoiler,omitempty"` }
InputMedia represents a composite InputMedia struct that is used by Telebot in sending and editing media methods.
type InputMessageContent ¶
type InputMessageContent interface {
IsInputMessageContent() bool
}
InputMessageContent objects represent the content of a message to be sent as a result of an inline query.
type InputTextMessageContent ¶
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.
func (*InputTextMessageContent) IsInputMessageContent ¶
func (input *InputTextMessageContent) IsInputMessageContent() bool
type InputVenueMessageContent ¶
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.
func (*InputVenueMessageContent) IsInputMessageContent ¶
func (input *InputVenueMessageContent) IsInputMessageContent() bool
type Inputtable ¶
type Inputtable interface { Media // InputMedia returns already marshalled InputMedia type // ready to be used in sending and editing media methods. InputMedia() InputMedia }
Inputtable is a generic type for all kinds of media you can put into an album.
type Invoice ¶
type Invoice struct { Title string `json:"title"` Description string `json:"description"` Payload string `json:"payload"` Currency string `json:"currency"` Prices []Price `json:"prices"` Token string `json:"provider_token"` Data string `json:"provider_data"` Photo *Photo `json:"photo"` PhotoSize int `json:"photo_size"` // Unique deep-linking parameter that can be used to // generate this invoice when used as a start parameter (0). Start string `json:"start_parameter"` // Shows the total price in the smallest units of the currency. // For example, for a price of US$ 1.45 pass amount = 145. Total int `json:"total_amount"` MaxTipAmount int `json:"max_tip_amount"` SuggestedTipAmounts []int `json:"suggested_tip_amounts"` NeedName bool `json:"need_name"` NeedPhoneNumber bool `json:"need_phone_number"` NeedEmail bool `json:"need_email"` NeedShippingAddress bool `json:"need_shipping_address"` SendPhoneNumber bool `json:"send_phone_number_to_provider"` SendEmail bool `json:"send_email_to_provider"` Flexible bool `json:"is_flexible"` }
Invoice contains basic information about an invoice.
type Location ¶
type Location struct { Lat float32 `json:"latitude"` Lng float32 `json:"longitude"` HorizontalAccuracy *float32 `json:"horizontal_accuracy,omitempty"` Heading int `json:"heading,omitempty"` AlertRadius int `json:"proximity_alert_radius,omitempty"` // 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.
type LocationResult ¶
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.
type Login ¶
type Login struct { URL string `json:"url"` Text string `json:"forward_text,omitempty"` Username string `json:"bot_username,omitempty"` WriteAccess bool `json:"request_write_access,omitempty"` }
Login represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram.
type LongPoller ¶
type LongPoller struct { Limit int Timeout time.Duration LastUpdateID int // AllowedUpdates contains the update types // you want your bot to receive. // // Possible values: // message // edited_message // channel_post // edited_channel_post // inline_query // chosen_inline_result // callback_query // shipping_query // pre_checkout_query // poll // poll_answer // AllowedUpdates []string `yaml:"allowed_updates"` }
LongPoller is a classic LongPoller with timeout.
type M ¶
type M = map[string]interface{}
M is a shortcut for map[string]interface{}. Useful for passing arguments to the layout functions.
type MaskFeature ¶
type MaskFeature string
MaskFeature defines sticker mask position.
const ( FeatureForehead MaskFeature = "forehead" FeatureEyes MaskFeature = "eyes" FeatureMouth MaskFeature = "mouth" FeatureChin MaskFeature = "chin" )
type MaskPosition ¶
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 Media ¶
type Media interface { // MediaType returns string-represented media type. MediaType() string // MediaFile returns a pointer to the media file. MediaFile() *File }
Media is a generic type for all kinds of media that includes File.
type MemberStatus ¶
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 MenuButton ¶
type MenuButton struct { Type MenuButtonType `json:"type"` Text string `json:"text,omitempty"` WebApp *WebApp `json:"web_app,omitempty"` }
MenuButton describes the bot's menu button in a private chat.
type MenuButtonType ¶
type MenuButtonType = string
const ( MenuButtonDefault MenuButtonType = "default" MenuButtonCommands MenuButtonType = "commands" MenuButtonWebApp MenuButtonType = "web_app" )
type Message ¶
type Message struct { ID int `json:"message_id"` // (Optional) Unique identifier of a message thread to which the message belongs; for supergroups only ThreadID int `json:"message_thread_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"` // Sender of the message, sent on behalf of a chat. SenderChat *Chat `json:"sender_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, identifier of the original message // when forwarded from a channel. OriginalMessageID int `json:"forward_from_message_id"` // For forwarded messages, signature of the post author. OriginalSignature string `json:"forward_signature"` // For forwarded messages, sender's name from users who // disallow adding a link to their account. OriginalSenderName string `json:"forward_sender_name"` // For forwarded messages, unixtime of the original message. OriginalUnixtime int `json:"forward_date"` // Message is a channel post that was automatically forwarded to the connected discussion group. AutomaticForward bool `json:"is_automatic_forward"` // 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"` // Shows through which bot the message was sent. Via *User `json:"via_bot"` // (Optional) Time of last edit in Unix. LastEdit int64 `json:"edit_date"` // (Optional) True, if the message is sent to a forum topic. TopicMessage bool `json:"is_topic_message"` // (Optional) Message can't be forwarded. Protected bool `json:"has_protected_content,omitempty"` // 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 Entities `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 Entities `json:"caption_entities,omitempty"` // For an audio recording, information about it. Audio *Audio `json:"audio"` // For a general 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 animation, information about it. Animation *Animation `json:"animation"` // 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 poll, information the native poll. Poll *Poll `json:"poll"` // For a game, information about it. Game *Game `json:"game"` // For a dice, information about it. Dice *Dice `json:"dice"` // 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 receive 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 supergroup has been created. // // You would receive 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 receive 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 (supergroup) you // migrated to. // // You would receive such a message when your chat has migrated // to a supergroup. // // 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 receive such a message when your chat has migrated // to a supergroup. // // 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 is an invoice for a payment. Invoice *Invoice `json:"invoice"` // Message is a service message about a successful payment. Payment *Payment `json:"successful_payment"` UserShared *RecipientShared `json:"user_shared,omitempty"` ChatShared *RecipientShared `json:"chat_shared,omitempty"` // The domain name of the website on which the user has logged in. ConnectedWebsite string `json:"connected_website,omitempty"` // For a service message, a video chat started in the chat. VideoChatStarted *VideoChatStarted `json:"video_chat_started,omitempty"` // For a service message, a video chat ended in the chat. VideoChatEnded *VideoChatEnded `json:"video_chat_ended,omitempty"` // For a service message, some users were invited in the video chat. VideoChatParticipants *VideoChatParticipants `json:"video_chat_participants_invited,omitempty"` // For a service message, a video chat schedule in the chat. VideoChatScheduled *VideoChatScheduled `json:"video_chat_scheduled,omitempty"` // For a data sent by a Web App. WebAppData *WebAppData `json:"web_app_data,omitempty"` // For a service message, represents the content of a service message, // sent whenever a user in the chat triggers a proximity alert set by another user. ProximityAlert *ProximityAlert `json:"proximity_alert_triggered,omitempty"` // For a service message, represents about a change in auto-delete timer settings. AutoDeleteTimer *AutoDeleteTimer `json:"message_auto_delete_timer_changed,omitempty"` // Inline keyboard attached to the message. ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"` // Service message: forum topic created TopicCreated *Topic `json:"forum_topic_created,omitempty"` // Service message: forum topic closed TopicClosed *struct{} `json:"forum_topic_closed,omitempty"` // Service message: forum topic reopened TopicReopened *Topic `json:"forum_topic_reopened,omitempty"` // Service message: forum topic deleted TopicEdited *Topic `json:"forum_topic_edited,omitempty"` // Service message: general forum topic hidden GeneralTopicHidden *struct{} `json:"general_topic_hidden,omitempty"` GeneralTopicUnhidden *struct{} `json:"general_topic_unhidden,omitempty"` // Service message: represents spoiler information about the message. HasMediaSpoiler bool `json:"has_media_spoiler,omitempty"` // Service message: the user allowed the bot added to the attachment menu to write messages WriteAccessAllowed *WriteAccessAllowed `json:"write_access_allowed,omitempty"` }
Message object represents a message.
func (*Message) EntityText ¶
func (m *Message) EntityText(e MessageEntity) string
EntityText returns the substring of the message identified by the given MessageEntity.
It's safer than manually slicing Text because Telegram uses UTF-16 indices whereas Go string are []byte.
func (*Message) FromChannel ¶
FromChannel returns true, if message came from a channel.
func (*Message) IsForwarded ¶
IsForwarded says whether message is forwarded copy of another message or not.
func (*Message) IsService ¶
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 ¶
LastEdited returns time.Time of last edit.
func (*Message) Media ¶
Media returns the message's media if it contains either photo, voice, audio, animation, sticker, document, video or video note.
func (*Message) MessageSig ¶
MessageSig satisfies Editable interface (see Editable.)
type MessageEntity ¶
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"` // (Optional) For EntityCodeBlock entity type only. Language string `json:"language,omitempty"` // (Optional) For EntityCustomEmoji entity type only. CustomEmoji string `json:"custom_emoji_id"` }
MessageEntity object represents "special" parts of text messages, including hashtags, usernames, URLs, etc.
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc represents a middleware processing function, which get called before the endpoint group or specific handler.
type MiddlewarePoller ¶
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 ¶
func NewMiddlewarePoller(original Poller, filter func(*Update) bool) *MiddlewarePoller
NewMiddlewarePoller wait for it... constructs a new middleware poller.
type Mpeg4GifResult ¶
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"` // Optional. Video duration. Duration int `json:"mpeg4_duration,omitempty"` // URL of the static thumbnail (jpeg or gif) for the result. ThumbURL string `json:"thumb_url,omitempty"` // Optional. MIME type of the thumbnail, must be one of // “image/jpeg”, “image/gif”, or “video/mp4”. ThumbMIME string `json:"thumb_mime_type,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"` }
Mpeg4GifResult represents a link to a video animation (H.264/MPEG-4 AVC video without sound).
type Option ¶
type Option int
Option is a shortcut 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 // AllowWithoutReply = SendOptions.AllowWithoutReply AllowWithoutReply // Protected = SendOptions.Protected Protected // ForceReply = ReplyMarkup.ForceReply ForceReply // OneTimeKeyboard = ReplyMarkup.OneTimeKeyboard OneTimeKeyboard // RemoveKeyboard = ReplyMarkup.RemoveKeyboard RemoveKeyboard )
type Order ¶
type Order struct { Name string `json:"name"` PhoneNumber string `json:"phone_number"` Email string `json:"email"` Address ShippingAddress `json:"shipping_address"` }
Order represents information about an order.
type ParseMode ¶
type ParseMode = string
ParseMode determines the way client applications treat the text of the message
type Payment ¶
type Payment struct { Currency string `json:"currency"` Total int `json:"total_amount"` Payload string `json:"invoice_payload"` OptionID string `json:"shipping_option_id"` Order Order `json:"order_info"` TelegramChargeID string `json:"telegram_payment_charge_id"` ProviderChargeID string `json:"provider_payment_charge_id"` }
Payment contains basic information about a successful payment.
type Photo ¶
type Photo struct { File Width int `json:"width"` Height int `json:"height"` Caption string `json:"caption,omitempty"` }
Photo object represents a single photo file.
func (*Photo) InputMedia ¶
func (p *Photo) InputMedia() InputMedia
func (*Photo) UnmarshalJSON ¶
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 ¶
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"` }
PhotoResult represents a link to a photo.
type Poll ¶
type Poll struct { ID string `json:"id"` Type PollType `json:"type"` Question string `json:"question"` Options []PollOption `json:"options"` VoterCount int `json:"total_voter_count"` // (Optional) Closed bool `json:"is_closed,omitempty"` CorrectOption int `json:"correct_option_id,omitempty"` MultipleAnswers bool `json:"allows_multiple_answers,omitempty"` Explanation string `json:"explanation,omitempty"` ParseMode ParseMode `json:"explanation_parse_mode,omitempty"` Entities []MessageEntity `json:"explanation_entities"` // True by default, shouldn't be omitted. Anonymous bool `json:"is_anonymous"` // (Mutually exclusive) OpenPeriod int `json:"open_period,omitempty"` CloseUnixdate int64 `json:"close_date,omitempty"` }
Poll contains information about a poll.
func (*Poll) AddOptions ¶
AddOptions adds text options to the poll.
type PollAnswer ¶
type PollAnswer struct { PollID string `json:"poll_id"` Sender *User `json:"user"` Options []int `json:"option_ids"` }
PollAnswer represents an answer of a user in a non-anonymous poll.
type PollOption ¶
PollOption contains information about one answer option in a poll.
type PollType ¶
type PollType string
PollType defines poll types.
func (PollType) MarshalJSON ¶
MarshalJSON implements json.Marshaler. It allows passing PollType as a keyboard's poll type instead of KeyboardButtonPollType object.
type Poller ¶
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(ctx context.Context, 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 ¶
type PreCheckoutQuery struct { Sender *User `json:"from"` ID string `json:"id"` Currency string `json:"currency"` Payload string `json:"invoice_payload"` Total int `json:"total_amount"` OptionID string `json:"shipping_option_id"` Order Order `json:"order_info"` }
PreCheckoutQuery contains information about an incoming pre-checkout query.
type ProximityAlert ¶
type ProximityAlert struct { Traveler *User `json:"traveler,omitempty"` Watcher *User `json:"watcher,omitempty"` Distance int `json:"distance"` }
ProximityAlert sent whenever a user in the chat triggers a proximity alert set by another user.
type Query ¶
type Query struct { // Unique identifier for this query. 1-64 bytes. ID string `json:"id"` // Sender. Sender *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"` // ChatType of the type of the chat, from which the inline query was sent. ChatType string `json:"chat_type"` }
Query is an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
type QueryResponse ¶
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.
type Recipient ¶
type Recipient interface {
Recipient() string // must return legit Telegram chat_id or username
}
Recipient is any possible endpoint you can send messages to: either user, group or a channel.
type RecipientShared ¶
type RecipientShared struct {}
RecipientShared combines both UserShared and ChatShared objects.
type ReplyButton ¶
type ReplyButton struct { Text string `json:"text"` Contact bool `json:"request_contact,omitempty"` Location bool `json:"request_location,omitempty"` Poll PollType `json:"request_poll,omitempty"` User *ReplyRecipient `json:"request_user,omitempty"` Chat *ReplyRecipient `json:"request_chat,omitempty"` WebApp *WebApp `json:"web_app,omitempty"` }
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.
func (*ReplyButton) CallbackUnique ¶
func (t *ReplyButton) CallbackUnique() string
CallbackUnique returns ReplyButton.Text.
type ReplyMarkup ¶
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. ResizeKeyboard 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. // // Defaults to false. RemoveKeyboard 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"` // Placeholder will be shown in the input field when the reply is active. Placeholder string `json:"input_field_placeholder,omitempty"` // IsPersistent allows to control when the keyboard is shown. IsPersistent bool `json:"is_persistent,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).
func (*ReplyMarkup) Chat ¶
func (r *ReplyMarkup) Chat(text string, chat *ReplyRecipient) Btn
func (*ReplyMarkup) Contact ¶
func (r *ReplyMarkup) Contact(text string) Btn
func (*ReplyMarkup) Inline ¶
func (r *ReplyMarkup) Inline(rows ...Row)
func (*ReplyMarkup) Location ¶
func (r *ReplyMarkup) Location(text string) Btn
func (*ReplyMarkup) Query ¶
func (r *ReplyMarkup) Query(text, query string) Btn
func (*ReplyMarkup) QueryChat ¶
func (r *ReplyMarkup) QueryChat(text, query string) Btn
func (*ReplyMarkup) Reply ¶
func (r *ReplyMarkup) Reply(rows ...Row)
func (*ReplyMarkup) Split ¶
func (r *ReplyMarkup) Split(max int, btns []Btn) []Row
Split splits the keyboard into the rows with N maximum number of buttons. For example, if you pass six buttons and 3 as the max, you get two rows with three buttons in each.
`Split(3, []Btn{six buttons...}) -> [[1, 2, 3], [4, 5, 6]]` `Split(2, []Btn{six buttons...}) -> [[1, 2],[3, 4],[5, 6]]`
func (*ReplyMarkup) Text ¶
func (r *ReplyMarkup) Text(text string) Btn
func (*ReplyMarkup) URL ¶
func (r *ReplyMarkup) URL(text, url string) Btn
func (*ReplyMarkup) User ¶
func (r *ReplyMarkup) User(text string, user *ReplyRecipient) Btn
type ReplyRecipient ¶
type ReplyRecipient struct { ID int32 `json:"request_id"` Bot *bool `json:"user_is_bot,omitempty"` // user only, optional Premium *bool `json:"user_is_premium,omitempty"` // user only, optional Channel bool `json:"chat_is_channel,omitempty"` // chat only, required Forum *bool `json:"chat_is_forum,omitempty"` // chat only, optional WithUsername *bool `json:"chat_has_username,omitempty"` // chat only, optional Created *bool `json:"chat_is_created,omitempty"` // chat only, optional UserRights *Rights `json:"user_administrator_rights,omitempty"` // chat only, optional BotRights *Rights `json:"bot_administrator_rights,omitempty"` // chat only, optional BotMember *bool `json:"bot_is_member,omitempty"` // chat only, optional }
ReplyRecipient combines both KeyboardButtonRequestUser and KeyboardButtonRequestChat objects. Use inside ReplyButton to request the user or chat sharing with respective settings.
To pass the pointers to bool use a special tele.Flag function, that way you will be able to reflect the three-state bool (nil, false, true).
type Result ¶
type Result interface { ResultID() string SetResultID(string) SetParseMode(ParseMode) SetContent(InputMessageContent) SetReplyMarkup(*ReplyMarkup) Process(*Bot) }
Result represents one result of an inline query.
type ResultBase ¶
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. Send Markdown or HTML, if you want Telegram apps to show // bold, italic, fixed-width text or inline URLs in the media caption. ParseMode ParseMode `json:"parse_mode,omitempty"` // Optional. Content of the message to be sent. Content InputMessageContent `json:"input_message_content,omitempty"` // Optional. Inline keyboard attached to the message. ReplyMarkup *ReplyMarkup `json:"reply_markup,omitempty"` }
ResultBase must be embedded into all IQRs.
func (*ResultBase) Process ¶
func (r *ResultBase) Process(b *Bot)
func (*ResultBase) ResultID ¶
func (r *ResultBase) ResultID() string
ResultID returns ResultBase.ID.
func (*ResultBase) SetContent ¶
func (r *ResultBase) SetContent(content InputMessageContent)
SetContent sets ResultBase.Content.
func (*ResultBase) SetParseMode ¶
func (r *ResultBase) SetParseMode(mode ParseMode)
SetParseMode sets ResultBase.ParseMode.
func (*ResultBase) SetReplyMarkup ¶
func (r *ResultBase) SetReplyMarkup(markup *ReplyMarkup)
SetReplyMarkup sets ResultBase.ReplyMarkup.
func (*ResultBase) SetResultID ¶
func (r *ResultBase) SetResultID(id string)
SetResultID sets ResultBase.ID.
type Results ¶
type Results []Result
Results is a slice wrapper for convenient marshalling.
func (Results) MarshalJSON ¶
MarshalJSON makes sure IQRs have proper IDs and Type variables set.
type Rights ¶
type Rights struct { // Anonymous is true, if the user's presence in the chat is hidden. Anonymous bool `json:"is_anonymous"` CanBeEdited bool `json:"can_be_edited"` CanChangeInfo bool `json:"can_change_info"` CanPostMessages bool `json:"can_post_messages"` CanEditMessages bool `json:"can_edit_messages"` CanDeleteMessages bool `json:"can_delete_messages"` CanPinMessages bool `json:"can_pin_messages"` CanInviteUsers bool `json:"can_invite_users"` CanRestrictMembers bool `json:"can_restrict_members"` CanPromoteMembers bool `json:"can_promote_members"` CanSendMessages bool `json:"can_send_messages"` CanSendPolls bool `json:"can_send_polls"` CanSendOther bool `json:"can_send_other_messages"` CanAddPreviews bool `json:"can_add_web_page_previews"` CanManageVideoChats bool `json:"can_manage_video_chats"` CanManageChat bool `json:"can_manage_chat"` CanManageTopics bool `json:"can_manage_topics"` CanSendMedia bool `json:"can_send_media_messages,omitempty"` // deprecated CanSendAudios bool `json:"can_send_audios"` CanSendDocuments bool `json:"can_send_documents"` CanSendPhotos bool `json:"can_send_photos"` CanSendVideos bool `json:"can_send_videos"` CanSendVideoNotes bool `json:"can_send_video_notes"` CanSendVoiceNotes bool `json:"can_send_voice_notes"` // Independent defines whether the chat permissions are set independently. // If not, the can_send_other_messages and can_add_web_page_previews permissions // will imply the can_send_messages, can_send_audios, can_send_documents, can_send_photos, // can_send_videos, can_send_video_notes, and can_send_voice_notes permissions; // the can_send_polls permission will imply the can_send_messages permission. // // Works for Restrict and SetGroupPermissions methods only. Independent bool `json:"-"` }
Rights is a list of privileges available to chat members.
func NoRestrictions ¶
func NoRestrictions() Rights
NoRestrictions should be used when un-restricting or un-promoting user.
member.Rights = tele.NoRestrictions() b.Restrict(chat, member)
type SendOptions ¶
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 // Entities is a list of special entities that appear in message text, which can be specified instead of parse_mode. Entities Entities // AllowWithoutReply allows sending messages not a as reply if the replied-to message has already been deleted. AllowWithoutReply bool // Protected protects the contents of sent message from forwarding and saving. Protected bool // ThreadID supports sending messages to a thread. ThreadID int // HasSpoiler marks the message as containing a spoiler. HasSpoiler bool }
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.
func Placeholder ¶
func Placeholder(text string) *SendOptions
Placeholder is used to set input field placeholder as a send option.
type Sendable ¶
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 ¶
type Settings struct { URL string Token string // Updates channel capacity, defaulted to 100. Updates int // Poller is the provider of Updates. Poller Poller // Synchronous prevents handlers from running in parallel. // It makes ProcessUpdate return after the handler is finished. Synchronous bool // Verbose forces bot to log all upcoming requests. // Use for debugging purposes only. Verbose bool // ParseMode used to set default parse mode of all sent messages. // It attaches to every send, edit or whatever method. You also // will be able to override the default mode by passing a new one. ParseMode ParseMode // OnError is a callback function that will get called on errors // resulted from the handler. It is used as post-middleware function. // Notice that context can be nil. OnError func(error, Context) // HTTP Client used to make requests to telegram api Client *http.Client // Offline allows to create a bot without network for testing purposes. Offline bool }
Settings represents a utility struct for passing certain properties of a bot around and is required to make bots.
type ShippingAddress ¶
type ShippingAddress struct { CountryCode string `json:"country_code"` State string `json:"state"` City string `json:"city"` StreetLine1 string `json:"street_line1"` StreetLine2 string `json:"street_line2"` PostCode string `json:"post_code"` }
ShippingAddress represents a shipping address.
type ShippingOption ¶
type ShippingOption struct { ID string `json:"id"` Title string `json:"title"` Prices []Price `json:"prices"` }
ShippingOption represents one shipping option.
type ShippingQuery ¶
type ShippingQuery struct { Sender *User `json:"from"` ID string `json:"id"` Payload string `json:"invoice_payload"` Address ShippingAddress `json:"shipping_address"` }
ShippingQuery contains information about an incoming shipping query.
type Sticker ¶
type Sticker struct { File Width int `json:"width"` Height int `json:"height"` Animated bool `json:"is_animated"` Video bool `json:"is_video"` Thumbnail *Photo `json:"thumb"` Emoji string `json:"emoji"` SetName string `json:"set_name"` MaskPosition *MaskPosition `json:"mask_position"` PremiumAnimation *File `json:"premium_animation"` Type StickerSetType `json:"type"` CustomEmoji string `json:"custom_emoji_id"` }
Sticker object represents a WebP image, so-called sticker.
type StickerResult ¶
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 StickerSet ¶
type StickerSet struct { Type StickerSetType `json:"sticker_type"` Name string `json:"name"` Title string `json:"title"` Animated bool `json:"is_animated"` Video bool `json:"is_video"` Stickers []Sticker `json:"stickers"` Thumbnail *Photo `json:"thumb"` PNG *File `json:"png_sticker"` TGS *File `json:"tgs_sticker"` WebM *File `json:"webm_sticker"` Emojis string `json:"emojis"` ContainsMasks bool `json:"contains_masks"` // FIXME: can be removed MaskPosition *MaskPosition `json:"mask_position"` }
StickerSet represents a sticker set.
type StickerSetType ¶
type StickerSetType = string
type StoredMessage ¶
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 ¶
func (x StoredMessage) MessageSig() (messageID string, chatID int64)
type Update ¶
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"` InlineResult *InlineResult `json:"chosen_inline_result,omitempty"` ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"` PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"` Poll *Poll `json:"poll,omitempty"` PollAnswer *PollAnswer `json:"poll_answer,omitempty"` MyChatMember *ChatMemberUpdate `json:"my_chat_member,omitempty"` ChatMember *ChatMemberUpdate `json:"chat_member,omitempty"` ChatJoinRequest *ChatJoinRequest `json:"chat_join_request,omitempty"` }
Update object represents an incoming update.
type User ¶
type User struct { ID int64 `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name"` IsForum bool `json:"is_forum"` Username string `json:"username"` LanguageCode string `json:"language_code"` IsBot bool `json:"is_bot"` IsPremium bool `json:"is_premium"` AddedToMenu bool `json:"added_to_attachment_menu"` Usernames []string `json:"active_usernames"` CustomEmojiStatus string `json:"emoji_status_custom_emoji_id"` // Returns only in getMe CanJoinGroups bool `json:"can_join_groups"` CanReadMessages bool `json:"can_read_all_group_messages"` SupportsInline bool `json:"supports_inline_queries"` }
User object represents a Telegram user, bot.
type Venue ¶
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"` GooglePlaceID string `json:"google_place_id,omitempty"` GooglePlaceType string `json:"google_place_type,omitempty"` }
Venue object represents a venue location with name, address and optional foursquare ID.
type VenueResult ¶
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"` // Optional. Width of the thumbnail for the result. ThumbWidth int `json:"thumb_width,omitempty"` // Optional. Height of the thumbnail for the result. ThumbHeight int `json:"thumb_height,omitempty"` }
VenueResult represents a venue.
type Video ¶
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"` Streaming bool `json:"supports_streaming,omitempty"` MIME string `json:"mime_type,omitempty"` FileName string `json:"file_name,omitempty"` }
Video object represents a video file.
func (*Video) InputMedia ¶
func (v *Video) InputMedia() InputMedia
type VideoChatEnded ¶
type VideoChatEnded struct {
Duration int `json:"duration"` // in seconds
}
VideoChatEnded represents a service message about a video chat ended in the chat.
type VideoChatParticipants ¶
type VideoChatParticipants struct {
Users []User `json:"users"`
}
VideoChatParticipants represents a service message about new members invited to a video chat
type VideoChatScheduled ¶
type VideoChatScheduled struct {
Unixtime int64 `json:"start_date"`
}
VideoChatScheduled represents a service message about a video chat scheduled in the chat.
func (*VideoChatScheduled) StartsAt ¶
func (v *VideoChatScheduled) StartsAt() time.Time
StartsAt returns the point when the video chat is supposed to be started by a chat administrator.
type VideoChatStarted ¶
type VideoChatStarted struct{}
VideoChatStarted represents a service message about a video chat started in the chat.
type VideoNote ¶
type VideoNote struct { File Duration int `json:"duration"` // (Optional) Thumbnail *Photo `json:"thumb,omitempty"` Length int `json:"length,omitempty"` }
VideoNote represents a video message.
type VideoResult ¶
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.
type Voice ¶
type Voice struct { File Duration int `json:"duration"` // (Optional) Caption string `json:"caption,omitempty"` MIME string `json:"mime_type,omitempty"` }
Voice object represents a voice note.
type VoiceResult ¶
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"` // Optional. Caption, 0-1024 characters. Caption string `json:"caption,omitempty"` // 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.
type WebApp ¶
type WebApp struct {
URL string `json:"url"`
}
WebApp represents a parameter of the inline keyboard button or the keyboard button used to launch Web App.
type WebAppData ¶
WebAppData object represents a data sent from a Web App to the bot
type WebAppMessage ¶
type WebAppMessage struct {
InlineMessageID string `json:"inline_message_id"`
}
WebAppMessage describes an inline message sent by a Web App on behalf of a user.
type Webhook ¶
type Webhook struct { Listen string `json:"url"` MaxConnections int `json:"max_connections"` AllowedUpdates []string `json:"allowed_updates"` IP string `json:"ip_address"` DropUpdates bool `json:"drop_pending_updates"` SecretToken string `json:"secret_token"` // (WebhookInfo) HasCustomCert bool `json:"has_custom_certificate"` PendingUpdates int `json:"pending_update_count"` ErrorUnixtime int64 `json:"last_error_date"` ErrorMessage string `json:"last_error_message"` SyncErrorUnixtime int64 `json:"last_synchronization_error_date"` TLS *WebhookTLS Endpoint *WebhookEndpoint // contains filtered or unexported fields }
A Webhook configures the poller for webhooks. It opens a port on the given listen address. 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 address 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.
type WebhookEndpoint ¶
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 self-signed 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 certificate (letsencrypt, ...).
type WebhookTLS ¶
A WebhookTLS specifies the path to a key and a cert so the poller can open a TLS listener.
type WriteAccessAllowed ¶
type WriteAccessAllowed struct {
WebAppName string `json:"web_app_name,omitempty"`
}
WebAppAccessAllowed represents a service message about a user allowing a bot to write messages after adding the bot to the attachment menu or launching a Web App from a link.
Source Files ¶
- admin.go
- api.go
- bot.go
- callback.go
- chat.go
- commands.go
- context.go
- editable.go
- errors.go
- file.go
- game.go
- inline.go
- inline_types.go
- input_types.go
- markup.go
- media.go
- message.go
- middleware.go
- options.go
- payments.go
- payments_data.go
- poll.go
- poller.go
- sendable.go
- stickers.go
- telebot.go
- topic.go
- update.go
- video_chat.go
- web_app.go
- webhook.go