Documentation
¶
Overview ¶
Package tgwrap provides bindings for Telegram Bot API.
Index ¶
- Constants
- func NewBot(token string) *bot
- func NewBotWithClient(token string, client *http.Client) *bot
- func NewBotWithClientAndURL(token string, client *http.Client, apiURL string) *bot
- func NewBotWithOpt(token string, optRaw *BotOpt) *bot
- type Animation
- type Audio
- type BotChatInterface
- type BotContactsInterface
- type BotInterface
- type BotLocationInterface
- type BotMediaInterface
- type BotMessagesInterface
- type BotOpt
- type BotUpdatesInterface
- type CallbackQuery
- type Chat
- type ChatActions
- type ChatPermissions
- type ChatPhoto
- type ChosenInlineResult
- type Contact
- type DeleteWebhookOpt
- type Document
- type EditMessageLiveLocationOpt
- type File
- type ForceReply
- type Game
- type GenericResponse
- type GetUpdatesOpt
- type GetUserProfilePhotosOpt
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type InlineQuery
- type InputFile
- type InputFileLocal
- type Invoice
- type KeyboardButton
- type Location
- type Message
- type MessageEntity
- type OrderInfo
- type ParseModes
- type PassportData
- type PhotoSize
- type Poll
- type PollAnswer
- type PollOption
- type PreCheckoutQuery
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type SendAudioOpt
- type SendContactOpt
- type SendDocumentOpt
- type SendLocationOpt
- type SendMessageOpt
- type SendPhotoOpt
- type SendVenueOpt
- type SendVideoNoteOpt
- type SendVideoOpt
- type SendVoiceOpt
- type SetWebhookOpt
- type ShippingAddress
- type ShippingQuery
- type Sticker
- type StopMessageLiveLocationOpt
- type SuccessfulPayment
- type Update
- type UpdateType
- type User
- type UserProfilePhotos
- type Venue
- type Video
- type VideoNote
- type Voice
- type WebhookInfo
Constants ¶
const ( // UpdateTypeMessage is new incoming message of any kind — text, photo, sticker, etc. UpdateTypeMessage = "message" // UpdateTypeEditedMessage is new version of a message that is known to the bot and was edited. UpdateTypeEditedMessage = "edited_message" // UpdateTypeChannelPost is new incoming channel post of any kind — text, photo, sticker, etc. UpdateTypeChannelPost = "channel_post" // UpdateTypeEditedChannelPost is new version of a channel post that is known to the bot and was edited. UpdateTypeEditedChannelPost = "edited_channel_post" // UpdateTypeinlineQuery is new incoming inline query. UpdateTypeinlineQuery = "inline_query" // UpdateTypeChosenInlineResult - the result of an inline query that was chosen // by a user and sent to their chat partner. UpdateTypeChosenInlineResult = "chosen_inline_result" // UpdateTypeCallbackQuery is new incoming callback query/. UpdateTypeCallbackQuery = "callback_query" // UpdateTypeShippingQuery UpdateTypeShippingQuery = "shipping_query" // UpdateTypePreCheckoutQuery is new incoming shipping query. UpdateTypePreCheckoutQuery = "pre_checkout_query" // UpdateTypePoll is new poll state. Bots receive only updates // about stopped polls and polls, which are sent by the bot. UpdateTypePoll = "poll" // UpdateTypePollAnswer - a user changed their answer in a non-anonymous poll. // Bots receive new votes only in polls that were sent by the bot itself UpdateTypePollAnswer = "poll_answer" )
const DefaultClientTimeout = time.Second * 50
DefaultClientTimeout is result waiting interval used by default in default client.
const TelegramBotAPI = "https://api.telegram.org/bot"
TelegramBotAPI is default api address used in default client.
Variables ¶
This section is empty.
Functions ¶
func NewBot ¶
func NewBot(token string) *bot
NewBot creates new object with associated token inside.
func NewBotWithClient ¶
NewBotWithClient creates bot w/ associated token and optional HTTP client.
func NewBotWithClientAndURL ¶
NewBotWithClientAndURL creates bot w/ token, client and different API URL (proxy).
func NewBotWithOpt ¶ added in v1.1.1
NewBotWithOpt is general method for creating bot w/ options.
Types ¶
type Animation ¶
type Animation struct {
// FileID is identifier for this file, which can be used to download or reuse the file.
FileID string `json:"file_id"`
// Thumb is optional animation thumbnail as defined by sender.
Thumb *PhotoSize `json:"thumb,omitempty"`
// FileName is optional original animation filename as defined by sender.
FileName string `json:"file_name,omitempty"`
// MIMEType is optional type of the file as defined by sender.
MIMEType string `json:"mime_type,omitempty"`
// FileSize is file size in bytes if known.
FileSize int `json:"file_size,omitempty"`
}
Animation represents an animation file (GIF or H.264/MPEG-4 AVC video without sound). You can provide an animation for your game so that it looks stylish in chats (check out Lumberjack for an example). This object represents an animation file to be displayed in the message containing a game.
type Audio ¶
type Audio struct {
// FileID is identifier for this file, which can be used to download or reuse the file.
FileID string `json:"file_id"`
// FileUniqueID - unique identifier for this file, which is supposed
// to be the same over time and for different bots.
// Can't be used to download or reuse the file.
FileUniqueID string `json:"file_unique_id"`
// Duration of the audio in seconds as defined by sender.
Duration int `json:"duration"`
// Performer is optional performer name of the audio as defined by sender or by audio tags.
Performer string `json:"performer,omitempty"`
// Title is optional title of the audio as defined by sender or by audio tags.
Title string `json:"title,omitempty"`
// MIMEType is optional type of the file as defined by sender.
MIMEType string `json:"mime_type,omitempty"`
// FileSize is file size in bytes if known.
FileSize int `json:"file_size,omitempty"`
// Thumb is optional thumbnail of the album cover to which the music file belongs.
Thumb *PhotoSize `json:"thumb,omitempty"`
}
Audio represents an audio file to be treated as music by the Telegram clients.
type BotChatInterface ¶
type BotChatInterface interface {
// SendChatAction is used when you need to tell the user
// that something is happening on the bot's side. The status
// is set for 5 seconds or less (when a message arrives from
// your bot, Telegram clients clear its typing status).
// Returns True on success.
//
// chatID: unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// action: type of action to broadcast.
//
SendChatAction(chatID interface{}, action ChatActions) (bool, error)
}
BotChatInterface is a group of methods for chat manipulation used as a part of common BotInterface API interface.
type BotContactsInterface ¶
type BotContactsInterface interface {
// SendContact is used to to send phone contacts.
// On success, the sent Message is returned.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// phoneNumber: (string) Contact's phone number.
//
// firstName: (string) Contact's first name.
//
// opt: (can be nil) optional params
//
SendContact(chatID interface{}, phoneNumber string, firstName string, opt *SendContactOpt) (*Message, error)
}
BotContactsInterface is a group of methods for sending contact-related information; used as a part of common BotInterface API interface.
type BotInterface ¶
type BotInterface interface {
// GetMe is used for testing your bot's auth token.
// Requires no parameters. Returns basic information
// about the bot in form of a User object.Telegram API method
//
GetMe() (*User, error)
BotUpdatesInterface
BotMessagesInterface
BotChatInterface
BotMediaInterface
BotLocationInterface
BotContactsInterface
}
BotInterface is a summary declaration for nominal Telegram Bot API interface.
type BotLocationInterface ¶
type BotLocationInterface interface {
// SendLocation is used to send point on the map.
// On success, the sent Message is returned.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// latitude: (float64) Latitude of the location.
//
// longitude: (float64) Longitude of the location.
//
// opt: (can be nil) optional params
//
SendLocation(chatID interface{}, latitude float64, longitude float64, opt *SendLocationOpt) (*Message, error)
// SendVenue is used to send information about a venue.
// On success, the sent Message is returned.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// latitude: (float64) Latitude of the venue.
//
// longitude: (float64) Longitude of the venue.
//
// title: (string) Name of the venue.
//
// address: (string) Address of the venue.
//
// opt: (can be nil) optional params
//
SendVenue(chatID interface{}, latitude float64, longitude float64, title string, address string, opt *SendVenueOpt) (*Message, error)
// StopMessageLiveLocation is used to stop updating a live location message sent by the bot or via the bot (for inline bots) before live_period expires.
// On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.
//
// opt: (can be nil) optional params
StopMessageLiveLocation(opt *StopMessageLiveLocationOpt) (interface{}, error)
// EditMessageLiveLocation is used to edit live location messages sent by the bot or via the bot (for inline bots).
// A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation.
// On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
//
// latitude: (float64) Latitude of new location.
//
// longitude: (float64) Longitude of new location.
//
// opt: (can be nil) optional params
//
EditMessageLiveLocation(latitude float64, longitude float64, opt *EditMessageLiveLocationOpt) (interface{}, error)
}
BotLocationInterface is a group of methods for location used as a part of common BotInterface API interface
type BotMediaInterface ¶
type BotMediaInterface interface {
// SendPhoto is used to send photos.
//
// chatID: (Integer or String) Unique identifier
// for the target chat or username of the target channel (in the format @channelusername)
//
// photo: (*InputFile or string) Photo to send. Pass a file_id as string to send
// a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a string
// for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data
// using &NewInputFileLocal("<file path>")
//
// opt: (can be nil) optional params
//
SendPhoto(chatID interface{}, photo interface{}, opt *SendPhotoOpt) (*Message, error)
// SendVideo is used to send video files, Telegram clients support mp4 videos
// (other formats may be sent as Document). On success, the sent Message is returned.
// Bots can currently send video files of up to 50 MB in size,
// this limit may be changed in the future.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// video: (*InputFile or string) Video to send. Pass a file_id as string to send
// a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a string
// for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data
// using &NewInputFileLocal("<file path>")
//
// opt: (can be nil) optional params
//
SendVideo(chatID interface{}, video interface{}, opt *SendVideoOpt) (*Message, error)
// SendAudio is used to send audio files, if you want Telegram clients to display them in the music player.
// Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently
// send audio files of up to 50 MB in size, this limit may be changed in the future.
//
// For sending voice messages, use the SendVoice method instead.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// audio: (*InputFile or string) Audio to send. Pass a file_id as string to send
// an audio that exists on the Telegram servers (recommended), pass an HTTP URL as a string
// for Telegram to get an audio from the Internet, or upload a new file using multipart/form-data.
// using &NewInputFileLocal("<file path>")
//
// opt: (can be nil) optional params
//
SendAudio(chatID interface{}, audio interface{}, opt *SendAudioOpt) (*Message, error)
// SendVoice to send audio files, if you want Telegram clients to display the file
// as a playable voice message. For this to work, your audio must be in an .ogg file
// encoded with OPUS (other formats may be sent as Audio or Document).
// On success, the sent Message is returned. Bots can currently send voice messages
// of up to 50 MB in size, this limit may be changed in the future.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// voice: (*InputFile or string) Audio to send. Pass a file_id as String to send
// an audio that exists on the Telegram servers (recommended), pass an HTTP URL as a String
// for Telegram to get an audio from the Internet, or upload a new file using multipart/form-data.
// using &NewInputFileLocal("<file path>")
//
// opt: (can be nil) optional params
//
SendVoice(chatID interface{}, voice interface{}, opt *SendVoiceOpt) (*Message, error)
// SendDocument to send general files. On success, the sent Message is returned.
// Bots can currently send files of any type of up to 50 MB in size, t
// his limit may be changed in the future.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// document: (*InputFile or string) File to send. Pass a file_id as String to send
// an audio that exists on the Telegram servers (recommended), pass an HTTP URL as a String
// for Telegram to get an audio from the Internet, or upload a new file using multipart/form-data.
// using &NewInputFileLocal("<file path>")
//
// opt: (can be nil) optional params
//
SendDocument(chatID interface{}, document interface{}, opt *SendDocumentOpt) (*Message, error)
// SendVideoNote is used to send video notes.
// As of v.4.0, Telegram clients support rounded square mp4 videos of up to 1 minute long.
// Use this method to send video messages. On success, the sent Message is returned.
//
// chatID: (int64 or string) is unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// video: (*InputFile or string) Video note to send.
// Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or
// upload a new video using multipart/form-data.
// Sending video notes by a URL is currently unsupported
//
// opt: (can be nil) optional params
//
SendVideoNote(chatID interface{}, video interface{}, opt *SendVideoNoteOpt) (*Message, error)
}
BotMediaInterface is a group of methods for sending media used as a part of common BotInterface API interface
type BotMessagesInterface ¶
type BotMessagesInterface interface {
// SendMessage is used method to send text messages.
//
// chatID: unique identifier for the target chat
// or username(!) of the target channel (in the format @channelusername)
//
// text: text of the message to be sent
//
// opt: (can be nil) optional params
//
SendMessage(chatID interface{}, text string, opt *SendMessageOpt) (*Message, error)
// ForwardMessage is used to forward messages of any kind.
// On success, the sent Message is returned.
//
// chatID: unique identifier for the target chat
// or username of the target channel (in the format @channelusername)
//
// fromChatID: unique identifier for the chat
// where the original message was sent (or channel username
// in the format @channelusername)
//
// disableNotification: sends the message silently.
// Users will receive a notification with no sound.
//
// messageID: message identifier in the chat
// specified in fromChatID
//
ForwardMessage(chatID interface{}, fromChatID interface{},
disableNotification bool, messageID int64) (*Message, error)
}
BotMessagesInterface is just a group of methods to have smaller interface files.
type BotUpdatesInterface ¶
type BotUpdatesInterface interface {
// GetUpdates is used to receive incoming updates using [long] polling
//
// opt: (can be nil) optional params
//
GetUpdates(opt *GetUpdatesOpt) ([]Update, error)
}
BotUpdatesInterface is a group of methods related to getting updates used as a part of common BotInterface API interface
type CallbackQuery ¶
type CallbackQuery struct {
// ID is unique identifier for this query.
ID string `json:"id"`
// From - sender.
From *User `json:"from"`
// Message. Optional. Message with the callback button that originated the query.
// Note that message content and message date will not be available
// if the message is too old
Message *Message `json:"message,omitempty"`
// InlineMessageID. Optional. Identifier of the message sent via the bot in inline mode,
// that originated the query.
InlineMessageID string `json:"inline_message_id,omitempty"`
// ChatInstance. Global identifier, uniquely corresponding to the chat to which the message
// with the callback button was sent. Useful for high scores in games.
ChatInstance string `json:"chat_instance"`
// Data. Optional. Data associated with the callback button.
// Be aware that a bad client can send arbitrary data in this field.
Data string `json:"data,omitempty"`
// GameShortName. Optional. Short name of a Game to be returned,
// serves as the unique identifier for the game
GameShortName string `json:"game_short_name,omitempty"`
}
CallbackQuery represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.
NOTE: After the user presses a callback button, Telegram clients will display a progress bar until you call answerCallbackQuery. It is, therefore, necessary to react by calling answerCallbackQuery even if no notification to the user is needed (e.g., without specifying any of the optional parameters).
type Chat ¶
type Chat struct {
// ID - unique identifier for this chat.
ID int64 `json:"id"`
// Type of chat, can be either “private”, “group”, “supergroup” or “channel”
Type string `json:"type"`
// Title is optional title, for supergroups, channels and group chats.
Title string `json:"title,omitempty"`
// UserName is optional username, for private chats, supergroups and channels if available.
UserName string `json:"username,omitempty"`
// FirstName is optional. First name of the other party in a private chat
FirstName string `json:"first_name,omitempty"`
// LastName is optional. Last name of the other party in a private chat
LastName string `json:"last_name,omitempty"`
// Photo is optional. Chat photo. Returned only in getChat.
Photo *ChatPhoto `json:"photo,omitempty"`
// Description is optional. Description, for supergroups and channel chats. Returned only in getChat.
Description string `json:"description,omitempty"`
// InviteLink is optional. Chat invite link, for supergroups and channel chats. Returned only in getChat.
InviteLink string `json:"invite_link,omitempty"`
// PinnedMessage is optional. Pinned message, for supergroups and channel chats. Returned only in getChat.
PinnedMessage *Message `json:"pinned_message,omitempty"`
// Permissions is optional. Default chat member permissions, for groups and supergroups. Returned only in getChat.
Permissions *ChatPermissions `json:"permissions,omitempty"`
// SlowModeDelay is optional. For supergroups, the minimum allowed delay between consecutive messages
// sent by each unpriviledged user. Returned only in getChat.
SlowModeDelay int `json:"slow_mode_delay,omitempty"`
// StickerSetName is optional. For supergroups, name of group sticker set. Returned only in getChat.
StickerSetName string `json:"sticker_set_name,omitempty"`
// CanSetStickerSet is optional. True, if the bot can change the group sticker set. Returned only in getChat.
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
}
Chat is a Telegram API object.
type ChatActions ¶
type ChatActions string
ChatActions type defines string arguments range for SendChatAction.
const ( // ChatActionTyping indicates bot is typing (this looks frighteningly sometimes) ChatActionTyping ChatActions = "typing" // ChatActionUploadPhoto indicates bot is uploading photo ChatActionUploadPhoto ChatActions = "upload_photo" // ChatActionRecordVideo indicates bot is recording video ChatActionRecordVideo ChatActions = "record_video" // ChatActionRecordAudio indicates bot is recording audio ChatActionRecordAudio ChatActions = "record_audio" // ChatActionUploadDocument indicates bot is uploading document ChatActionUploadDocument ChatActions = "upload_document" // ChatActionFindLocation indicates bot is in search // for location (is it really working on any tg client?) ChatActionFindLocation ChatActions = "find_location" // ChatActionRecordVideoNote indicates bot is recording video note ChatActionRecordVideoNote ChatActions = "record_video_note" // ChatActionUploadVideoNote indicates bot is uploading note ChatActionUploadVideoNote ChatActions = "upload_video_note" )
type ChatPermissions ¶ added in v1.1.4
type ChatPermissions struct {
// CanSendMessages. Optional. True, if the user is allowed to send text messages, contacts, locations and venues.
CanSendMessages bool `json:"can_send_messages"`
// CanSendMediaMessages. Optional. True, if the user is allowed to send audios, documents, photos,
// videos, video notes and voice notes, implies can_send_messages.
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
// CanSendPolls.Optional. True, if the user is allowed to send polls, implies can_send_messages.
CanSendPolls bool `json:"can_send_polls,omitempty"`
// CanSendOtherMessages. Optional. True, if the user is allowed to send animations,
// games, stickers and use inline bots, implies can_send_media_messages.
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
// CanAddWebPagePreviews. Optional. True, if the user is allowed to add web page previews
// to their messages, implies can_send_media_messages.
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
// CanChangeInfo. Optional. True, if the user is allowed to change the chat title, photo and other settings.
// Ignored in public supergroups.
CanChangeInfo bool `json:"can_change_info,omitempty"`
// CanInviteUsers. Optional. True, if the user is allowed to invite new users to the chat.
CanInviteUsers bool `json:"can_invite_users,omitempty"`
// CanPinMessages. Optional. True, if the user is allowed to pin messages. Ignored in public supergroups.
CanPinMessages bool `json:"can_pin_messages,omitempty"`
}
ChatPermissions describes actions that a non-administrator user is allowed to take in a chat.
type ChatPhoto ¶
type ChatPhoto struct {
// SmallFileID - unique file identifier of small (160x160) chat photo.
// This file_id can be used only for photo download.
SmallFileID string `json:"small_file_id"`
// SmallFileUniqueID - unique file identifier of small (160x160) chat photo,
// which is supposed to be the same over time and for different bots.
// Can't be used to download or reuse the file.
SmallFileUniqueID string `json:"small_file_unique_id"`
// BigFileID - unique file identifier of big (640x640) chat photo.
// This file_id can be used only for photo download.
BigFileID string `json:"big_file_id"`
// BigFileUniqueID - unique file identifier of big (640x640) chat photo,
// which is supposed to be the same over time and for different bots.
// Can't be used to download or reuse the file.
BigFileUniqueID string `json:"big_file_unique_id"`
}
ChatPhoto is a Telegram API object.
type ChosenInlineResult ¶
type ChosenInlineResult struct {
// ResultID - unique identifier for the result that was chosen.
ResultID string `json:"result_id"`
// From is the user that chose the result.
From *User `json:"from"`
// Location. Optional. Sender location, only for bots that require user location
Location *Location `json:"location,omitempty"`
// InlineMessageID. Optional. Identifier of the sent inline message.
// Available only if there is an inline keyboard attached to the message.
// Will be also received in callback queries and can be used to edit the message.
InlineMessageID string `json:"inline_message_id,omitempty"`
// Query that was used to obtain the result.
Query string `json:"query"`
}
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 is contact's phone number.
PhoneNumber string `json:"phone_number"`
// FirstName is contact's first name.
FirstName string `json:"first_name"`
// LastName. Optional. Contact's last name.
LastName string `json:"last_name,omitempty"`
// UserID. Optional. Contact's user identifier in Telegram.
UserID int64 `json:"user_id,omitempty"`
}
Contact represents a phone contact.
type DeleteWebhookOpt ¶ added in v1.2.1
type DeleteWebhookOpt struct {
// DropPendingUpdates is optional. Pass True to drop all pending updates.
DropPendingUpdates bool `json:"drop_pending_updates,omitempty"`
// contains filtered or unexported fields
}
DeleteWebhookOpt represents optional params for DeleteWebhook.
type Document ¶
type Document struct {
// FileID is unique file identifier.
FileID string `json:"file_id"`
// Thumb. Optional. Document thumbnail as defined by sender.
Thumb *PhotoSize `json:"thumb,omitempty"`
// FileName. Optional. Original filename as defined by sender.
FileName string `json:"file_name,omitempty"`
// MIMEType. Optional. MIME type of the file as defined by sender.
MIMEType string `json:"mime_type,omitempty"`
// FileSize. Optional. File size bytes.
FileSize uint `json:"file_size,omitempty"`
// FilePath. Optional. Use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
FilePath string `json:"file_path,omitempty"`
}
Document represents a general file (as opposed to photos, voice messages and audio files).
type EditMessageLiveLocationOpt ¶
type EditMessageLiveLocationOpt struct {
// ChatID required if inline_message_id is not specified.
// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID interface{} `json:"chat_id,omitempty"`
// MessageID required if inline_message_id is not specified.
// Identifier of the sent message.
MessageID int64 `json:"message_id,omitempty"`
// InlineMessageID required if chat_id and message_id are not specified.
// Identifier of the inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
EditMessageLiveLocationOpt represents optional params for EditMessageLiveLocation.
type File ¶ added in v1.1.4
type File struct {
// FileID is identifier for this file, which can be used to download or reuse the file.
FileID string `json:"file_id"`
// FileUniqueID - unique identifier for this file, which is supposed
// to be the same over time and for different bots.
// Can't be used to download or reuse the file.
FileUniqueID string `json:"file_unique_id"`
// FileSize in bytes, if known.
FileSize int `json:"file_size,omitempty"`
// FilePath - use https://api.telegram.org/file/bot<token>/<file_path> to get the file.
FilePath string `json:"file_path"`
}
File represents a file ready to be downloaded. The file can be downloaded via the link https://api.telegram.org/file/bot<token>/<file_path>. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling getFile. Maximum file size to download is 20 MB.
type ForceReply ¶
type ForceReply struct {
// Shows reply interface to the user, as if they manually selected the bot‘s message and tapped ’Reply'
// should be true
ForceReply bool `json:"force_reply"`
// Selective. Optional. Use this parameter 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 reply_to_message_id),
// sender of the original message.
Selective bool `json:"selective,omitempty"`
}
ForceReply is a Telegram API object.
Upon receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot‘s message and tapped ’Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
type Game ¶
type Game struct {
// Title of the game.
Title string `json:"title"`
// Description of the game.
Description string `json:"description"`
// Photo that will be displayed in the game message in chats.
Photo []PhotoSize `json:"photo"`
// Text. Optional. Brief description of the game or high scores included
// in the game message. Can be automatically edited to include
// current high scores for the game when the bot calls setGameScore,
// or manually edited using editMessageText. 0-4096 characters.
Text string `json:"text,omitempty"`
// TextEntities. Optional. Special entities that appear in text,
// such as usernames, URLs, bot commands, etc.
TextEntities []MessageEntity `json:"text_entities,omitempty"`
// Animation. Optional. Animation that will be displayed in the game message in chats.
// Upload via BotFather
Animation *Animation `json:"animation,omitempty"`
}
Game represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
type GenericResponse ¶
type GenericResponse struct {
OK bool `json:"ok"`
Description string `json:"description,omitempty"`
ErrorCode int `json:"error_code,omitempty"`
}
GenericResponse is a common part of all the API responses. Description and ErrorCode are provided in case of error.
type GetUpdatesOpt ¶
type GetUpdatesOpt struct {
// Offset is an identifier of the first update to be returned.
// Must be greater by one than the highest among the identifiers
// of previously received updates. By default, updates starting
// with the earliest unconfirmed update are returned. An update
// is considered confirmed as soon as getUpdates is called with
// an offset higher than its update_id. The negative offset
// can be specified to retrieve updates starting from -offset
// update from the end of the updates queue.
// All previous updates will forgotten.
Offset int64 `json:"offset,omitempty"`
// Limit limits the number of updates to be retrieved.
// Values between 1—100 are accepted. Defaults to 100.
Limit uint `json:"limit,omitempty"`
// Timeout in seconds for long polling.
// Defaults to 0, i.e. usual short polling. Should be positive,
// short polling should be used for testing purposes only.
Timeout uint `json:"timeout,omitempty"`
// AllowedUpdates lists the types of updates you want your bot to receive.
// For example, specify [“message”, “edited_channel_post”, “callback_query”]
// to only receive updates of these types. See Update for a complete list
// of available update types. Specify an empty list to receive all updates
// regardless of type (default). If not specified, the previous setting will be used.
//
// Please note that this parameter doesn't affect updates
// created before the call to the getUpdates, so unwanted
// updates may be received for a short period of time.
AllowedUpdates []UpdateType `json:"allowed_updates,omitempty"`
// contains filtered or unexported fields
}
GetUpdatesOpt represents optional params for GetUpdates.
type GetUserProfilePhotosOpt ¶ added in v1.1.4
type GetUserProfilePhotosOpt struct {
// Offset is sequential number of the first photo to be returned.
// By default, all photos are returned.
Offset int `json:"offset,omitempty"`
// Limit to limit the number of photos to be retrieved.
// Values between 1—100 are accepted. Defaults to 100.
Limit int `json:"limit,omitempty"`
// contains filtered or unexported fields
}
type InlineKeyboardButton ¶
type InlineKeyboardButton struct {
// Text is label text on the button
Text string `json:"text"`
// URL. Optional. HTTP url to be opened when button is pressed.
URL string `json:"url,omitempty"`
// CallbackData. Optional. Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
CallbackData string `json:"callback_data,omitempty"`
// SwitchInlineQuery. Optional. If set, pressing the button will prompt the user to select one of their chats,
// open that chat and insert the bot‘s username and the specified inline query in the input field.
// Can be empty, in which case just the bot’s username will be inserted.
//
// Note: This offers an easy way for users to start using your bot in inline mode when they
// are currently in a private chat with it. Especially useful when combined with switch_pm… actions
// – in this case the user will be automatically returned to the chat they switched from,
// skipping the chat selection screen.
SwitchInlineQuery string `json:"switch_inline_query,omitempty"`
// SwitchInlineQueryCurrentChat. Optional. If set, pressing the button will insert the bot‘s username
// and the specified inline query in the current chat's input field. Can be empty, in which case only
// the bot’s username will be inserted.
//
// This offers a quick way for the user to open your bot in inline mode in the same chat
// – good for selecting something from multiple options.
SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"`
// CallbackGame. Optional. Description of the game that will be launched when the user presses the button.
//
// NOTE: This type of button must always be the first button in the first row.
CallbackGame string `json:"callback_game,omitempty"`
// Pay. Optional. Specify True, to send a Pay button.
//
// NOTE: This type of button must always be the first button in the first row.
Pay string `json:"pay,omitempty"`
}
InlineKeyboardButton represents one button of an inline keyboard. You must use exactly one of the optional fields.
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct {
// Array of button rows, each represented
// by an Array of InlineKeyboardButton objects
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
InlineKeyboardMarkup represents an inline keyboard that appears right next to the message it belongs to.
type InlineQuery ¶
type InlineQuery struct {
// ID - unique identifier for this query.
ID string `json:"id"`
// From is Sender.
From *User `json:"from"`
// Location. Optional. Sender location, only for bots that request user location
Location *Location `json:"location,omitempty"`
// Query - text of the query (up to 512 characters).
Query string `json:"query"`
// Offset of the results to be returned, can be controlled by the bot.
Offset string `json:"offset"`
}
InlineQuery represents an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
type InputFile ¶
type InputFile struct {
// contains filtered or unexported fields
}
InputFile is used to store file_id, URL, or localFileName to encode as multipart/form-data
func NewInputFileFromID ¶
NewInputFileFromID is used to create InputFile with file_id stored inside.
func NewInputFileFromURL ¶
NewInputFileFromURL is used to create InputFile with URL stored inside.
func (*InputFile) MarshalText ¶
MarshalText implements TextMarshaler and returns fileID or URL.
type InputFileLocal ¶
type InputFileLocal struct {
// contains filtered or unexported fields
}
InputFileLocal is used to store localFileName to encode as multipart/form-data.
func NewInputFileLocal ¶
func NewInputFileLocal(path string) *InputFileLocal
NewInputFileLocal is used to create InputFile with localFileName stored inside.
func (*InputFileLocal) MarshalText ¶
func (p *InputFileLocal) MarshalText() (text []byte, err error)
MarshalText implements TextMarshaler.
func (*InputFileLocal) String ¶
func (p *InputFileLocal) String() string
String implements stringer interface.
type Invoice ¶
type Invoice struct {
// Title is a Product name.
Title string `json:"title"`
// Description is a Product description.
Description string `json:"description"`
// StartParameter - Unique bot deep-linking parameter that can be used to generate this invoice.
StartParameter string `json:"start_parameter"`
// Currency - three-letter ISO 4217 [currency code](https://core.telegram.org/bots/payments#supported-currencies).
Currency string `json:"currency"`
// TotalAmount - total price in the smallest units of the currency
// (integer, not float/double). For example, for a price
// of US$ 1.45 pass amount = 145. See the exp parameter
// in https://core.telegram.org/bots/payments/currencies.json
// it shows the number of digits past the decimal point
// for each currency (2 for the majority of currencies,
// and zero for remaining ).
TotalAmount int `json:"total_amount"`
}
Invoice contains basic information about an invoice.
type KeyboardButton ¶
type KeyboardButton struct {
// Text of the button. If none of the optional fields are used,
// it will be sent as a message when the button is pressed
Text string `json:"text"`
// RequestContact. Optional. If True, the user's phone number will be sent
// as a contact when the button is pressed. Available in private chats only
RequestContact string `json:"request_contact,omitempty"`
// RequestLocation. Optional. If True, the user's current location will be sent
// when the button is pressed. Available in private chats only
RequestLocation string `json:"request_location,omitempty"`
}
KeyboardButton represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields are mutually exclusive.
Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
type Location ¶
type Location struct {
// Longitude as defined by sender.
Longitude float64 `json:"longitude"`
// Latitude as defined by sender.
Latitude float64 `json:"latitude"`
}
Location represents a point on the map.
type Message ¶
type Message struct {
// ID is unique message identifier inside chat.
ID int64 `json:"message_id"`
// From. Optional. Sender, empty for messages sent to channels.
From *User `json:"from,omitempty"`
// Date the message was sent in Unix time.
Date int64 `json:"date"`
// Chat - conversation the message belongs to.
Chat *Chat `json:"chat"`
// ForwardFrom. Optional. For forwarded messages, sender of the original message.
ForwardFrom *User `json:"forward_from,omitempty"`
// ForwardFromChat. Optional. For messages forwarded from channels, information about the original channel.
ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
// ForwardFromMessageID. Optional. For messages forwarded from channels,
// identifier of the original message in the channel.
ForwardFromMessageID int64 `json:"forward_from_message_id,omitempty"`
// ForwardSignature. Optional. For messages forwarded from channels, signature of the post author if present.
ForwardSignature string `json:"forward_signature,omitempty"`
// ForwardSignature. Optional. Optional. Sender's name for messages forwarded from users
// who disallow adding a link to their account in forwarded messages.
ForwardSenderName string `json:"forward_sender_name,omitempty"`
// ForwardDate. Optional. For forwarded messages, date the original message was sent in Unix time.
ForwardDate int64 `json:"forward_date,omitempty"`
// ReplyToMessage. Optional. For replies, the original message.
// Note that the Message object in this field
// will not contain further reply_to_message fields
// even if it itself is a reply.
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
// EditDate. Optional. Date the message was last edited in Unix time.
EditDate int64 `json:"edit_date,omitempty"`
// MediaGroupID. Optional. The unique identifier of a media message group this message belongs to.
MediaGroupID string `json:"media_group_id,omitempty"`
// AuthorSignature. Optional. Signature of the post author for messages in channels.
AuthorSignature string `json:"author_signature,omitempty"`
// Text. Optional. For text messages, the actual UTF-8 text of the message, 0-4096 characters.
Text string `json:"text,omitempty"`
// Entities. Optional. For text messages, special entities
// like usernames, URLs, bot commands, etc. that appear in the text
Entities []MessageEntity `json:"entities,omitempty"`
// CaptionEntities. Optional. For messages with a caption, special entities
// like usernames, URLs, bot commands, etc. that appear in the caption
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Audio. Optional. Message is an audio file, information about the file.
Audio *Audio `json:"audio,omitempty"`
// Document. Optional. Message is a general file, information about the file.
Document *Document `json:"document,omitempty"`
// Animation. Optional. Message is an animation, information about the animation.
// For backward compatibility, when this field is set, the document field will also be set.
Animation *Animation `json:"animation,omitempty"`
// Game. Optional. Message is a game, information about the game.
Game *Game `json:"game,omitempty"`
// Photo. Optional. Message is a photo, available sizes of the photo.
Photo []PhotoSize `json:"photo,omitempty"`
// Sticker. Optional. Message is a sticker, information about the sticker.
Sticker *Sticker `json:"sticker,omitempty"`
// Video. Optional. Message is a video, information about the video.
Video *Video `json:"video,omitempty"`
// Voice. Optional. Message is a voice message, information about the file.
Voice *Voice `json:"voice,omitempty"`
// VideoNote. Optional. Message is a video note, information about the video message.
VideoNote *VideoNote `json:"video_note,omitempty"`
// Caption. Optional. Caption for the audio, document, photo, video or voice, 0-200 characters.
Caption string `json:"caption,omitempty"`
// Contact. Optional. Message is a shared contact, information about the contact.
Contact *Contact `json:"contact,omitempty"`
// Location. Optional. Message is a shared location, information about the location.
Location *Location `json:"location,omitempty"`
// Venue. Optional. Message is a venue, information about the venue.
Venue *Venue `json:"venue,omitempty"`
// Poll. Optional. Message is a native poll, information about the poll.
Poll *Poll `json:"poll,omitempty"`
// NewChatMembers. Optional. New members that were added to the group
// or supergroup and information about them
// (the bot itself may be one of these members).
NewChatMembers []User `json:"new_chat_members,omitempty"`
// LeftChatMembers. Optional. A member was removed from the group,
// information about them (this member may be the bot itself).
LeftChatMembers *User `json:"left_chat_member,omitempty"`
// NewChatTitle. Optional. A chat title was changed to this value.
NewChatTitle string `json:"new_chat_title,omitempty"`
// NewChatPhoto. Optional. A chat photo was changed to this value.
NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
// DeleteChatPhoto. Optional. Service message: the chat photo was deleted.
DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
// GroupChatCreated. Optional. Service message: the group has been created.
GroupChatCreated bool `json:"group_chat_created,omitempty"`
// SupergroupChatCreated. Optional. Service message: the supergroup has been created.
// This field can‘t be received in a message coming through updates,
// because bot can’t be a member of a supergroup when it is created.
// It can only be found in reply_to_message if someone replies
// to a very first message in a directly created supergroup.
SupergroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
// ChannelChatCreated. Optional. Service message: the channel has been created.
// This field can‘t be received in a message coming through updates,
// because bot can’t be a member of a channel when it is created.
// It can only be found in reply_to_message if someone replies
// to a very first message in a channel.
ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
// MigrateChatID. Optional. The group has been migrated to a supergroup
// with the specified identifier. This number may be greater
// than 32 bits and some programming languages may have
// difficulty/silent defects in interpreting it. But
// it is smaller than 52 bits, so a signed 64 bit
// integer or double-precision float type are safe
// for storing this identifier.
MigrateChatID int64 `json:"migrate_to_chat_id,omitempty"`
// MigrateFromChatID. Optional. The supergroup has been migrated from a group
// with the specified identifier. This number may be greater
// than 32 bits and some programming languages may have
// difficulty/silent defects in interpreting it. But
// it is smaller than 52 bits, so a signed 64 bit
// integer or double-precision float type are safe
// for storing this identifier.
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
// PinnedMessage. Optional. Specified message was pinned.
// Note that the Message object in this field
// will not contain further reply_to_message fields
// even if it is itself a reply.
PinnedMessage *Message `json:"pinned_message,omitempty"`
// Invoice. Optional. Message is an invoice for a payment,
// information about the invoice.
Invoice *Invoice `json:"invoice,omitempty"`
// SuccessfulPayment. Optional. Message is a service message about
// a successful payment, information about the payment.
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
// ConnectedWebsite. The domain name of the website on which the user has logged in.
ConnectedWebsite string `json:"connected_website,omitempty"`
//PassportData. Optional. Telegram Passport data.
PassportData *PassportData `json:"passport_data,omitempty"`
// ReplyMarkup. Optional. Inline keyboard attached to the message.
// login_url buttons are represented as ordinary url buttons.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
Message is a Telegram API object.
func (*Message) ForwardTime ¶
ForwardTime returns Message.ForwardDate in time.Time format.
type MessageEntity ¶
type MessageEntity struct {
// Type of the entity.
// Can be:
// - mention (@username),
// - hashtag (#hashtag),
// - cashtag ($USD),
// - bot_command (/start@jobs_bot),
// - url,
// - email,
// - bold (bold text),
// - italic (italic text),
// - underline (underline text),
// - strikethrough (strikethrough text),
// - code (monowidth string),
// - pre (monowidth block),
// - text_link (for clickable text URLs),
// - text_mention (for users without usernames).
Type string `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"`
// URL. Optional. For “text_link” only, url that will be opened after user taps on the text.
URL string `json:"url,omitempty"`
// User. Optional. For “text_mention” only, the mentioned user.
User *User `json:"user,omitempty"`
// Language is Optional. For “pre” only, the programming language of the entity text.
Language string `json:"language,omitempty"`
}
MessageEntity represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
type OrderInfo ¶
type OrderInfo struct {
//Name. Optional. User name.
Name string `json:"name,omitempty"`
//PhoneNumber. Optional. User's phone number.
PhoneNumber string `json:"phone_number,omitempty"`
//Email. Optional. User email.
Email string `json:"email,omitempty"`
//ShippingAddress. Optional. User shipping address.
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
OrderInfo represents information about an order.
type ParseModes ¶
type ParseModes string
ParseModes defines stock values for SendMessage formatting.
The Bot API supports basic formatting for messages. You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages. Telegram clients will render them accordingly. You can use either markdown-style or HTML-style formatting.
Note that Telegram clients will display an alert to the user before opening an inline link (‘Open this link?’ together with the full URL).
Links 'tg://user?id=<user_id>' can be used to mention a user by their id without using a username. Please note: These links will work only if they are used inside an inline link. These mentions are only guaranteed to work if the user has contacted the bot in the past or is a member in the group where he was mentioned.
const ( // ParseModeDefault is simple text by default. ParseModeDefault ParseModes = "" // ParseModeHTML for restriced HTML markup. // The following tags are currently supported: // // <b>bold</b>, <strong>bold</strong> // <i>italic</i>, <em>italic</em> // <a href="http://www.example.com/">inline URL</a> // <a href="tg://user?id=123456789">inline mention of a user</a> // <code>inline fixed-width code</code> // <pre>pre-formatted fixed-width code block</pre> ParseModeHTML ParseModes = "HTML" // ParseModeMarkdown for markdown. // Use the following syntax in your message: // // *bold text* // _italic text_ // [inline URL](http://www.example.com/) // [inline mention of a user](tg://user?id=123456789) // `inline fixed-width code` // “`block_language // pre-formatted fixed-width code block // “` ParseModeMarkdown ParseModes = "Markdown" )
type PassportData ¶ added in v1.1.4
type PassportData struct {
}
Contains information about Telegram Passport data shared with the bot by the user.
type PhotoSize ¶
type PhotoSize struct {
// FileID - unique identifier for this file.
FileID string `json:"file_id"`
// Width is Photo width.
Width int `json:"width"`
// Height is Photo height.
Height int `json:"height"`
// Optional. File size.
FileSize int `json:"file_size,omitempty"`
}
PhotoSize represents one size of a photo or a file / sticker thumbnail.
type PollAnswer ¶ added in v1.1.4
type PollAnswer struct {
}
PollAnswer represents an answer of a user in a non-anonymous poll.
type PollOption ¶ added in v1.1.4
type PollOption struct {
}
PollOption contains information about one answer option in a poll.
type PreCheckoutQuery ¶
type PreCheckoutQuery struct {
//ID is unique query identifier.
ID string `json:"id"`
//From is user who sent the query.
From *User `json:"from"`
//Currency is a three-letter ISO 4217 currency code.
Currency string `json:"currency"`
// TotalAmount - total price in the smallest units of the currency (integer, not float/double).
// For example, for a price of US$ 1.45 pass amount = 145.
// See the exp parameter in currencies.json,
// it shows the number of digits past the decimal point
// for each currency (2 for the majority of currencies).
TotalAmount int `json:"total_amount"`
//InvoicePayload - bot-specified invoice payload.
InvoicePayload string `json:"invoice_payload"`
//ShippingOptionID. Optional. Identifier of the shipping option chosen by the user.
ShippingOptionID string `json:"shipping_option_id,omitempty"`
//OrderInfo. Optional. Order info provided by the user
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}
PreCheckoutQuery contains information about an incoming pre-checkout query.
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct {
// Array of button rows, each represented by an Array of KeyboardButton objects.
Keyboard [][]KeyboardButton `json:"keyboard"`
// ResizeKeyboard. Optional. 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 [][]KeyboardButton `json:"resize_keyboard,omitempty"`
// OneTimeKeyboard. Optional. Requests clients to hide the keyboard as soon as it's been used.
// The keyboard will still be available, but clients will automatically display
// the usual letter-keyboard in the chat – the user can press a special button
// in the input field to see the custom keyboard again. Defaults to false.
OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
// Selective. Optional. Use this parameter if you want to remove the keyboard for 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 reply_to_message_id), sender of the original message.
//
// Example: A user votes in a poll, bot returns confirmation message in reply
// to the vote and removes the keyboard for that user, while still showing
// the keyboard with poll options to users who haven't voted yet.
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardMarkup represents a custom keyboard with reply options (see Introduction to bots for details and examples).
type ReplyKeyboardRemove ¶
type ReplyKeyboardRemove struct {
RemoveKeyboard [][]InlineKeyboardButton `json:"remove_keyboard"`
// Selective. Optional. Use this parameter if you want to remove the keyboard for 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 reply_to_message_id), sender of the original message.
//
// Example: A user votes in a poll, bot returns confirmation message in reply
// to the vote and removes the keyboard for that user, while still showing
// the keyboard with poll options to users who haven't voted yet.
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardRemove is a Telegram API object.
Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button (see ReplyKeyboardMarkup).
type SendAudioOpt ¶
type SendAudioOpt struct {
// Caption is audio caption, 0-200 characters.
Caption string `json:"caption,omitempty"`
// Duration of the audio in seconds.
Duration uint `json:"duration,omitempty"`
// Performer of the track.
Performer string `json:"performer,omitempty"`
// Title is track name.
Title string `json:"title,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendAudioOpt represents optional params for SendAudio.
type SendContactOpt ¶
type SendContactOpt struct {
// LastName is contact's last name
LastName string `json:"last_name,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendContactOpt represents optional params for SendContact.
type SendDocumentOpt ¶
type SendDocumentOpt struct {
// Caption is document caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendDocumentOpt represents optional params for SendDocument.
type SendLocationOpt ¶
type SendLocationOpt struct {
// LivePeriod is period in seconds for which the location
// will be updated (see Live Locations), should be between 60 and 86400.
LivePeriod uint `json:"live_period,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendLocationOpt represents optional params for SendLocation.
type SendMessageOpt ¶
type SendMessageOpt struct {
// ParseMode - 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 ParseModes `json:"parse_mode,omitempty"`
// DisableWebPreview disables link previews for links in this message.
DisableWebPreview bool `json:"disable_web_page_preview,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendMessageOpt represents optional params for SendMessage.
type SendPhotoOpt ¶
type SendPhotoOpt struct {
// Caption is photo caption (may also be used when resending photos by file_id),
// 0-200 characters
Caption string `json:"caption,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendPhotoOpt represents optional params for SendPhoto.
type SendVenueOpt ¶
type SendVenueOpt struct {
// Foursquare is identifier of the venue.
FoursquareID string `json:"foursquare_id,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendVenueOpt represents optional params for SendVenue.
type SendVideoNoteOpt ¶
type SendVideoNoteOpt struct {
// Duration of sent video in seconds.
Duration uint `json:"duration,omitempty"`
// Length is optional video length in bytes.
Length uint `json:"width,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendVideoNoteOpt represents optional params for SendVideoNote.
type SendVideoOpt ¶
type SendVideoOpt struct {
// Caption is video caption (may also be used when resending photos by file_id),
// 0-200 characters
Caption string `json:"caption,omitempty"`
// Duration of sent video in seconds.
Duration int `json:"duration,omitempty"`
// Width is video width
Width int `json:"width,omitempty"`
// Height is video height.
Height int `json:"height,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendVideoOpt represents optional params for SendVideo.
type SendVoiceOpt ¶
type SendVoiceOpt struct {
// Caption is audio caption, 0-200 characters.
Caption string `json:"caption,omitempty"`
// Duration of the audio in seconds.
Duration uint `json:"duration,omitempty"`
// DisableNotification sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// ReplyToID is optional ID of the original message if the message is a reply.
ReplyToID int64 `json:"reply_to_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
SendVoiceOpt represents optional params for SendVoice.
type SetWebhookOpt ¶
type SetWebhookOpt struct {
// Certificate is optional file, your public key certificate
// so that the root certificate in use can be checked.
// See self-signed guide for details.
// https://core.telegram.org/bots/self-signed
Certificate *InputFile `json:"certificate,omitempty"`
// IPAddress is optional. The fixed IP address
// which will be used to send webhook requests
// instead of the IP address resolved through DNS.
IPAddress string `json:"ip_address,omitempty"`
// MaxConnections is maximum allowed number of simultaneous HTTPS connections
// to the webhook for update delivery, 1-100. Defaults to 40.
// Use lower values to limit the load on your bot‘s server,
// and higher values to increase your bot’s throughput.
MaxConnections int `json:"max_connections,omitempty"`
// AllowedUpdates lists types of updates you want your bot to receive.
// For example, specify [“message”, “edited_channel_post”,
// “callback_query”] to only receive updates of these types.
// See UpdateType for a complete list of available update types.
// Specify an empty list to receive all updates regardless
// of type (default). If not specified, the previous setting
// will be used.
//
// Please note that this parameter doesn't affect updates
// created before the call to the setWebhook, so unwanted
// updates may be received for a short period of time.
AllowedUpdates []UpdateType `json:"allowed_updates,omitempty"`
// DropPendingUpdates is optional. Pass True to drop all pending updates.
DropPendingUpdates bool `json:"drop_pending_updates,omitempty"`
// contains filtered or unexported fields
}
SetWebhookOpt represents optional params for SetWebhook.
type ShippingAddress ¶ added in v1.1.4
type ShippingAddress struct {
//CountryCode - ISO 3166-1 alpha-2 country code.
CountryCode string `json:"country_code"`
//State (province) if applicable.
State string `json:"state"`
//City of the address.
City string `json:"city"`
//StreetLine1 - First line for the address.
StreetLine1 string `json:"street_line1"`
//StreetLine2 - Second line for the address.
StreetLine2 string `json:"street_line2"`
//PostCode - address post code.
PostCode string `json:"post_code"`
}
ShippingAddress is a Telegram API object.
type ShippingQuery ¶
type ShippingQuery struct {
//ID is unique query identifier.
ID string `json:"id"`
// From is User who sent the query.
From *User `json:"from"`
//InvoicePayload - bot-specified invoice payload.
InvoicePayload string `json:"invoice_payload"`
//ShippingAddress is user-specified shipping address.
ShippingAddress *ShippingAddress `json:"shipping_address"`
}
ShippingQuery contains information about an incoming shipping query.
type StopMessageLiveLocationOpt ¶
type StopMessageLiveLocationOpt struct {
// ChatID is required if inline_message_id is not specified.
// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID interface{} `json:"chat_id,omitempty"`
// MessageID is required if inline_message_id is not specified.
// Identifier of the sent message
MessageID int64 `json:"message_id,omitempty"`
// InlineMessageID is required if ChatID and MessageID are not specified.
// Identifier of the inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// ReplyMarkup - additional interface options. A JSON-serialized object
// for an inline keyboard, custom reply keyboard,
// instructions to remove reply keyboard
// or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
// contains filtered or unexported fields
}
StopMessageLiveLocationOpt for StopMessageLiveLocation optional params.
type SuccessfulPayment ¶
type SuccessfulPayment struct {
// Currency is three-letter ISO 4217 currency code.
// https://core.telegram.org/bots/payments#supported-currencies
Currency string `json:"currency"`
// TotalAmount - total price in the smallest units of the currency
// (integer, not float/double). For example, for a price
// of US$ 1.45 pass amount = 145. See the exp parameter
// in https://core.telegram.org/bots/payments/currencies.json
// it shows the number of digits past the decimal point
// for each currency (2 for the majority of currencies,
// and zero for remaining ).
TotalAmount int `json:"total_amount"`
// InvoicePayload is a bot-specified invoice payload.
InvoicePayload string `json:"invoice_payload"`
// ShippingOptionID. Optional. Identifier of the shipping option chosen by the user
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// OrderInfo. Optional. Order info provided by the user
OrderInfo *OrderInfo `json:"order_info,omitempty"`
// TelegramPaymentChargeID is a Telegram payment identifier.
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
// ProviderPaymentChargeID is a Provider payment identifier.
ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
}
SuccessfulPayment contains basic information about a successful payment.
type Update ¶
type Update struct {
// ID is the update‘s unique identifier. Update identifiers start
// from a certain positive number and increase sequentially. This ID
// becomes especially handy if you’re using Webhooks, since it allows
// you to ignore repeated updates or to restore the correct update sequence,
// should they get out of order. If there are no new updates for at least a week,
// then identifier of the next update will be chosen randomly instead of sequentially.
ID uint64 `json:"update_id"`
// Message. Optional. New incoming message of any kind — text, photo, sticker, etc.
Message *Message `json:"message,omitempty"`
// EditedMessage. Optional. New version of a message that is known to the bot and was edited.
EditedMessage *Message `json:"edited_message,omitempty"`
// ChannelPost. Optional. New incoming channel post of any kind — text, photo, sticker, etc.
ChannelPost *Message `json:"channel_post,omitempty"`
// EditedChannelPost. Optional. New version of a channel post that is known to the bot and was edited.
EditedChannelPost *Message `json:"edited_channel_post,omitempty"`
// InlineQuery. Optional. New incoming inline query.
InlineQuery *InlineQuery `json:"inline_query,omitempty"`
// ChosenInlineResult. Optional. The result of an inline query that was chosen
// by a user and sent to their chat partner. Please see our
// documentation on the feedback collecting for details
// on how to enable these updates for your bot.
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
// CallbackQuery. Optional. New incoming callback query.
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
// ShippingQuery. Optional. New incoming shipping query.
// Only for invoices with flexible price.
ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
// PreCheckoutQuery. Optional. New incoming pre-checkout query.
// Contains full information about checkout
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
// Poll. Optional. New poll state. Bots receive only updates
// about stopped polls and polls, which are sent by the bot.
Poll *Poll `json:"poll,omitempty"`
// PollAnswer. Optional. A user changed their answer in a non-anonymous poll.
// Bots receive new votes only in polls that were sent by the bot itself.
PollAnswer *PollAnswer `json:"poll_answer,omitempty"`
}
Update represents an incoming update. At most one of the optional parameters can be present in any given update.
type UpdateType ¶ added in v1.1.4
type UpdateType string
type User ¶
type User struct {
// User‘s or bot’s id
ID int64 `json:"id"`
// IsBot - true for bot.
IsBot bool `json:"is_bot"`
// FirstName. User‘s or bot’s first name.
FirstName string `json:"first_name"`
// LastName. Optional. User‘s or bot’s last name
LastName string `json:"last_name"`
// UserName. Optional. User‘s or bot’s username
UserName string `json:"username,omitempty"`
// LanguageCode. Optional. IETF language tag of the user's language
LanguageCode string `json:"language_code,omitempty"`
// CanJoinGroups. True, if the bot can be invited to groups. Returned only in getMe.
CanJoinGroups bool `json:"can_join_groups,omitempty"`
// CanReadAllGroupMessages. True, if privacy mode is disabled for the bot. Returned only in getMe.
CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
// SupportsInlineQueries. Optional. True, if the bot supports inline queries. Returned only in getMe.
SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
}
User represents a Telegram user or bot.
type UserProfilePhotos ¶ added in v1.1.4
type UserProfilePhotos struct {
// TotalCount is total number of profile pictures the target user has.
TotalCount int `json:"total_count"`
// Photos - requested profile pictures (in up to 4 sizes each).
Photos [][]PhotoSize `json:"photos"`
}
UserProfilePhotos represent a user's profile pictures.
type Venue ¶
type Venue struct {
// Location is Venue location.
Location *Location `json:"location"`
// Title is Name of the venue.
Title string `json:"title"`
// Address of the venue.
Address string `json:"address"`
// FoursquareID. Optional. Foursquare identifier of the venue.
FoursquareID string `json:"foursquare_id,omitempty"`
// FoursquareType. Optional. Foursquare type of the venue.
// (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.)
FoursquareType string `json:"foursquare_type"`
}
Venue represents a place, meeting point, event point.
type Video ¶
type Video struct {
// ID is unique identifier for this file.
ID string `json:"file_id"`
// Width. Video width as defined by sender.
Width int `json:"width"`
// Height. Video height as defined by sender.
Height int `json:"height"`
// Duration of the video in seconds as defined by sender.
Duration int `json:"duration"`
// Thumb. Optional. Video thumbnail.
Thumb *PhotoSize `json:"thumb,omitempty"`
// MIMEType. Optional. Mime type of a file as defined by sender
MIMEType string `json:"mime_type,omitempty"`
// FileSize. Optional. File size bytes.
FileSize int `json:"file_size,omitempty"`
}
Video represents a video file.
type VideoNote ¶
type VideoNote struct {
// ID is unique identifier for this file.
ID string `json:"file_id"`
// Length. Video width and height as defined by sender
Length int `json:"length"`
// Duration of the video in seconds as defined by sender.
Duration int `json:"duration"`
// Thumb. Optional. Video thumbnail.
Thumb *PhotoSize `json:"thumb,omitempty"`
// FileSize. Optional. File size bytes.
FileSize int `json:"file_size,omitempty"`
}
VideoNote represents a video message (available in Telegram apps as of v.4.0).
type Voice ¶
type Voice struct {
// ID is unique identifier for this file.
ID string `json:"file_id"`
// Duration of the audio in seconds as defined by sender.
Duration int `json:"duration"`
// MIMEType. Optional. MIME type of the file as defined by sender.
MIMEType string `json:"mime_type,omitempty"`
// FileSize. Optional. File size.
FileSize int `json:"file_size,omitempty"`
}
Voice represents a voice note.
type WebhookInfo ¶ added in v1.2.1
type WebhookInfo struct {
// URL may be empty if webhook is not set up.
URL string `json:"url"`
// HasCustomCertificate true, if a custom certificate was provided
// for webhook certificate checks.
HasCustomCertificate bool `json:"has_custom_certificate"`
//PendingUpdateCount is number of updates awaiting delivery.
PendingUpdateCount int `json:"pending_update_count"`
//IPAddress is optional. Currently used webhook IP address.
IPAddress string `json:"ip_address,omitempty"`
// LastErrorDate is optional. Unix time for the most recent error
// that happened when trying to deliver an update via webhook.
LastErrorDate int `json:"last_error_date,omitempty"`
// LastErrorMessage is optional. Error message in human-readable format
// for the most recent error that happened when trying to deliver an update via webhook.
LastErrorMessage string `json:"last_error_message,omitempty"`
// LastSynchronizationErrorDate is optional. Unix time of the most recent error
// that happened when trying to synchronize available updates with Telegram datacenters.
LastSynchronizationErrorDate int `json:"last_synchronization_error_date,omitempty"`
// MaxConnections is optional. Maximum allowed number of simultaneous
// HTTPS connections to the webhook for update delivery.
MaxConnections int `json:"max_connections,omitempty"`
//AllowedUpdates is optional. A list of update types
//the bot is subscribed to. Defaults to all update types except chat_member.
AllowedUpdates []string `json:"allowed_updates,omitempty"`
}
WebhookInfo contains information about the current status of a webhook.
Source Files
¶
- a-tgwrap.go
- a-transport.go
- api-Inline-keyboard.go
- api-animation.go
- api-audio.go
- api-callback-query.go
- api-chat-permissions.go
- api-chat-photo.go
- api-chat.go
- api-chosen-inline-result.go
- api-contact.go
- api-document.go
- api-file.go
- api-force-reply.go
- api-game.go
- api-inline-query.go
- api-input-file.go
- api-invoice.go
- api-location.go
- api-message-entity.go
- api-message.go
- api-order-info.go
- api-passport-data.go
- api-photo-size.go
- api-poll.go
- api-precheckout-query.go
- api-reply-keyboard.go
- api-shipping-address.go
- api-shipping-query.go
- api-sticker.go
- api-successful-payment.go
- api-update.go
- api-user-profile-photos.go
- api-user.go
- api-venue.go
- api-video-note.go
- api-video.go
- api-voice.go
- api-webhook-info.go
- doc.go
- interface-bot-chat.go
- interface-bot-contacts.go
- interface-bot-location.go
- interface-bot-media.go
- interface-bot-messages.go
- interface-bot-updates.go
- interface-bot.go
- wrap-delete-webhook.go
- wrap-edit-message-live-location.go
- wrap-forward-message.go
- wrap-get-file.go
- wrap-get-me.go
- wrap-get-updates.go
- wrap-get-user-profile-photos.go
- wrap-get-webhook-info.go
- wrap-send-audio.go
- wrap-send-chat-action.go
- wrap-send-contact.go
- wrap-send-document.go
- wrap-send-location.go
- wrap-send-message.go
- wrap-send-photo.go
- wrap-send-venue.go
- wrap-send-video-note.go
- wrap-send-video.go
- wrap-send-voice.go
- wrap-set-chat-title.go
- wrap-set-webhook.go
- wrap-stop-message-live-location.go
- wrap-unban-chat-member.go