tbotapi

package module
v0.0.0-...-edc2572 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2017 License: MIT Imports: 11 Imported by: 10

README

TBotAPI - Telegram Bot-API for Go - DISCONTINUED

This was a simple wrapper for the Telegram Bot-API for Go.

THIS WRAPPER IS NOT CURRENTLY MAINTAINED

Alternatives

Documentation

Overview

Package tbotapi provides a Go wrapper for the Telegram Messenger Bot API.

Note that, if the REST API returns an error, that error will be wrapped in a Go error.

We currently only support long polling (i.e. no webhooks). Feature-wise, everything up to and including the January 20 changes should be implemented.

Examples are provided in the examples package, so check that out.

The Bot API imposes certain limitations, these are especially interesting for inline query results and files. This library does not keep track of those limitations, so you'll have to perform checks yourself.

Index

Constants

View Source
const (
	EntityTypeMention    = MessageEntityType("mention")
	EntityTypeHashtag    = MessageEntityType("hashtag")
	EntityTypeBotCommand = MessageEntityType("bot_command")
	EntityTypeURL        = MessageEntityType("url")
	EntityTypeEmail      = MessageEntityType("email")
	EntityTypeBold       = MessageEntityType("bold")
	EntityTypeItalic     = MessageEntityType("italic")
	EntityTypeCode       = MessageEntityType("code")
	EntityTypePre        = MessageEntityType("pre")
	EntityTypeTextLink   = MessageEntityType("text_link")
)

Entity types.

View Source
const (
	ModeMarkdown = ParseMode("Markdown") // Parse as Markdown.
	ModeHTML     = ParseMode("HTML")     // Parse as HTML.
	ModeDefault  = ParseMode("")         // Parse as text.
)

ParseModes.

View Source
const (
	ChatActionTyping         ChatAction = "typing"
	ChatActionUploadPhoto               = "upload_photo"
	ChatActionRecordVideo               = "record_video"
	ChatActionUploadVideo               = "upload_video"
	ChatActionRecordAudio               = "record_audio"
	ChatActionUploadAudio               = "upload_audio"
	ChatActionUploadDocument            = "upload_document"
	ChatActionFindLocation              = "find_location"
)

Represents all the possible ChatActions to be sent, see https://core.telegram.org/bots/api#sendchataction

View Source
const (
	ArticleResult  = InlineQueryResultType("article")
	PhotoResult    = InlineQueryResultType("photo")
	GifResult      = InlineQueryResultType("gif")
	Mpeg4GifResult = InlineQueryResultType("mpeg4_gif")
	VideoResult    = InlineQueryResultType("video")
)

Inline query result type constants.

View Source
const (
	MIMETextHTML = MIMEType("text/html")
	MIMEVideoMP4 = MIMEType("video/mp4")
)

MIME type constants for an InlineQueryResultVideo.

Variables

View Source
var ErrNoFileSpecified = errors.New("tbotapi: Neither a fileID nor a fileName/reader were specified")

ErrNoFileSpecified is returned in case neither a file name + io.Reader nor a fileID were specified.

Functions

This section is empty.

Types

type Audio

type Audio struct {
	FileBase
	Duration int    `json:"duration"`
	MimeType string `json:"mime_type"`
}

Audio represents an audio file to be treated as music.

type BotUpdate

type BotUpdate struct {
	// contains filtered or unexported fields
}

BotUpdate represents an update the bot received. Always check if an error occurred before using the update.

func (*BotUpdate) Error

func (u *BotUpdate) Error() error

Error returns != nil, if an error occurred during retrieval of the update.

func (*BotUpdate) Update

func (u *BotUpdate) Update() Update

Update returns the contained update.

type CallbackQuery

type CallbackQuery struct {
	ID              string   `json:"id"`                // Unique identifier for this query.
	From            User     `json:"from"`              // Sender.
	Message         *Message `json:"message"`           // Message with the callback button that originated the query. (optional).
	InlineMessageID *string  `json:"inline_message_id"` // Identifier of the message sent via the bot in inline mode, that originated the query.
	Data            string   `json:"data"`              // Data associated with the callback button. Be aware that a bad client can send arbitrary data in this field.
}

CallbackQuery represents an incoming callback query from a button of an inline keyboard.

type Chat

type Chat struct {
	ID        int     `json:"id"`         // Unique identifier for this chat.
	Type      string  `json:"type"`       // Type of chat, can be either "private", "group" or "channel". Check Is(PrivateChat|GroupChat|Channel)() methods.
	Title     *string `json:"title"`      // Title for channels and group chats.
	Username  *string `json:"username"`   // Username for private chats and channels if available.
	FirstName *string `json:"first_name"` // First name of the other party in a private chat.
	LastName  *string `json:"last_name"`  // Last name of the other party in a private chat.
}

Chat contains information about the chat a message originated from.

func (Chat) IsChannel

func (c Chat) IsChannel() bool

IsChannel checks if the chat is a channel.

func (Chat) IsGroupChat

func (c Chat) IsGroupChat() bool

IsGroupChat checks if the chat is a group chat.

func (Chat) IsPrivateChat

func (c Chat) IsPrivateChat() bool

IsPrivateChat checks if the chat is a private chat.

func (Chat) IsSupergroup

func (c Chat) IsSupergroup() bool

IsSupergroup checks if the chat is a supergroup chat.

func (Chat) String

func (c Chat) String() string

type ChatAction

type ChatAction string

ChatAction represents an action to be shown to clients, indicating activity of the bot.

type ChosenInlineResult

type ChosenInlineResult struct {
	ID    string `json:"result_id"` // Unique identifier for the result that was chosen.
	From  User   `json:"from"`      // User that chose the result.
	Query string `json:"query"`     // Query that was used to obtain the result.
}

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

type Contact

type Contact struct {
	PhoneNumber string `json:"phone_number"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	ID          int    `json:"user_id"`
}

Contact represents a phone contact.

type Document

type Document struct {
	FileBase
	Thumbnail PhotoSize `json:"thumb"`
	Name      string    `json:"file_name"`
	MimeType  string    `json:"mime_type"`
}

Document represents a general file.

type File

type File struct {
	FileBase
	Path string `json:"file_path"`
}

File represents a file ready to be downloaded.

type FileBase

type FileBase struct {
	ID   string `json:"file_id"`
	Size int    `json:"file_size"`
}

FileBase contains all the fields present in every file-like API response.

type FileResponse

type FileResponse struct {
	File File `json:"result"`
	// contains filtered or unexported fields
}

FileResponse represents the response sent by the API when requesting a file for download.

type ForceReply

type ForceReply struct {
	ForceReply bool `json:"force_reply"`
	Selective  bool `json:"selective"`
}

ForceReply represents the values sent by a bot so that clients will be presented with a forced reply, see https://core.telegram.org/bots/api#forcereply

type InlineKeyboardButton

type InlineKeyboardButton struct {
	Text              string `json:"text"`
	URL               string `json:"url,omitempty"`
	CallbackData      string `json:"callback_data,omitempty"`
	SwitchInlineQuery string `json:"switch_inline_query,omitempty"`
}

InlineKeyboardButton represents a button for an inline query keyboard.

type InlineKeyboardMarkup

type InlineKeyboardMarkup struct {
	InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}

InlineKeyboardMarkup represents markup for an inline query response.

type InlineQuery

type InlineQuery struct {
	ID     string `json:"id"`     // Unique identifier for this query.
	From   User   `json:"from"`   // Sender.
	Query  string `json:"query"`  // Text of the query.
	Offset string `json:"offset"` // Offset of the results to be returned, can be controlled by the bot.
}

InlineQuery represents an incoming inline query.

type InlineQueryAnswer

type InlineQueryAnswer struct {
	QueryID    string              `json:"inline_query_id"`       // Unique identifier for the answered query.
	Results    []InlineQueryResult `json:"results"`               // Results for the query.
	CacheTime  int                 `json:"cache_time,omitempty"`  // The maximum amount of time in seconds that the result of the query may be cached.
	Personal   bool                `json:"is_personal,omitempty"` // If set to true, results will be cached for that user onl.
	NextOffset string              `json:"next_offset,omitempty"` // The offset that a client should send in the next query with the same text to receive more results.
	// contains filtered or unexported fields
}

InlineQueryAnswer represents a response to an inline query. For limitations, check the API documentation.

func (*InlineQueryAnswer) Send

func (ia *InlineQueryAnswer) Send() error

Send sends the inline query answer. On success, nil is returned.

type InlineQueryResult

type InlineQueryResult interface {
	// contains filtered or unexported methods
}

InlineQueryResult is a marker interface for query results. It is implemented by pointers to InlineQueryResult(Article|Photo|Gif|Mpeg4Gif|Video).

type InlineQueryResultArticle

type InlineQueryResultArticle struct {
	InlineQueryResultBase
	Title       string `json:"title"`                  // Title of the result.
	Text        string `json:"message_text"`           // Text of the message to be sent.
	URL         string `json:"url,omitempty"`          // URL of the result (optional).
	HideURL     bool   `json:"hide_url,omitempty"`     // Whether to hide the URL in the message (optional).
	Description string `json:"description,omitempty"`  // Short description of the result (optional).
	ThumbURL    string `json:"thumb_url,omitempty"`    // URL of the thumbnail for the result (optional).
	ThumbWidth  int    `json:"thumb_width,omitempty"`  // Thumbnail width (optional).
	ThumbHeight int    `json:"thumb_height,omitempty"` // Thumbnail height (optional).
}

InlineQueryResultArticle represents a link to an article or web page.

func NewInlineQueryResultArticle

func NewInlineQueryResultArticle(id, title, text string) *InlineQueryResultArticle

NewInlineQueryResultArticle returns a new InlineQueryResultArticle with all mandatory fields set.

type InlineQueryResultBase

type InlineQueryResultBase struct {
	Type                  InlineQueryResultType `json:"type"`                               // Type of the result.
	ID                    string                `json:"id"`                                 // Unique identifier for this result, 1-64 bytes.
	ParseMode             ParseMode             `json:"parse_mode,omitempty"`               // Indicates how to parse client-side (optional).
	DisableWebPagePreview bool                  `json:"disable_web_page_preview,omitempty"` // Disables link previews (optional).
}

InlineQueryResultBase is the base for all InlineQueryResults.

type InlineQueryResultFileOptionals

type InlineQueryResultFileOptionals struct {
	Caption string `json:"caption,omitempty"`      // Caption of the file to be sent, for limitations check the API documentation (optional).
	Text    string `json:"message_text,omitempty"` // Text of a message to be sent instead of the file, for limitations check the API documentation (optional).
}

InlineQueryResultFileOptionals contains optional fields that all inline query file-like results support.

type InlineQueryResultGif

type InlineQueryResultGif struct {
	InlineQueryResultBase
	GifURL    string `json:"gif_url"`              // Valid URL for the GIF file.
	ThumbURL  string `json:"thumb_url"`            // URL of the static thumbnail for the result.
	GifWidth  int    `json:"gif_width,omitempty"`  // Width of the GIF (optional).
	GifHeight int    `json:"gif_height,omitempty"` // Height of the GIF (optional).
	Title     string `json:"title,omitempty"`      // Title for the result (optional).
	InlineQueryResultFileOptionals
}

InlineQueryResultGif represents a link to an animated GIF file.

func NewInlineQueryResultGif

func NewInlineQueryResultGif(id, gifURL, thumbURL string) *InlineQueryResultGif

NewInlineQueryResultGif returns a new InlineQueryResultGif with all mandatory fields set.

type InlineQueryResultMpeg4Gif

type InlineQueryResultMpeg4Gif struct {
	InlineQueryResultBase
	Mpeg4URL    string `json:"mpeg4_url"`              // Valid URL for the MP4 file.
	ThumbURL    string `json:"thumb_url"`              // URL of the static thumbnail for the result.
	Mpeg4Width  int    `json:"mpeg4_width,omitempty"`  // Video width (optional).
	Mpeg4Height int    `json:"mpeg4_height,omitempty"` // Video height (optional).
	Title       string `json:"title,omitempty"`        // Title for the result (optional).
	InlineQueryResultFileOptionals
}

InlineQueryResultMpeg4Gif represents a link to a video animation (without sound).

func NewInlineQueryResultMpeg4Gif

func NewInlineQueryResultMpeg4Gif(id, mpeg4URL, thumbURL string) *InlineQueryResultMpeg4Gif

NewInlineQueryResultMpeg4Gif returns a new InlineQueryResultMpeg4Gif with all mandatory fields set.

type InlineQueryResultPhoto

type InlineQueryResultPhoto struct {
	InlineQueryResultBase
	PhotoURL    string `json:"photo_url"`              // Valid URL of the photo.
	ThumbURL    string `json:"thumb_url"`              // URL of the thumbnail for the photo.
	PhotoWidth  int    `json:"photo_width,omitempty"`  // Width of the photo (optional).
	PhotoHeight int    `json:"photo_height,omitempty"` // Height of the photo (optional).
	Title       string `json:"title,omitempty"`        // Title for the result (optional).
	Description string `json:"description,omitempty"`  // Description of the result (optional).
	InlineQueryResultFileOptionals
}

InlineQueryResultPhoto represents a link to a photo.

func NewInlineQueryResultPhoto

func NewInlineQueryResultPhoto(id, photoURL, thumbURL string) *InlineQueryResultPhoto

NewInlineQueryResultPhoto returns a new InlineQueryResultPhoto with all mandatory fields set.

type InlineQueryResultType

type InlineQueryResultType string

InlineQueryResultType represents a type of an inline query result.

type InlineQueryResultVideo

type InlineQueryResultVideo struct {
	InlineQueryResultBase
	VideoURL      string   `json:"video_url"`                // Valid URL for the video player/file.
	MIMEType      MIMEType `json:"mime_type"`                // MIME type of the content of the URL.
	ThumbURL      string   `json:"thumb_url"`                // URL of the static thumbnail.
	Title         string   `json:"title"`                    // Title for the result.
	Text          string   `json:"message_text"`             // Text of the message to be sent with the video, for limitations check the API documentation.
	VideoWidth    int      `json:"video_width,omitempty"`    // Video width (optional).
	VideoHeight   int      `json:"video_height,omitempty"`   // Video height (optional).
	VideoDuration int      `json:"video_duration,omitempty"` // Video duration in seconds (optional).
	Description   string   `json:"description"`              // Short description of the result (optional).
	InlineQueryResultFileOptionals
}

InlineQueryResultVideo represents a link to a video player/file.

func NewInlineQueryResultVideo

func NewInlineQueryResultVideo(id, videoURL, thumbURL, title, text string, mimeType MIMEType) *InlineQueryResultVideo

NewInlineQueryResultVideo returns a new InlineQueryResultVideo with all mandatory fields set.

type KeyboardButton

type KeyboardButton struct {
	Text            string `json:"text"`
	RequestContact  bool   `json:"request_contact"`
	RequestLocation bool   `json:"request_location"`
}

KeyboardButton represents a button on a reply keyboard.

type Location

type Location struct {
	Longitude float32 `json:"longitude"`
	Latitude  float32 `json:"latitude"`
}

Location represents a point on the map.

type MIMEType

type MIMEType string

MIMEType represents a MIME type.

type Message

type Message struct {
	ReplyToMessage *noReplyMessage `json:"reply_to_message"`
	// contains filtered or unexported fields
}

Message represents a message.

func (*Message) IsForwarded

func (m *Message) IsForwarded() bool

IsForwarded checks if the message was forwarded.

func (*Message) IsReply

func (m *Message) IsReply() bool

IsReply checks if the message is a reply.

func (*Message) Type

func (m *Message) Type() MessageType

Type determines the type of the message. Note that, for all these types, messages can still be replies or forwarded.

type MessageEntity

type MessageEntity struct {
	Type   MessageEntityType `json:"type"`
	Offset int               `json:"offset"`
	Length int               `json:"length"`
	URL    *string           `json:"url"`
}

MessageEntity represents an entity contained in a text message.

type MessageEntityType

type MessageEntityType string

MessageEntityType is the type of an entity contained in a message.

type MessageResponse

type MessageResponse struct {
	Message Message `json:"result"`
	// contains filtered or unexported fields
}

MessageResponse represents the response sent by the API on successful messages sent.

type MessageType

type MessageType int

MessageType is the type of a message.

const (
	TextMessage     MessageType = iota // Text messages.
	PinnedMessage                      // Pinned messages.
	AudioMessage                       // Audio messages.
	DocumentMessage                    // Files.
	PhotoMessage                       // Photos.
	StickerMessage                     // Stickers.
	VideoMessage                       // Videos.
	VoiceMessage                       // Voice messages.
	ContactMessage                     // Contact information.
	LocationMessage                    // Locations.
	VenueMessage                       // Venues.

	NewChatMember         // Joined chat participant.
	LeftChatMember        // Left chat participant.
	NewChatTitle          // Chat title change.
	NewChatPhoto          // New chat photo.
	DeletedChatPhoto      // Deleted chat photo.
	GroupChatCreated      // Creation of a group cha.
	SupergroupChatCreated // Creation of a supergroup cha.
	ChannelChatCreated    // Createion of a channe.
	MigrationToSupergroup // Migration to supergrou.
	MigrationFromGroup    // Migration from group (to supergroup).

	UnknownMessage // Unknown (probably new due to API changes).
)

Message types.

func (MessageType) IsChatAction

func (mt MessageType) IsChatAction() bool

IsChatAction checks if the MessageType is about changes in group chats.

func (MessageType) String

func (mt MessageType) String() string

type OutgoingAudio

type OutgoingAudio struct {
	Duration  int    `json:"duration,omitempty"`
	Title     string `json:"title,omitempty"`
	Performer string `json:"performer,omitempty"`
	// contains filtered or unexported fields
}

OutgoingAudio represents an outgoing audio file.

func (*OutgoingAudio) Send

func (oa *OutgoingAudio) Send() (*MessageResponse, error)

Send sends the audio. Note that the Telegram servers may check the fileName for its extension. For current limitations on what bots can send, please check the API documentation. On success, the sent message is returned as a MessageResponse.

func (*OutgoingAudio) SetDisableNotification

func (op *OutgoingAudio) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingAudio) SetDuration

func (oa *OutgoingAudio) SetDuration(to int) *OutgoingAudio

SetDuration sets a duration for the audio file (optional).

func (*OutgoingAudio) SetForceReply

func (op *OutgoingAudio) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingAudio) SetPerformer

func (oa *OutgoingAudio) SetPerformer(to string) *OutgoingAudio

SetPerformer sets a performer for the audio file (optional).

func (*OutgoingAudio) SetReplyKeyboardHide

func (op *OutgoingAudio) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingAudio) SetReplyKeyboardMarkup

func (op *OutgoingAudio) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingAudio) SetReplyToMessageID

func (op *OutgoingAudio) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

func (*OutgoingAudio) SetTitle

func (oa *OutgoingAudio) SetTitle(to string) *OutgoingAudio

SetTitle sets a title for the audio file (optional).

type OutgoingCallbackQueryResponse

type OutgoingCallbackQueryResponse struct {
	CallbackQueryID string `json:"callback_query_id"` // ID of the callback query.
	Text            string `json:"text,omitempty"`
	ShowAlert       bool   `json:"show_alert,omitempty"`
	// contains filtered or unexported fields
}

OutgoingCallbackQueryResponse represents a response to a callback query.

func (*OutgoingCallbackQueryResponse) Send

Send sends the callback response.

type OutgoingChatAction

type OutgoingChatAction struct {
	Action ChatAction `json:"action"`
	// contains filtered or unexported fields
}

OutgoingChatAction represents an outgoing chat action.

func (*OutgoingChatAction) Send

func (oc *OutgoingChatAction) Send() error

Send sends the chat action. On success, nil is returned.

type OutgoingDocument

type OutgoingDocument struct {
	// contains filtered or unexported fields
}

OutgoingDocument represents an outgoing file.

func (*OutgoingDocument) Send

func (od *OutgoingDocument) Send() (*MessageResponse, error)

Send sends the document. Note that the Telegram servers may check the fileName for its extension. For current limitations on what bots can send, please check the API documentation. On success, the sent message is returned as a MessageResponse.

func (*OutgoingDocument) SetDisableNotification

func (op *OutgoingDocument) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingDocument) SetForceReply

func (op *OutgoingDocument) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingDocument) SetReplyKeyboardHide

func (op *OutgoingDocument) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingDocument) SetReplyKeyboardMarkup

func (op *OutgoingDocument) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingDocument) SetReplyToMessageID

func (op *OutgoingDocument) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingForward

type OutgoingForward struct {
	FromChatID Recipient `json:"from_chat_id"`
	MessageID  int       `json:"message_id"`
	// contains filtered or unexported fields
}

OutgoingForward represents an outgoing, forwarded message.

func (*OutgoingForward) Send

func (of *OutgoingForward) Send() (*MessageResponse, error)

Send sends the forward. On success, the sent message is returned as a MessageResponse.

func (*OutgoingForward) SetDisableNotification

func (op *OutgoingForward) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingForward) SetForceReply

func (op *OutgoingForward) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingForward) SetReplyKeyboardHide

func (op *OutgoingForward) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingForward) SetReplyKeyboardMarkup

func (op *OutgoingForward) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingForward) SetReplyToMessageID

func (op *OutgoingForward) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingKickChatMember

type OutgoingKickChatMember struct {
	Recipient Recipient `json:"chat_id"`
	UserID    int       `json:"user_id"`
	// contains filtered or unexported fields
}

OutgoingKickChatMember represents a request to kick a chat member.

func (*OutgoingKickChatMember) Send

func (kr *OutgoingKickChatMember) Send() error

Send sends the kick request.

type OutgoingLocation

type OutgoingLocation struct {
	Latitude  float32 `json:"latitude"`
	Longitude float32 `json:"longitude"`
	// contains filtered or unexported fields
}

OutgoingLocation represents an outgoing location on a map.

func (*OutgoingLocation) Send

func (ol *OutgoingLocation) Send() (*MessageResponse, error)

Send sends the location. On success, the sent message is returned as a MessageResponse.

func (*OutgoingLocation) SetDisableNotification

func (op *OutgoingLocation) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingLocation) SetForceReply

func (op *OutgoingLocation) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingLocation) SetReplyKeyboardHide

func (op *OutgoingLocation) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingLocation) SetReplyKeyboardMarkup

func (op *OutgoingLocation) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingLocation) SetReplyToMessageID

func (op *OutgoingLocation) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingMessage

type OutgoingMessage struct {
	Text                  string    `json:"text"`
	DisableWebPagePreview bool      `json:"disable_web_page_preview,omitempty"`
	ParseMode             ParseMode `json:"parse_mode,omitempty"`
	// contains filtered or unexported fields
}

OutgoingMessage represents an outgoing message.

func (*OutgoingMessage) Send

func (om *OutgoingMessage) Send() (*MessageResponse, error)

Send sends the message. On success, the sent message is returned as a MessageResponse.

func (*OutgoingMessage) SetDisableNotification

func (op *OutgoingMessage) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingMessage) SetDisableWebPagePreview

func (om *OutgoingMessage) SetDisableWebPagePreview(to bool) *OutgoingMessage

SetDisableWebPagePreview disables web page previews for the message (optional).

func (*OutgoingMessage) SetForceReply

func (op *OutgoingMessage) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingMessage) SetHTML

func (om *OutgoingMessage) SetHTML(to bool) *OutgoingMessage

SetHTML sets or resets whether the message should be parsed as HTML or plain text (optional).

func (*OutgoingMessage) SetMarkdown

func (om *OutgoingMessage) SetMarkdown(to bool) *OutgoingMessage

SetMarkdown sets or resets whether the message should be parsed as markdown or plain text (optional).

func (*OutgoingMessage) SetReplyKeyboardHide

func (op *OutgoingMessage) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingMessage) SetReplyKeyboardMarkup

func (op *OutgoingMessage) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingMessage) SetReplyToMessageID

func (op *OutgoingMessage) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingPhoto

type OutgoingPhoto struct {
	Caption string `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

OutgoingPhoto represents an outgoing photo.

func (*OutgoingPhoto) Send

func (op *OutgoingPhoto) Send() (*MessageResponse, error)

Send sends the photo. Note that the Telegram servers may check the fileName for its extension. For current limitations on what bots can send, please check the API documentation. On success, the sent message is returned as a MessageResponse.

func (*OutgoingPhoto) SetCaption

func (op *OutgoingPhoto) SetCaption(to string) *OutgoingPhoto

SetCaption sets a caption for the photo (optional).

func (*OutgoingPhoto) SetDisableNotification

func (op *OutgoingPhoto) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingPhoto) SetForceReply

func (op *OutgoingPhoto) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingPhoto) SetReplyKeyboardHide

func (op *OutgoingPhoto) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingPhoto) SetReplyKeyboardMarkup

func (op *OutgoingPhoto) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingPhoto) SetReplyToMessageID

func (op *OutgoingPhoto) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingSticker

type OutgoingSticker struct {
	// contains filtered or unexported fields
}

OutgoingSticker represents an outgoing sticker message.

func (*OutgoingSticker) Send

func (os *OutgoingSticker) Send() (*MessageResponse, error)

Send sends the sticker. Note that the Telegram servers may check the fileName for its extension. For current limitations on what bots can send, please check the API documentation. On success, the sent message is returned as a MessageResponse.

func (*OutgoingSticker) SetDisableNotification

func (op *OutgoingSticker) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingSticker) SetForceReply

func (op *OutgoingSticker) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingSticker) SetReplyKeyboardHide

func (op *OutgoingSticker) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingSticker) SetReplyKeyboardMarkup

func (op *OutgoingSticker) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingSticker) SetReplyToMessageID

func (op *OutgoingSticker) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingUnbanChatMember

type OutgoingUnbanChatMember struct {
	Recipient Recipient `json:"chat_id"`
	UserID    int       `json:"user_id"`
	// contains filtered or unexported fields
}

OutgoingUnbanChatMember represents a request to unban a chat member.

func (*OutgoingUnbanChatMember) Send

func (ub *OutgoingUnbanChatMember) Send() error

Send sends the unban request.

type OutgoingUserProfilePhotosRequest

type OutgoingUserProfilePhotosRequest struct {
	UserID int `json:"user_id"`
	Offset int `json:"offset,omitempty"`
	Limit  int `json:"limit,omitempty"`
	// contains filtered or unexported fields
}

OutgoingUserProfilePhotosRequest represents a request for a users profile photos.

func (*OutgoingUserProfilePhotosRequest) Send

Send sends the request. On success, the photos are returned as a UserProfilePhotosResponse.

func (*OutgoingUserProfilePhotosRequest) SetLimit

SetLimit sets a limit for the request (optional).

func (*OutgoingUserProfilePhotosRequest) SetOffset

SetOffset sets an offset for the request (optional).

type OutgoingVenue

type OutgoingVenue struct {
	Latitude     float32 `json:"latitude"`
	Longitude    float32 `json:"longitude"`
	Title        string  `json:"title"`
	Address      string  `json:"address"`
	FoursquareID string  `json:"foursquare_id,omitempty"`
	// contains filtered or unexported fields
}

OutgoingVenue represents an outgoing venue message.

func (*OutgoingVenue) Send

func (ol *OutgoingVenue) Send() (*MessageResponse, error)

Send sends the venue. On success, the sent message is returned as a MessageResponse.

func (*OutgoingVenue) SetDisableNotification

func (op *OutgoingVenue) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingVenue) SetForceReply

func (op *OutgoingVenue) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVenue) SetFoursquareID

func (ov *OutgoingVenue) SetFoursquareID(to string) *OutgoingVenue

SetFoursquareID sets the foursquare ID for the venue (optional).

func (*OutgoingVenue) SetReplyKeyboardHide

func (op *OutgoingVenue) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVenue) SetReplyKeyboardMarkup

func (op *OutgoingVenue) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVenue) SetReplyToMessageID

func (op *OutgoingVenue) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingVideo

type OutgoingVideo struct {
	Duration int    `json:"duration,omitempty"`
	Caption  string `json:"caption,omitempty"`
	// contains filtered or unexported fields
}

OutgoingVideo represents an outgoing video file.

func (*OutgoingVideo) Send

func (ov *OutgoingVideo) Send() (*MessageResponse, error)

Send sends the video. Note that the Telegram servers may check the fileName for its extension. For current limitations on what bots can send, please check the API documentation. On success, the sent message is returned as a MessageResponse.

func (*OutgoingVideo) SetCaption

func (ov *OutgoingVideo) SetCaption(to string) *OutgoingVideo

SetCaption sets a caption for the video file (optional).

func (*OutgoingVideo) SetDisableNotification

func (op *OutgoingVideo) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingVideo) SetDuration

func (ov *OutgoingVideo) SetDuration(to int) *OutgoingVideo

SetDuration sets a duration for the video file (optional).

func (*OutgoingVideo) SetForceReply

func (op *OutgoingVideo) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVideo) SetReplyKeyboardHide

func (op *OutgoingVideo) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVideo) SetReplyKeyboardMarkup

func (op *OutgoingVideo) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVideo) SetReplyToMessageID

func (op *OutgoingVideo) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type OutgoingVoice

type OutgoingVoice struct {
	Duration int `json:"duration,omitempty"`
	// contains filtered or unexported fields
}

OutgoingVoice represents an outgoing voice note.

func (*OutgoingVoice) Send

func (ov *OutgoingVoice) Send() (*MessageResponse, error)

Send sends the voice message. Note that the Telegram servers may check the fileName for its extension. For current limitations on what bots can send, please check the API documentation. On success, the sent message is returned as a MessageResponse.

func (*OutgoingVoice) SetDisableNotification

func (op *OutgoingVoice) SetDisableNotification(to bool)

SetDisableNotification sets whether notifications should be disabled for this message (optional).

func (*OutgoingVoice) SetDuration

func (ov *OutgoingVoice) SetDuration(to int) *OutgoingVoice

SetDuration sets a duration of the voice note (optional).

func (*OutgoingVoice) SetForceReply

func (op *OutgoingVoice) SetForceReply(to ForceReply)

SetForceReply sets ForceReply for this message (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVoice) SetReplyKeyboardHide

func (op *OutgoingVoice) SetReplyKeyboardHide(to ReplyKeyboardHide)

SetReplyKeyboardHide sets the ReplyKeyboardHide (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVoice) SetReplyKeyboardMarkup

func (op *OutgoingVoice) SetReplyKeyboardMarkup(to ReplyKeyboardMarkup)

SetReplyKeyboardMarkup sets the ReplyKeyboardMarkup (optional) Note that only one of ReplyKeyboardMarkup, ReplyKeyboardHide or ForceReply can be set. Attempting to set any of the other two or re-setting this will cause a panic.

func (*OutgoingVoice) SetReplyToMessageID

func (op *OutgoingVoice) SetReplyToMessageID(to int)

SetReplyToMessageID sets the ID for the message to reply to (optional).

type ParseMode

type ParseMode string

ParseMode describes how a message should be parsed client-side.

type PhotoSize

type PhotoSize struct {
	FileBase
	Width  int `json:"width"`
	Height int `json:"height"`
}

PhotoSize represents one size of a photo or a thumbnail.

type Recipient

type Recipient struct {
	ChatID    *int
	ChannelID *string
}

Recipient represents the recipient of a message.

func NewChannelRecipient

func NewChannelRecipient(channelName string) Recipient

NewChannelRecipient creates a new recipient for channels.

func NewChatRecipient

func NewChatRecipient(chatID int) Recipient

NewChatRecipient creates a new recipient for private or group chats.

func NewRecipientFromChat

func NewRecipientFromChat(chat Chat) Recipient

NewRecipientFromChat creates a recipient that addresses the given chat.

func (Recipient) MarshalJSON

func (r Recipient) MarshalJSON() ([]byte, error)

MarshalJSON marshals the recipient to JSON.

type ReplyKeyboardHide

type ReplyKeyboardHide struct {
	HideKeyboard bool `json:"hide_keyboard"`
	Selective    bool `json:"selective"`
}

ReplyKeyboardHide contains the fields necessary to hide a custom keyboard.

type ReplyKeyboardMarkup

type ReplyKeyboardMarkup struct {
	Keyboard        [][]KeyboardButton `json:"keyboard"` // Slice of keyboard lines.
	ResizeKeyboard  bool               `json:"resize_keyboard"`
	OneTimeKeyboard bool               `json:"one_time_keyboard"`
	Selective       bool               `json:"selective"`
}

ReplyKeyboardMarkup represents a custom keyboard with reply options to be presented to clients.

type ReplyMarkup

type ReplyMarkup interface {
	// contains filtered or unexported methods
}

ReplyMarkup is s marker interface for ReplyMarkups. It is implemented by ReplyKeyboard(Hide|Markup) and ForceReply.

type Sticker

type Sticker struct {
	FileBase
	Width     int       `json:"width"`
	Height    int       `json:"height"`
	Thumbnail PhotoSize `json:"thumb"`
}

Sticker represents a sticker.

type TelegramBotAPI

type TelegramBotAPI struct {
	ID       int            // The bots ID.
	Name     string         // The bots Name as seen by users.
	Username string         // The bots username.
	Updates  chan BotUpdate // A channel providing updates this bot receives.
	// contains filtered or unexported fields
}

A TelegramBotAPI is an API Client for one Telegram bot. Create a new client by calling the New() function.

func New

func New(apiKey string) (*TelegramBotAPI, error)

New creates a new API Client for a Telegram bot using the apiKey provided. It will call the GetMe method to retrieve the bots id, name and username.

This bot uses long polling to retrieve its updates. If a webhook was set for the given apiKey, this will remove it.

func NewWithWebhook

func NewWithWebhook(apiKey, webhookURL, certificate string) (*TelegramBotAPI, http.HandlerFunc, error)

NewWithWebhook creates a new API client for a Telegram bot using the apiKey provided. It will call the GetMe method to retrieve the bots id, name and username. In addition to the API client, a http.HandlerFunc will be returned. This handler func reacts to webhook requests and will put updates into the Updates channel.

func (*TelegramBotAPI) Close

func (api *TelegramBotAPI) Close()

Close shuts down this client. Until Close returns, new updates and errors will be put into the respective channels. Note that, if no updates are received, this function may block for up to one minute, which is the time interval for long polling.

func (*TelegramBotAPI) GetFile

func (api *TelegramBotAPI) GetFile(fileID string) (*FileResponse, error)

GetFile returns a FileResponse containing a Path string needed to download a file. You will have to construct the download link manually like https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response.

func (*TelegramBotAPI) GetMe

func (api *TelegramBotAPI) GetMe() (*UserResponse, error)

GetMe returns basic information about the bot in form of a UserResponse.

func (*TelegramBotAPI) NewInlineQueryAnswer

func (api *TelegramBotAPI) NewInlineQueryAnswer(queryID string, results []InlineQueryResult) *InlineQueryAnswer

NewInlineQueryAnswer creates a new inline query answer.

func (*TelegramBotAPI) NewOutgoingAudio

func (api *TelegramBotAPI) NewOutgoingAudio(recipient Recipient, fileName string, reader io.Reader) *OutgoingAudio

NewOutgoingAudio creates a new outgoing audio file.

func (*TelegramBotAPI) NewOutgoingAudioResend

func (api *TelegramBotAPI) NewOutgoingAudioResend(recipient Recipient, fileID string) *OutgoingAudio

NewOutgoingAudioResend creates a new outgoing audio file for re-sending.

func (*TelegramBotAPI) NewOutgoingCallbackQueryResponse

func (api *TelegramBotAPI) NewOutgoingCallbackQueryResponse(queryID string) *OutgoingCallbackQueryResponse

NewOutgoingCallbackQueryResponse creates a response to a callback query.

func (*TelegramBotAPI) NewOutgoingChatAction

func (api *TelegramBotAPI) NewOutgoingChatAction(recipient Recipient, action ChatAction) *OutgoingChatAction

NewOutgoingChatAction creates a new outgoing chat action.

func (*TelegramBotAPI) NewOutgoingDocument

func (api *TelegramBotAPI) NewOutgoingDocument(recipient Recipient, fileName string, reader io.Reader) *OutgoingDocument

NewOutgoingDocument creates a new outgoing file.

func (*TelegramBotAPI) NewOutgoingDocumentResend

func (api *TelegramBotAPI) NewOutgoingDocumentResend(recipient Recipient, fileID string) *OutgoingDocument

NewOutgoingDocumentResend creates a new outgoing file for re-sending.

func (*TelegramBotAPI) NewOutgoingForward

func (api *TelegramBotAPI) NewOutgoingForward(recipient Recipient, origin Chat, messageID int) *OutgoingForward

NewOutgoingForward creates a new outgoing, forwarded message.

func (*TelegramBotAPI) NewOutgoingKickChatMember

func (api *TelegramBotAPI) NewOutgoingKickChatMember(chat Recipient, userID int) *OutgoingKickChatMember

NewOutgoingKickChatMember creates a request to kick a member from a group chat or channel.

func (*TelegramBotAPI) NewOutgoingLocation

func (api *TelegramBotAPI) NewOutgoingLocation(recipient Recipient, latitude, longitude float32) *OutgoingLocation

NewOutgoingLocation creates a new outgoing location.

func (*TelegramBotAPI) NewOutgoingMessage

func (api *TelegramBotAPI) NewOutgoingMessage(recipient Recipient, text string) *OutgoingMessage

NewOutgoingMessage creates a new outgoing message.

func (*TelegramBotAPI) NewOutgoingPhoto

func (api *TelegramBotAPI) NewOutgoingPhoto(recipient Recipient, fileName string, reader io.Reader) *OutgoingPhoto

NewOutgoingPhoto creates a new outgoing photo.

func (*TelegramBotAPI) NewOutgoingPhotoResend

func (api *TelegramBotAPI) NewOutgoingPhotoResend(recipient Recipient, fileID string) *OutgoingPhoto

NewOutgoingPhotoResend creates a new outgoing photo for re-sending.

func (*TelegramBotAPI) NewOutgoingSticker

func (api *TelegramBotAPI) NewOutgoingSticker(recipient Recipient, fileName string, reader io.Reader) *OutgoingSticker

NewOutgoingSticker creates a new outgoing sticker message.

func (*TelegramBotAPI) NewOutgoingStickerResend

func (api *TelegramBotAPI) NewOutgoingStickerResend(recipient Recipient, fileID string) *OutgoingSticker

NewOutgoingStickerResend creates a new outgoing sticker message for re-sending.

func (*TelegramBotAPI) NewOutgoingUnbanChatMember

func (api *TelegramBotAPI) NewOutgoingUnbanChatMember(chat Recipient, userID int) *OutgoingUnbanChatMember

NewOutgoingUnbanChatMember creates a request to unban a member of a group chat or channel.

func (*TelegramBotAPI) NewOutgoingUserProfilePhotosRequest

func (api *TelegramBotAPI) NewOutgoingUserProfilePhotosRequest(userID int) *OutgoingUserProfilePhotosRequest

NewOutgoingUserProfilePhotosRequest creates a new request for a users profile photos.

func (*TelegramBotAPI) NewOutgoingVenue

func (api *TelegramBotAPI) NewOutgoingVenue(recipient Recipient, latitude, longitude float32, title, address string) *OutgoingVenue

NewOutgoingVenue creates a new outgoing location.

func (*TelegramBotAPI) NewOutgoingVideo

func (api *TelegramBotAPI) NewOutgoingVideo(recipient Recipient, fileName string, reader io.Reader) *OutgoingVideo

NewOutgoingVideo creates a new outgoing video file.

func (*TelegramBotAPI) NewOutgoingVideoResend

func (api *TelegramBotAPI) NewOutgoingVideoResend(recipient Recipient, fileID string) *OutgoingVideo

NewOutgoingVideoResend creates a new outgoing video file for re-sending.

func (*TelegramBotAPI) NewOutgoingVoice

func (api *TelegramBotAPI) NewOutgoingVoice(recipient Recipient, fileName string, reader io.Reader) *OutgoingVoice

NewOutgoingVoice creates a new outgoing voice note.

func (*TelegramBotAPI) NewOutgoingVoiceResend

func (api *TelegramBotAPI) NewOutgoingVoiceResend(recipient Recipient, fileID string) *OutgoingVoice

NewOutgoingVoiceResend creates a new outgoing voice note for re-sending.

type Update

type Update struct {
	ID                 int                 `json:"update_id"`
	Message            *Message            `json:"message"`
	InlineQuery        *InlineQuery        `json:"inline_query"`
	ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"`
	CallbackQuery      *CallbackQuery      `json:"callback_query"`
}

Update represents an incoming update.

func (*Update) Type

func (u *Update) Type() UpdateType

Type returns the type of the update.

type UpdateType

type UpdateType int

UpdateType represents an update type.

const (
	MessageUpdate            UpdateType = iota // Message update.
	InlineQueryUpdate                          // Inline query.
	ChosenInlineResultUpdate                   // Chosen inline result.

	UnknownUpdate // Unkown, probably due to API changes.
)

Update types.

func (UpdateType) String

func (t UpdateType) String() string

type User

type User struct {
	ID        int     `json:"id"`
	FirstName string  `json:"first_name"`
	LastName  *string `json:"last_name"`
	Username  *string `json:"username"`
}

User represents a Telegram user or bot.

func (User) String

func (u User) String() string

type UserProfilePhotos

type UserProfilePhotos struct {
	TotalCount int         `json:"total_count"`
	Photos     []PhotoSize `json:"photos"`
}

UserProfilePhotos represents a users profile pictures.

type UserProfilePhotosResponse

type UserProfilePhotosResponse struct {
	UserProfilePhotos UserProfilePhotos `json:"result"`
	// contains filtered or unexported fields
}

UserProfilePhotosResponse represents the response sent by the API on a GetUserProfilePhotos request.

type UserResponse

type UserResponse struct {
	User User `json:"result"`
	// contains filtered or unexported fields
}

UserResponse represents the response sent by the API on a GetMe request.

type Venue

type Venue struct {
	Location     Location `json:"location"`     // Venue location.
	Title        string   `json:"title"`        // Name of the venue.
	Address      string   `json:"address"`      // Address of the venue.
	FoursquareID *string  `json:"foursqare_id"` // Foursqare ID of the venue (optional).
}

Venue represents a venue contained in a message.

type Video

type Video struct {
	FileBase
	Width     int       `json:"width"`
	Height    int       `json:"height"`
	Duration  int       `json:"duration"`
	Thumbnail PhotoSize `json:"thumb"`
	MimeType  string    `json:"mime_type"`
	Caption   string    `json:"caption"`
}

Video represents a video file.

type Voice

type Voice struct {
	FileBase
	Duration int    `json:"duration"`
	MimeType string `json:"mime_type"`
}

Voice represents a voice note.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL