Documentation ¶
Overview ¶
Package tgbotapi has functions and types used for interacting with the Telegram Bot API.
Index ¶
- Constants
- func EscapeText(parseMode string, text string) string
- func SetLogger(logger BotLogger) error
- type APIResponse
- type Animation
- type AnimationConfig
- type Audio
- type AudioConfig
- type BaseChat
- type BaseEdit
- type BaseFile
- type BotAPI
- func (bot *BotAPI) AnswerCallbackQuery(config CallbackConfig) (APIResponse, error)
- func (bot *BotAPI) AnswerInlineQuery(config InlineConfig) (APIResponse, error)
- func (bot *BotAPI) AnswerPreCheckoutQuery(config PreCheckoutConfig) (APIResponse, error)
- func (bot *BotAPI) AnswerShippingQuery(config ShippingConfig) (APIResponse, error)
- func (bot *BotAPI) DeleteChatPhoto(config DeleteChatPhotoConfig) (APIResponse, error)
- func (bot *BotAPI) DeleteMessage(config DeleteMessageConfig) (APIResponse, error)
- func (bot *BotAPI) GetChat(config ChatConfig) (Chat, error)
- func (bot *BotAPI) GetChatAdministrators(config ChatConfig) ([]ChatMember, error)
- func (bot *BotAPI) GetChatMember(config ChatConfigWithUser) (ChatMember, error)
- func (bot *BotAPI) GetChatMembersCount(config ChatConfig) (int, error)
- func (bot *BotAPI) GetFile(config FileConfig) (File, error)
- func (bot *BotAPI) GetFileDirectURL(fileID string) (string, error)
- func (bot *BotAPI) GetGameHighScores(config GetGameHighScoresConfig) ([]GameHighScore, error)
- func (bot *BotAPI) GetInviteLink(config ChatConfig) (string, error)
- func (bot *BotAPI) GetMe() (User, error)
- func (bot *BotAPI) GetMyCommands() ([]BotCommand, error)
- func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
- func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error)
- func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error)
- func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error)
- func (bot *BotAPI) GetWebhookInfo() (WebhookInfo, error)
- func (bot *BotAPI) HandleUpdate(r *http.Request) (*Update, error)
- func (bot *BotAPI) IsMessageToMe(message Message) bool
- func (bot *BotAPI) KickChatMember(config KickChatMemberConfig) (APIResponse, error)
- func (bot *BotAPI) LeaveChat(config ChatConfig) (APIResponse, error)
- func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel
- func (bot *BotAPI) MakeRequest(endpoint string, params url.Values) (APIResponse, error)
- func (bot *BotAPI) PinChatMessage(config PinChatMessageConfig) (APIResponse, error)
- func (bot *BotAPI) PromoteChatMember(config PromoteChatMemberConfig) (APIResponse, error)
- func (bot *BotAPI) RemoveWebhook() (APIResponse, error)
- func (bot *BotAPI) RestrictChatMember(config RestrictChatMemberConfig) (APIResponse, error)
- func (bot *BotAPI) Send(c Chattable) (Message, error)
- func (bot *BotAPI) SetAPIEndpoint(apiEndpoint string)
- func (bot *BotAPI) SetChatDescription(config SetChatDescriptionConfig) (APIResponse, error)
- func (bot *BotAPI) SetChatPhoto(config SetChatPhotoConfig) (APIResponse, error)
- func (bot *BotAPI) SetChatTitle(config SetChatTitleConfig) (APIResponse, error)
- func (bot *BotAPI) SetMyCommands(commands []BotCommand) error
- func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error)
- func (bot *BotAPI) StopReceivingUpdates()
- func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error)
- func (bot *BotAPI) UnpinChatMessage(config UnpinChatMessageConfig) (APIResponse, error)
- func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldname string, file interface{}) (APIResponse, error)
- type BotCommand
- type BotLogger
- type CallbackConfig
- type CallbackGame
- type CallbackQuery
- type Chat
- type ChatActionConfig
- type ChatAnimation
- type ChatConfig
- type ChatConfigWithUser
- type ChatMember
- type ChatMemberConfig
- type ChatPhoto
- type Chattable
- type ChosenInlineResult
- type Contact
- type ContactConfig
- type Credentials
- type DataCredentials
- type DeleteChatPhotoConfig
- type DeleteMessageConfig
- type DiceConfig
- type Document
- type DocumentConfig
- type EditMessageCaptionConfig
- type EditMessageReplyMarkupConfig
- type EditMessageTextConfig
- type EncryptedCredentials
- type EncryptedPassportElement
- type Error
- type File
- type FileBytes
- type FileConfig
- type FileCredentials
- type FileReader
- type Fileable
- type ForceReply
- type ForwardConfig
- type Game
- type GameConfig
- type GameHighScore
- type GetGameHighScoresConfig
- type GetStickerSetConfig
- type GroupChat
- type HttpClient
- type IDDocumentData
- type InlineConfig
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type InlineQuery
- type InlineQueryResultArticle
- func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle
- func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryResultArticle
- func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle
- func NewInlineQueryResultArticleMarkdownV2(id, title, messageText string) InlineQueryResultArticle
- type InlineQueryResultAudio
- type InlineQueryResultCachedAudio
- type InlineQueryResultCachedDocument
- type InlineQueryResultCachedGIF
- type InlineQueryResultCachedMpeg4Gif
- type InlineQueryResultCachedPhoto
- type InlineQueryResultCachedSticker
- type InlineQueryResultCachedVideo
- type InlineQueryResultCachedVoice
- type InlineQueryResultDocument
- type InlineQueryResultGIF
- type InlineQueryResultGame
- type InlineQueryResultLocation
- type InlineQueryResultMPEG4GIF
- type InlineQueryResultPhoto
- type InlineQueryResultVenue
- type InlineQueryResultVideo
- type InlineQueryResultVoice
- type InputContactMessageContent
- type InputLocationMessageContent
- type InputMediaPhoto
- type InputMediaVideo
- type InputTextMessageContent
- type InputVenueMessageContent
- type Invoice
- type InvoiceConfig
- type KeyboardButton
- type KickChatMemberConfig
- type LabeledPrice
- type Location
- type LocationConfig
- type MediaGroupConfig
- type Message
- type MessageConfig
- type MessageEntity
- func (e MessageEntity) IsBold() bool
- func (e MessageEntity) IsCode() bool
- func (e MessageEntity) IsCommand() bool
- func (e MessageEntity) IsEmail() bool
- func (e MessageEntity) IsHashtag() bool
- func (e MessageEntity) IsItalic() bool
- func (e MessageEntity) IsMention() bool
- func (e MessageEntity) IsPre() bool
- func (e MessageEntity) IsTextLink() bool
- func (e MessageEntity) IsUrl() bool
- func (e MessageEntity) ParseURL() (*url.URL, error)
- type OrderInfo
- type Params
- func (p Params) AddBool(key string, value bool)
- func (p Params) AddFirstValid(key string, args ...interface{}) error
- func (p Params) AddInterface(key string, value interface{}) error
- func (p Params) AddNonEmpty(key, value string)
- func (p Params) AddNonZero(key string, value int)
- func (p Params) AddNonZero64(key string, value int64)
- func (p Params) AddNonZeroFloat(key string, value float64)
- type PassportData
- type PassportElementError
- type PassportElementErrorDataField
- type PassportElementErrorFile
- type PassportElementErrorFiles
- type PassportElementErrorFrontSide
- type PassportElementErrorReverseSide
- type PassportElementErrorSelfie
- type PassportFile
- type PassportRequestInfoConfig
- type PassportScope
- type PassportScopeElement
- type PassportScopeElementOne
- type PassportScopeElementOneOfSeveral
- type PersonalDetails
- type PhotoConfig
- type PhotoSize
- type PinChatMessageConfig
- type PreCheckoutConfig
- type PreCheckoutQuery
- type PromoteChatMemberConfig
- type ReplyKeyboardHide
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type ResponseParameters
- type RestrictChatMemberConfig
- type SecureData
- type SecureValue
- type SendPollConfig
- type SetChatDescriptionConfig
- type SetChatPhotoConfig
- type SetChatTitleConfig
- type SetGameScoreConfig
- type ShippingAddress
- type ShippingConfig
- type ShippingOption
- type ShippingQuery
- type Sticker
- type StickerConfig
- type StickerSet
- type SuccessfulPayment
- type UnpinChatMessageConfig
- type Update
- type UpdateConfig
- type UpdatesChannel
- type User
- type UserProfilePhotos
- type UserProfilePhotosConfig
- type Venue
- type VenueConfig
- type Video
- type VideoConfig
- type VideoNote
- type VideoNoteConfig
- type Voice
- type VoiceConfig
- type WebhookConfig
- type WebhookInfo
Examples ¶
Constants ¶
const ( // APIEndpoint is the endpoint for all API methods, // with formatting for Sprintf. APIEndpoint = "https://api.telegram.org/bot%s/%s" // FileEndpoint is the endpoint for downloading a file from Telegram. FileEndpoint = "https://api.telegram.org/file/bot%s/%s" )
Telegram constants
const ( ChatTyping = "typing" ChatUploadPhoto = "upload_photo" ChatRecordVideo = "record_video" ChatUploadVideo = "upload_video" ChatRecordAudio = "record_audio" ChatUploadAudio = "upload_audio" ChatUploadDocument = "upload_document" ChatFindLocation = "find_location" )
Constant values for ChatActions
const ( ModeMarkdown = "Markdown" ModeMarkdownV2 = "MarkdownV2" ModeHTML = "HTML" )
Constant values for ParseMode in MessageConfig
const ( // ErrBadFileType happens when you pass an unknown type ErrBadFileType = "bad file type" ErrBadURL = "bad or empty url" )
Library errors
const (
// ErrAPIForbidden happens when a token is bad
ErrAPIForbidden = "forbidden"
)
API errors
Variables ¶
This section is empty.
Functions ¶
func EscapeText ¶
EscapeText takes an input text and escape Telegram markup symbols. In this way we can send a text without being afraid of having to escape the characters manually. Note that you don't have to include the formatting style in the input text, or it will be escaped too. If there is an error, an empty string will be returned.
parseMode is the text formatting mode (ModeMarkdown, ModeMarkdownV2 or ModeHTML) text is the input string that will be escaped
Types ¶
type APIResponse ¶
type APIResponse struct { Ok bool `json:"ok"` Result json.RawMessage `json:"result"` ErrorCode int `json:"error_code"` Description string `json:"description"` Parameters *ResponseParameters `json:"parameters"` }
APIResponse is a response from the Telegram API with the result stored raw.
type Animation ¶
type Animation struct { // FileID identifier for this file, which can be used to download or reuse the file. FileID string `json:"file_id"` // Thumb animation thumbnail as defined by sender. // // optional Thumb PhotoSize `json:"thumb"` // FileName original animation filename as defined by sender. // // optional FileName string `json:"file_name"` // MimeType of the file as defined by sender. // // optional MimeType string `json:"mime_type"` // FileSize ile size // // optional FileSize int `json:"file_size"` }
Animation is a GIF animation demonstrating the game.
type AnimationConfig ¶
AnimationConfig contains information about a SendAnimation request.
func NewAnimationShare ¶
func NewAnimationShare(chatID int64, fileID string) AnimationConfig
NewAnimationShare shares an existing animation. You may use this to reshare an existing animation without reuploading it.
chatID is where to send it, fileID is the ID of the animation already uploaded.
func NewAnimationUpload ¶
func NewAnimationUpload(chatID int64, file interface{}) AnimationConfig
NewAnimationUpload creates a new animation uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type Audio ¶
type Audio struct { // FileID is an identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // Duration of the audio in seconds as defined by sender Duration int `json:"duration"` // Performer of the audio as defined by sender or by audio tags // // optional Performer string `json:"performer"` // Title of the audio as defined by sender or by audio tags // // optional Title string `json:"title"` // MimeType of the file as defined by sender // // optional MimeType string `json:"mime_type"` // FileSize file size // // optional FileSize int `json:"file_size"` }
Audio contains information about audio.
type AudioConfig ¶
type AudioConfig struct { BaseFile Caption string ParseMode string Duration int Performer string Title string }
AudioConfig contains information about a SendAudio request.
func NewAudioShare ¶
func NewAudioShare(chatID int64, fileID string) AudioConfig
NewAudioShare shares an existing audio file. You may use this to reshare an existing audio file without reuploading it.
chatID is where to send it, fileID is the ID of the audio already uploaded.
func NewAudioUpload ¶
func NewAudioUpload(chatID int64, file interface{}) AudioConfig
NewAudioUpload creates a new audio uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type BaseChat ¶
type BaseChat struct { ChatID int64 // required ChannelUsername string ReplyToMessageID int ReplyMarkup interface{} DisableNotification bool }
BaseChat is base type for all chat config types.
type BaseEdit ¶
type BaseEdit struct { ChatID int64 ChannelUsername string MessageID int InlineMessageID string ReplyMarkup *InlineKeyboardMarkup }
BaseEdit is base type of all chat edits.
type BaseFile ¶
type BaseFile struct { BaseChat File interface{} FileID string UseExisting bool MimeType string FileSize int }
BaseFile is a base type for all file config types.
type BotAPI ¶
type BotAPI struct { Token string `json:"token"` Debug bool `json:"debug"` Buffer int `json:"buffer"` Self User `json:"-"` Client HttpClient `json:"-"` // contains filtered or unexported fields }
BotAPI allows you to interact with the Telegram Bot API.
func NewBotAPI ¶
NewBotAPI creates a new BotAPI instance.
It requires a token, provided by @BotFather on Telegram.
Example ¶
package main import ( "log" "time" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" ) func main() { bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") if err != nil { log.Panic(err) } bot.Debug = true log.Printf("Authorized on account %s", bot.Self.UserName) u := tgbotapi.NewUpdate(0) u.Timeout = 60 updates, err := bot.GetUpdatesChan(u) // Optional: wait for updates and clear them if you don't want to handle // a large backlog of old messages time.Sleep(time.Millisecond * 500) updates.Clear() for update := range updates { if update.Message == nil { continue } log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text) msg.ReplyToMessageID = update.Message.MessageID bot.Send(msg) } }
Output:
func NewBotAPIWithAPIEndpoint ¶
NewBotAPIWithAPIEndpoint creates a new BotAPI instance and allows you to pass API endpoint.
It requires a token, provided by @BotFather on Telegram and API endpoint.
func NewBotAPIWithClient ¶
func NewBotAPIWithClient(token, apiEndpoint string, client HttpClient) (*BotAPI, error)
NewBotAPIWithClient creates a new BotAPI instance and allows you to pass a http.Client.
It requires a token, provided by @BotFather on Telegram and API endpoint.
func (*BotAPI) AnswerCallbackQuery ¶
func (bot *BotAPI) AnswerCallbackQuery(config CallbackConfig) (APIResponse, error)
AnswerCallbackQuery sends a response to an inline query callback.
func (*BotAPI) AnswerInlineQuery ¶
func (bot *BotAPI) AnswerInlineQuery(config InlineConfig) (APIResponse, error)
AnswerInlineQuery sends a response to an inline query.
Note that you must respond to an inline query within 30 seconds.
func (*BotAPI) AnswerPreCheckoutQuery ¶
func (bot *BotAPI) AnswerPreCheckoutQuery(config PreCheckoutConfig) (APIResponse, error)
AnswerPreCheckoutQuery allows you to reply to Update with pre_checkout_query.
func (*BotAPI) AnswerShippingQuery ¶
func (bot *BotAPI) AnswerShippingQuery(config ShippingConfig) (APIResponse, error)
AnswerShippingQuery allows you to reply to Update with shipping_query parameter.
func (*BotAPI) DeleteChatPhoto ¶
func (bot *BotAPI) DeleteChatPhoto(config DeleteChatPhotoConfig) (APIResponse, error)
DeleteChatPhoto delete photo of chat.
func (*BotAPI) DeleteMessage ¶
func (bot *BotAPI) DeleteMessage(config DeleteMessageConfig) (APIResponse, error)
DeleteMessage deletes a message in a chat
func (*BotAPI) GetChat ¶
func (bot *BotAPI) GetChat(config ChatConfig) (Chat, error)
GetChat gets information about a chat.
func (*BotAPI) GetChatAdministrators ¶
func (bot *BotAPI) GetChatAdministrators(config ChatConfig) ([]ChatMember, error)
GetChatAdministrators gets a list of administrators in the chat.
If none have been appointed, only the creator will be returned. Bots are not shown, even if they are an administrator.
func (*BotAPI) GetChatMember ¶
func (bot *BotAPI) GetChatMember(config ChatConfigWithUser) (ChatMember, error)
GetChatMember gets a specific chat member.
func (*BotAPI) GetChatMembersCount ¶
func (bot *BotAPI) GetChatMembersCount(config ChatConfig) (int, error)
GetChatMembersCount gets the number of users in a chat.
func (*BotAPI) GetFile ¶
func (bot *BotAPI) GetFile(config FileConfig) (File, error)
GetFile returns a File which can download a file from Telegram.
Requires FileID.
func (*BotAPI) GetFileDirectURL ¶
GetFileDirectURL returns direct URL to file
It requires the FileID.
func (*BotAPI) GetGameHighScores ¶
func (bot *BotAPI) GetGameHighScores(config GetGameHighScoresConfig) ([]GameHighScore, error)
GetGameHighScores allows you to get the high scores for a game.
func (*BotAPI) GetInviteLink ¶
func (bot *BotAPI) GetInviteLink(config ChatConfig) (string, error)
GetInviteLink get InviteLink for a chat
func (*BotAPI) GetMe ¶
GetMe fetches the currently authenticated bot.
This method is called upon creation to validate the token, and so you may get this data from BotAPI.Self without the need for another request.
func (*BotAPI) GetMyCommands ¶
func (bot *BotAPI) GetMyCommands() ([]BotCommand, error)
GetMyCommands gets the current list of the bot's commands.
func (*BotAPI) GetStickerSet ¶
func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
GetStickerSet get a sticker set.
func (*BotAPI) GetUpdates ¶
func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error)
GetUpdates fetches updates. If a WebHook is set, this will not return any data!
Offset, Limit, and Timeout are optional. To avoid stale items, set Offset to one higher than the previous item. Set Timeout to a large number to reduce requests so you can get updates instantly instead of having to wait between requests.
func (*BotAPI) GetUpdatesChan ¶
func (bot *BotAPI) GetUpdatesChan(config UpdateConfig) (UpdatesChannel, error)
GetUpdatesChan starts and returns a channel for getting updates.
func (*BotAPI) GetUserProfilePhotos ¶
func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error)
GetUserProfilePhotos gets a user's profile photos.
It requires UserID. Offset and Limit are optional.
func (*BotAPI) GetWebhookInfo ¶
func (bot *BotAPI) GetWebhookInfo() (WebhookInfo, error)
GetWebhookInfo allows you to fetch information about a webhook and if one currently is set, along with pending update count and error messages.
func (*BotAPI) HandleUpdate ¶
HandleUpdate parses and returns update received via webhook
func (*BotAPI) IsMessageToMe ¶
IsMessageToMe returns true if message directed to this bot.
It requires the Message.
func (*BotAPI) KickChatMember ¶
func (bot *BotAPI) KickChatMember(config KickChatMemberConfig) (APIResponse, error)
KickChatMember kicks a user from a chat. Note that this only will work in supergroups, and requires the bot to be an admin. Also note they will be unable to rejoin until they are unbanned.
func (*BotAPI) LeaveChat ¶
func (bot *BotAPI) LeaveChat(config ChatConfig) (APIResponse, error)
LeaveChat makes the bot leave the chat.
func (*BotAPI) ListenForWebhook ¶
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel
ListenForWebhook registers a http handler for a webhook.
func (*BotAPI) MakeRequest ¶
MakeRequest makes a request to a specific endpoint with our token.
func (*BotAPI) PinChatMessage ¶
func (bot *BotAPI) PinChatMessage(config PinChatMessageConfig) (APIResponse, error)
PinChatMessage pin message in supergroup
func (*BotAPI) PromoteChatMember ¶
func (bot *BotAPI) PromoteChatMember(config PromoteChatMemberConfig) (APIResponse, error)
PromoteChatMember add admin rights to user
func (*BotAPI) RemoveWebhook ¶
func (bot *BotAPI) RemoveWebhook() (APIResponse, error)
RemoveWebhook unsets the webhook.
func (*BotAPI) RestrictChatMember ¶
func (bot *BotAPI) RestrictChatMember(config RestrictChatMemberConfig) (APIResponse, error)
RestrictChatMember to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
func (*BotAPI) Send ¶
Send will send a Chattable item to Telegram.
It requires the Chattable to send.
func (*BotAPI) SetAPIEndpoint ¶
SetAPIEndpoint add telegram apiEndpont to Bot
func (*BotAPI) SetChatDescription ¶
func (bot *BotAPI) SetChatDescription(config SetChatDescriptionConfig) (APIResponse, error)
SetChatDescription change description of chat.
func (*BotAPI) SetChatPhoto ¶
func (bot *BotAPI) SetChatPhoto(config SetChatPhotoConfig) (APIResponse, error)
SetChatPhoto change photo of chat.
func (*BotAPI) SetChatTitle ¶
func (bot *BotAPI) SetChatTitle(config SetChatTitleConfig) (APIResponse, error)
SetChatTitle change title of chat.
func (*BotAPI) SetMyCommands ¶
func (bot *BotAPI) SetMyCommands(commands []BotCommand) error
SetMyCommands changes the list of the bot's commands.
func (*BotAPI) SetWebhook ¶
func (bot *BotAPI) SetWebhook(config WebhookConfig) (APIResponse, error)
SetWebhook sets a webhook.
If this is set, GetUpdates will not get any data!
If you do not have a legitimate TLS certificate, you need to include your self signed certificate with the config.
func (*BotAPI) StopReceivingUpdates ¶
func (bot *BotAPI) StopReceivingUpdates()
StopReceivingUpdates stops the go routine which receives updates
func (*BotAPI) UnbanChatMember ¶
func (bot *BotAPI) UnbanChatMember(config ChatMemberConfig) (APIResponse, error)
UnbanChatMember unbans a user from a chat. Note that this only will work in supergroups and channels, and requires the bot to be an admin.
func (*BotAPI) UnpinChatMessage ¶
func (bot *BotAPI) UnpinChatMessage(config UnpinChatMessageConfig) (APIResponse, error)
UnpinChatMessage unpin message in supergroup
func (*BotAPI) UploadFile ¶
func (bot *BotAPI) UploadFile(endpoint string, params map[string]string, fieldname string, file interface{}) (APIResponse, error)
UploadFile makes a request to the API with a file.
Requires the parameter to hold the file not be in the params. File should be a string to a file path, a FileBytes struct, a FileReader struct, or a url.URL.
Note that if your FileReader has a size set to -1, it will read the file into memory to calculate a size.
type BotCommand ¶
type BotCommand struct { // Command text of the command, 1-32 characters. // Can contain only lowercase English letters, digits and underscores. Command string `json:"command"` // Description of the command, 3-256 characters. Description string `json:"description"` }
BotCommand represents a bot command.
type BotLogger ¶
type BotLogger interface { Println(v ...interface{}) Printf(format string, v ...interface{}) }
BotLogger is an interface that represents the required methods to log data.
Instead of requiring the standard logger, we can just specify the methods we use and allow users to pass anything that implements these.
type CallbackConfig ¶
type CallbackConfig struct { CallbackQueryID string `json:"callback_query_id"` Text string `json:"text"` ShowAlert bool `json:"show_alert"` URL string `json:"url"` CacheTime int `json:"cache_time"` }
CallbackConfig contains information on making a CallbackQuery response.
func NewCallback ¶
func NewCallback(id, text string) CallbackConfig
NewCallback creates a new callback message.
func NewCallbackWithAlert ¶
func NewCallbackWithAlert(id, text string) CallbackConfig
NewCallbackWithAlert creates a new callback message that alerts the user.
type CallbackGame ¶
type CallbackGame struct{}
CallbackGame is for starting a game in an inline keyboard button.
type CallbackQuery ¶
type CallbackQuery struct { // ID unique identifier for this query ID string `json:"id"` // From sender From *User `json:"from"` // 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. // // optional Message *Message `json:"message"` // InlineMessageID identifier of the message sent via the bot in inline mode, that originated the query. // // optional // InlineMessageID string `json:"inline_message_id"` // 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 associated with the callback button. Be aware that // a bad client can send arbitrary data in this field. // // optional Data string `json:"data"` // GameShortName short name of a Game to be returned, serves as the unique identifier for the game. // // optional GameShortName string `json:"game_short_name"` }
CallbackQuery is data sent when a keyboard button with callback data is clicked.
type Chat ¶
type Chat struct { // ID is a 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 for supergroups, channels and group chats // // optional Title string `json:"title"` // UserName for private chats, supergroups and channels if available // // optional UserName string `json:"username"` // FirstName of the other party in a private chat // // optional FirstName string `json:"first_name"` // LastName of the other party in a private chat // // optional LastName string `json:"last_name"` // AllMembersAreAdmins // // optional AllMembersAreAdmins bool `json:"all_members_are_administrators"` // Photo is a chat photo Photo *ChatPhoto `json:"photo"` // Description for groups, supergroups and channel chats // // optional Description string `json:"description,omitempty"` // InviteLink is a chat invite link, for groups, supergroups and channel chats. // Each administrator in a chat generates their own invite links, // so the bot must first generate the link using exportChatInviteLink // // optional InviteLink string `json:"invite_link,omitempty"` // PinnedMessage Pinned message, for groups, supergroups and channels // // optional PinnedMessage *Message `json:"pinned_message"` }
Chat contains information about the place a message was sent.
func (Chat) ChatConfig ¶
func (c Chat) ChatConfig() ChatConfig
ChatConfig returns a ChatConfig struct for chat related methods.
func (Chat) IsSuperGroup ¶
IsSuperGroup returns if the Chat is a supergroup.
type ChatActionConfig ¶
ChatActionConfig contains information about a SendChatAction request.
func NewChatAction ¶
func NewChatAction(chatID int64, action string) ChatActionConfig
NewChatAction sets a chat action. Actions last for 5 seconds, or until your next action.
chatID is where to send it, action should be set via Chat constants.
type ChatAnimation ¶
type ChatAnimation struct { // FileID odentifier for this file, which can be used to download or reuse the file FileID 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"` // Thumbnail animation thumbnail as defined by sender // // optional Thumbnail *PhotoSize `json:"thumb"` // FileName original animation filename as defined by sender // // optional FileName string `json:"file_name"` // MimeType of the file as defined by sender // // optional MimeType string `json:"mime_type"` // FileSize file size // // optional FileSize int `json:"file_size"` }
ChatAnimation contains information about an animation.
type ChatConfig ¶
ChatConfig contains information about getting information on a chat.
type ChatConfigWithUser ¶
ChatConfigWithUser contains information about getting information on a specific user within a chat.
type ChatMember ¶
type ChatMember struct { // User information about the user User *User `json:"user"` // Status the member's status in the chat. // Can be // “creator”, // “administrator”, // “member”, // “restricted”, // “left” or // “kicked” Status string `json:"status"` // CustomTitle owner and administrators only. Custom title for this user // // optional CustomTitle string `json:"custom_title,omitempty"` // UntilDate restricted and kicked only. // Date when restrictions will be lifted for this user; // unix time. // // optional UntilDate int64 `json:"until_date,omitempty"` // CanBeEdited administrators only. // True, if the bot is allowed to edit administrator privileges of that user. // // optional CanBeEdited bool `json:"can_be_edited,omitempty"` // CanChangeInfo administrators and restricted only. // True, if the user is allowed to change the chat title, photo and other settings. // // optional CanChangeInfo bool `json:"can_change_info,omitempty"` // CanChangeInfo administrators only. // True, if the administrator can post in the channel; // channels only. // // optional CanPostMessages bool `json:"can_post_messages,omitempty"` // CanEditMessages administrators only. // True, if the administrator can edit messages of other users and can pin messages; // channels only. // // optional CanEditMessages bool `json:"can_edit_messages,omitempty"` // CanDeleteMessages administrators only. // True, if the administrator can delete messages of other users. // // optional CanDeleteMessages bool `json:"can_delete_messages,omitempty"` // CanInviteUsers administrators and restricted only. // True, if the user is allowed to invite new users to the chat. // // optional CanInviteUsers bool `json:"can_invite_users,omitempty"` // CanRestrictMembers administrators only. // True, if the administrator can restrict, ban or unban chat members. // // optional CanRestrictMembers bool `json:"can_restrict_members,omitempty"` // CanPinMessages // // optional CanPinMessages bool `json:"can_pin_messages,omitempty"` // CanPromoteMembers administrators only. // True, if the administrator can add new administrators // with a subset of their own privileges or demote administrators that he has promoted, // directly or indirectly (promoted by administrators that were appointed by the user). // // optional CanPromoteMembers bool `json:"can_promote_members,omitempty"` // CanSendMessages // // optional CanSendMessages bool `json:"can_send_messages,omitempty"` // CanSendMediaMessages restricted only. // True, if the user is allowed to send text messages, contacts, locations and venues // // optional CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"` // CanSendOtherMessages restricted only. // True, if the user is allowed to send audios, documents, // photos, videos, video notes and voice notes. // // optional CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"` // CanAddWebPagePreviews restricted only. // True, if the user is allowed to add web page previews to their messages. // // optional CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"` }
ChatMember is information about a member in a chat.
func (ChatMember) HasLeft ¶
func (chat ChatMember) HasLeft() bool
HasLeft returns if the ChatMember left the chat.
func (ChatMember) IsAdministrator ¶
func (chat ChatMember) IsAdministrator() bool
IsAdministrator returns if the ChatMember is a chat administrator.
func (ChatMember) IsCreator ¶
func (chat ChatMember) IsCreator() bool
IsCreator returns if the ChatMember was the creator of the chat.
func (ChatMember) IsMember ¶
func (chat ChatMember) IsMember() bool
IsMember returns if the ChatMember is a current member of the chat.
func (ChatMember) WasKicked ¶
func (chat ChatMember) WasKicked() bool
WasKicked returns if the ChatMember was kicked from the chat.
type ChatMemberConfig ¶
type ChatMemberConfig struct { ChatID int64 SuperGroupUsername string ChannelUsername string UserID int }
ChatMemberConfig contains information about a user in a chat for use with administrative functions such as kicking or unbanning a user.
type ChatPhoto ¶
type ChatPhoto struct { // SmallFileID is a file identifier of small (160x160) chat photo. // This file_id can be used only for photo download and // only for as long as the photo is not changed. SmallFileID string `json:"small_file_id"` // BigFileID is a file identifier of big (640x640) chat photo. // This file_id can be used only for photo download and // only for as long as the photo is not changed. BigFileID string `json:"big_file_id"` }
ChatPhoto represents a chat photo.
type Chattable ¶
type Chattable interface {
// contains filtered or unexported methods
}
Chattable is any config type that can be sent.
type ChosenInlineResult ¶
type ChosenInlineResult struct { // ResultID the unique identifier for the result that was chosen ResultID string `json:"result_id"` // From the user that chose the result From *User `json:"from"` // Location sender location, only for bots that require user location // // optional Location *Location `json:"location"` // InlineMessageID 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. // // optional InlineMessageID string `json:"inline_message_id"` // Query the query that was used to obtain the result Query string `json:"query"` }
ChosenInlineResult is an inline query result chosen by a User
type Contact ¶
type Contact struct { // PhoneNumber contact's phone number PhoneNumber string `json:"phone_number"` // FirstName contact's first name FirstName string `json:"first_name"` // LastName contact's last name // // optional LastName string `json:"last_name"` // UserID contact's user identifier in Telegram // // optional UserID int `json:"user_id"` }
Contact contains information about a contact.
Note that LastName and UserID may be empty.
type ContactConfig ¶
ContactConfig allows you to send a contact.
func NewContact ¶
func NewContact(chatID int64, phoneNumber, firstName string) ContactConfig
NewContact allows you to send a shared contact.
type Credentials ¶
type Credentials struct { Data SecureData `json:"secure_data"` // Nonce the same nonce given in the request Nonce string `json:"nonce"` }
Credentials contains encrypted data.
type DataCredentials ¶
type DataCredentials struct { // DataHash checksum of encrypted data DataHash string `json:"data_hash"` // Secret of encrypted data Secret string `json:"secret"` }
DataCredentials contains information required to decrypt data.
type DeleteChatPhotoConfig ¶
type DeleteChatPhotoConfig struct {
ChatID int64
}
DeleteChatPhotoConfig contains information for delete chat photo.
type DeleteMessageConfig ¶
DeleteMessageConfig contains information of a message in a chat to delete.
func NewDeleteMessage ¶
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig
NewDeleteMessage creates a request to delete a message.
type DiceConfig ¶
type DiceConfig struct { BaseChat // Emoji on which the dice throw animation is based. // Currently, must be one of “🎲”, “🎯”, or “🏀”. // Dice can have values 1-6 for “🎲” and “🎯”, and values 1-5 for “🏀”. // Defaults to “🎲” Emoji string }
DiceConfig contains information about a sendDice request.
func NewDice ¶
func NewDice(chatID int64) DiceConfig
NewDice creates a new DiceConfig.
chatID is where to send it
func NewDiceWithEmoji ¶
func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig
NewDiceWithEmoji creates a new DiceConfig.
chatID is where to send it emoji is type of the Dice
type Document ¶
type Document struct { // FileID is a identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // Thumbnail document thumbnail as defined by sender // // optional Thumbnail *PhotoSize `json:"thumb"` // FileName original filename as defined by sender // // optional FileName string `json:"file_name"` // MimeType of the file as defined by sender // // optional MimeType string `json:"mime_type"` // FileSize file size // // optional FileSize int `json:"file_size"` }
Document contains information about a document.
type DocumentConfig ¶
DocumentConfig contains information about a SendDocument request.
func NewDocumentShare ¶
func NewDocumentShare(chatID int64, fileID string) DocumentConfig
NewDocumentShare shares an existing document. You may use this to reshare an existing document without reuploading it.
chatID is where to send it, fileID is the ID of the document already uploaded.
func NewDocumentUpload ¶
func NewDocumentUpload(chatID int64, file interface{}) DocumentConfig
NewDocumentUpload creates a new document uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type EditMessageCaptionConfig ¶
EditMessageCaptionConfig allows you to modify the caption of a message.
func NewEditMessageCaption ¶
func NewEditMessageCaption(chatID int64, messageID int, caption string) EditMessageCaptionConfig
NewEditMessageCaption allows you to edit the caption of a message.
type EditMessageReplyMarkupConfig ¶
type EditMessageReplyMarkupConfig struct {
BaseEdit
}
EditMessageReplyMarkupConfig allows you to modify the reply markup of a message.
func NewEditMessageReplyMarkup ¶
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig
NewEditMessageReplyMarkup allows you to edit the inline keyboard markup.
type EditMessageTextConfig ¶
type EditMessageTextConfig struct { BaseEdit Text string ParseMode string DisableWebPagePreview bool }
EditMessageTextConfig allows you to modify the text in a message.
func NewEditMessageText ¶
func NewEditMessageText(chatID int64, messageID int, text string) EditMessageTextConfig
NewEditMessageText allows you to edit the text of a message.
func NewEditMessageTextAndMarkup ¶
func NewEditMessageTextAndMarkup(chatID int64, messageID int, text string, replyMarkup InlineKeyboardMarkup) EditMessageTextConfig
NewEditMessageTextAndMarkup allows you to edit the text and replymarkup of a message.
type EncryptedCredentials ¶
type EncryptedCredentials struct { // Base64-encoded encrypted JSON-serialized data with unique user's // payload, data hashes and secrets required for EncryptedPassportElement // decryption and authentication Data string `json:"data"` // Base64-encoded data hash for data authentication Hash string `json:"hash"` // Base64-encoded secret, encrypted with the bot's public RSA key, // required for data decryption Secret string `json:"secret"` }
EncryptedCredentials contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
type EncryptedPassportElement ¶
type EncryptedPassportElement struct { // Element type. Type string `json:"type"` // Base64-encoded encrypted Telegram Passport element data provided by // the user, available for "personal_details", "passport", // "driver_license", "identity_card", "identity_passport" and "address" // types. Can be decrypted and verified using the accompanying // EncryptedCredentials. Data string `json:"data,omitempty"` // User's verified phone number, available only for "phone_number" type PhoneNumber string `json:"phone_number,omitempty"` // User's verified email address, available only for "email" type Email string `json:"email,omitempty"` // Array of encrypted files with documents provided by the user, // available for "utility_bill", "bank_statement", "rental_agreement", // "passport_registration" and "temporary_registration" types. Files can // be decrypted and verified using the accompanying EncryptedCredentials. Files []PassportFile `json:"files,omitempty"` // Encrypted file with the front side of the document, provided by the // user. Available for "passport", "driver_license", "identity_card" and // "internal_passport". The file can be decrypted and verified using the // accompanying EncryptedCredentials. FrontSide *PassportFile `json:"front_side,omitempty"` // Encrypted file with the reverse side of the document, provided by the // user. Available for "driver_license" and "identity_card". The file can // be decrypted and verified using the accompanying EncryptedCredentials. ReverseSide *PassportFile `json:"reverse_side,omitempty"` // Encrypted file with the selfie of the user holding a document, // provided by the user; available for "passport", "driver_license", // "identity_card" and "internal_passport". The file can be decrypted // and verified using the accompanying EncryptedCredentials. Selfie *PassportFile `json:"selfie,omitempty"` }
EncryptedPassportElement contains information about documents or other Telegram Passport elements shared with the bot by the user.
type Error ¶
type Error struct { Code int Message string ResponseParameters }
Error is an error containing extra information returned by the Telegram API.
type File ¶
type File struct { // FileID identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // FileSize file size, if known // // optional FileSize int `json:"file_size"` // FilePath file path // // optional FilePath string `json:"file_path"` }
File contains information about a file to download from Telegram.
type FileConfig ¶
type FileConfig struct {
FileID string
}
FileConfig has information about a file hosted on Telegram.
type FileCredentials ¶
type FileCredentials struct { // FileHash checksum of encrypted data FileHash string `json:"file_hash"` // Secret of encrypted data Secret string `json:"secret"` }
FileCredentials contains information required to decrypt files.
type FileReader ¶
FileReader contains information about a reader to upload as a File. If Size is -1, it will read the entire Reader into memory to calculate a Size.
type Fileable ¶
type Fileable interface { Chattable // contains filtered or unexported methods }
Fileable is any config type that can be sent that includes a file.
type ForceReply ¶
type ForceReply struct { // ForceReply shows reply interface to the user, // as if they manually selected the bot's message and tapped 'Reply'. ForceReply bool `json:"force_reply"` // Selective 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 Message.ReplyToMessage not nil), sender of the original message. // // optional Selective bool `json:"selective"` }
ForceReply allows the Bot to have users directly reply to it without additional interaction.
type ForwardConfig ¶
type ForwardConfig struct { BaseChat FromChatID int64 // required FromChannelUsername string MessageID int // required }
ForwardConfig contains information about a ForwardMessage request.
func NewForward ¶
func NewForward(chatID int64, fromChatID int64, messageID int) ForwardConfig
NewForward creates a new forward.
chatID is where to send it, fromChatID is the source chat, and messageID is the ID of the original message.
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 a 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. // // optional Text string `json:"text"` // TextEntities special entities that appear in text, such as usernames, URLs, bot commands, etc. // // optional TextEntities []MessageEntity `json:"text_entities"` // Animation animation that will be displayed in the game message in chats. // Upload via BotFather (https://t.me/botfather). // // optional Animation Animation `json:"animation"` }
Game is a game within Telegram.
type GameConfig ¶
GameConfig allows you to send a game.
type GameHighScore ¶
type GameHighScore struct { // Position in high score table for the game Position int `json:"position"` // User user User User `json:"user"` // Score score Score int `json:"score"` }
GameHighScore is a user's score and position on the leaderboard.
type GetGameHighScoresConfig ¶
type GetGameHighScoresConfig struct { UserID int ChatID int ChannelUsername string MessageID int InlineMessageID string }
GetGameHighScoresConfig allows you to fetch the high scores for a game.
type GetStickerSetConfig ¶
type GetStickerSetConfig struct {
Name string
}
GetStickerSetConfig contains information for get sticker set.
type IDDocumentData ¶
type IDDocumentData struct { DocumentNumber string `json:"document_no"` ExpiryDate string `json:"expiry_date"` }
IDDocumentData https://core.telegram.org/passport#iddocumentdata
type InlineConfig ¶
type InlineConfig struct { InlineQueryID string `json:"inline_query_id"` Results []interface{} `json:"results"` CacheTime int `json:"cache_time"` IsPersonal bool `json:"is_personal"` NextOffset string `json:"next_offset"` SwitchPMText string `json:"switch_pm_text"` SwitchPMParameter string `json:"switch_pm_parameter"` }
InlineConfig contains information on making an InlineQuery response.
type InlineKeyboardButton ¶
type InlineKeyboardButton struct { // Text label text on the button Text string `json:"text"` // URL HTTP or tg:// url to be opened when button is pressed. // // optional URL *string `json:"url,omitempty"` // CallbackData data to be sent in a callback query to the bot when button is pressed, 1-64 bytes. // // optional CallbackData *string `json:"callback_data,omitempty"` // SwitchInlineQuery 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. // // 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. // // optional SwitchInlineQuery *string `json:"switch_inline_query,omitempty"` // SwitchInlineQueryCurrentChat 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. // // optional SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` // CallbackGame description of the game that will be launched when the user presses the button. // // optional CallbackGame *CallbackGame `json:"callback_game,omitempty"` // Pay specify True, to send a Pay button. // // NOTE: This type of button must always be the first button in the first row. // // optional Pay bool `json:"pay,omitempty"` }
InlineKeyboardButton is a button within a custom keyboard for inline query responses.
Note that some values are references as even an empty string will change behavior.
CallbackGame, if set, MUST be first button in first row.
func NewInlineKeyboardButtonData ¶
func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton
NewInlineKeyboardButtonData creates an inline keyboard button with text and data for a callback.
func NewInlineKeyboardButtonSwitch ¶
func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton
NewInlineKeyboardButtonSwitch creates an inline keyboard button with text which allows the user to switch to a chat or return to a chat.
func NewInlineKeyboardButtonURL ¶
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton
NewInlineKeyboardButtonURL creates an inline keyboard button with text which goes to a URL.
func NewInlineKeyboardRow ¶
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton
NewInlineKeyboardRow creates an inline keyboard row with buttons.
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct { // InlineKeyboard array of button rows, each represented by an Array of InlineKeyboardButton objects InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"` }
InlineKeyboardMarkup is a custom keyboard presented for an inline bot.
func NewInlineKeyboardMarkup ¶
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup
NewInlineKeyboardMarkup creates a new inline keyboard.
type InlineQuery ¶
type InlineQuery struct { // ID unique identifier for this query ID string `json:"id"` // From sender From *User `json:"from"` // Location sender location, only for bots that request user location. // // optional Location *Location `json:"location"` // Query text of the query (up to 256 characters). Query string `json:"query"` // Offset of the results to be returned, can be controlled by the bot. Offset string `json:"offset"` }
InlineQuery is a Query from Telegram for an inline request.
type InlineQueryResultArticle ¶
type InlineQueryResultArticle struct { // Type of the result, must be article. // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 Bytes. // // required ID string `json:"id"` // Title of the result // // required Title string `json:"title"` // InputMessageContent content of the message to be sent. // // required InputMessageContent interface{} `json:"input_message_content,omitempty"` // ReplyMarkup Inline keyboard attached to the message. // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // URL of the result. // // optional URL string `json:"url"` // HideURL pass True, if you don't want the URL to be shown in the message. // // optional HideURL bool `json:"hide_url"` // Description short description of the result. // // optional Description string `json:"description"` // ThumbURL url of the thumbnail for the result // // optional ThumbURL string `json:"thumb_url"` // ThumbWidth thumbnail width // // optional ThumbWidth int `json:"thumb_width"` // ThumbHeight thumbnail height // // optional ThumbHeight int `json:"thumb_height"` }
InlineQueryResultArticle is an inline query response article.
func NewInlineQueryResultArticle ¶
func NewInlineQueryResultArticle(id, title, messageText string) InlineQueryResultArticle
NewInlineQueryResultArticle creates a new inline query article.
func NewInlineQueryResultArticleHTML ¶
func NewInlineQueryResultArticleHTML(id, title, messageText string) InlineQueryResultArticle
NewInlineQueryResultArticleHTML creates a new inline query article with HTML parsing.
func NewInlineQueryResultArticleMarkdown ¶
func NewInlineQueryResultArticleMarkdown(id, title, messageText string) InlineQueryResultArticle
NewInlineQueryResultArticleMarkdown creates a new inline query article with Markdown parsing.
func NewInlineQueryResultArticleMarkdownV2 ¶
func NewInlineQueryResultArticleMarkdownV2(id, title, messageText string) InlineQueryResultArticle
NewInlineQueryResultArticleMarkdownV2 creates a new inline query article with MarkdownV2 parsing.
type InlineQueryResultAudio ¶
type InlineQueryResultAudio struct { // Type of the result, must be audio // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // URL a valid url for the audio file // // required URL string `json:"audio_url"` // Title is a title // // required Title string `json:"title"` // Caption 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // Performer is a performer // // optional Performer string `json:"performer"` // Duration audio duration in seconds // // optional Duration int `json:"audio_duration"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the audio // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultAudio is an inline query response audio.
func NewInlineQueryResultAudio ¶
func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio
NewInlineQueryResultAudio creates a new inline query audio.
type InlineQueryResultCachedAudio ¶
type InlineQueryResultCachedAudio struct { // Type of the result, must be audio // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // AudioID a valid file identifier for the audio file // // required AudioID string `json:"audio_file_id"` // Caption 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the video caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the audio // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedAudio is an inline query response with cached audio.
func NewInlineQueryResultCachedAudio ¶
func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio
NewInlineQueryResultCachedAudio create a new inline query with cached photo.
type InlineQueryResultCachedDocument ¶
type InlineQueryResultCachedDocument struct { // Type of the result, must be document // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // DocumentID a valid file identifier for the file // // required DocumentID string `json:"document_file_id"` // Title for the result // // optional Title string `json:"title"` // required // Caption of the document to be sent, 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // Description short description of the result // // optional Description string `json:"description"` // ParseMode mode for parsing entities in the video caption. // // See formatting options for more details // // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the file // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedDocument is an inline query response with cached document.
func NewInlineQueryResultCachedDocument ¶
func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument
NewInlineQueryResultCachedDocument create a new inline query with cached photo.
type InlineQueryResultCachedGIF ¶
type InlineQueryResultCachedGIF struct { // Type of the result, must be gif. // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes. // // required ID string `json:"id"` // GifID a valid file identifier for the GIF file. // // required GifID string `json:"gif_file_id"` // Title for the result // // optional Title string `json:"title"` // Caption of the GIF file to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message. // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the GIF animation. // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedGIF is an inline query response with cached gif.
func NewInlineQueryResultCachedGIF ¶
func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF
NewInlineQueryResultCachedGIF create a new inline query with cached photo.
type InlineQueryResultCachedMpeg4Gif ¶
type InlineQueryResultCachedMpeg4Gif struct { // Type of the result, must be mpeg4_gif // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // MGifID a valid file identifier for the MP4 file // // required MGifID string `json:"mpeg4_file_id"` // Title for the result // // optional Title string `json:"title"` // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message. // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the video animation. // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedMpeg4Gif is an inline query response with cached H.264/MPEG-4 AVC video without sound gif.
func NewInlineQueryResultCachedMPEG4GIF ¶
func NewInlineQueryResultCachedMPEG4GIF(id, MPEG4GifID string) InlineQueryResultCachedMpeg4Gif
NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached MPEG4 GIF.
type InlineQueryResultCachedPhoto ¶
type InlineQueryResultCachedPhoto struct { // Type of the result, must be photo. // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes. // // required ID string `json:"id"` // PhotoID a valid file identifier of the photo. // // required PhotoID string `json:"photo_file_id"` // Title for the result. // // optional Title string `json:"title"` // Description short description of the result. // // optional Description string `json:"description"` // Caption of the photo to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the photo caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message. // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the photo. // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedPhoto is an inline query response with cached photo.
func NewInlineQueryResultCachedPhoto ¶
func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto
NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
type InlineQueryResultCachedSticker ¶
type InlineQueryResultCachedSticker struct { // Type of the result, must be sticker // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // StickerID a valid file identifier of the sticker // // required StickerID string `json:"sticker_file_id"` // Title is a title Title string `json:"title"` // ParseMode mode for parsing entities in the video caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the sticker // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedSticker is an inline query response with cached sticker.
func NewInlineQueryResultCachedSticker ¶
func NewInlineQueryResultCachedSticker(id, stickerID, title string) InlineQueryResultCachedSticker
NewInlineQueryResultCachedSticker create a new inline query with cached sticker.
type InlineQueryResultCachedVideo ¶
type InlineQueryResultCachedVideo struct { // Type of the result, must be video // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // VideoID a valid file identifier for the video file // // required VideoID string `json:"video_file_id"` // Title for the result // // required Title string `json:"title"` // Description short description of the result // // optional Description string `json:"description"` // Caption of the video to be sent, 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the video caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the video // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedVideo is an inline query response with cached video.
func NewInlineQueryResultCachedVideo ¶
func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo
NewInlineQueryResultCachedVideo create a new inline query with cached video.
type InlineQueryResultCachedVoice ¶
type InlineQueryResultCachedVoice struct { // Type of the result, must be voice // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // VoiceID a valid file identifier for the voice message // // required VoiceID string `json:"voice_file_id"` // Title voice message title // // required Title string `json:"title"` // Caption 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the video caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the voice message // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultCachedVoice is an inline query response with cached voice.
func NewInlineQueryResultCachedVoice ¶
func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice
NewInlineQueryResultCachedVoice create a new inline query with cached photo.
type InlineQueryResultDocument ¶
type InlineQueryResultDocument struct { // Type of the result, must be document // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // Title for the result // // required Title string `json:"title"` // Caption of the document to be sent, 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // URL a valid url for the file // // required URL string `json:"document_url"` // MimeType of the content of the file, either “application/pdf” or “application/zip” // // required MimeType string `json:"mime_type"` // Description short description of the result // // optional Description string `json:"description"` // ReplyMarkup nline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the file // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` // ThumbURL url of the thumbnail (jpeg only) for the file // // optional ThumbURL string `json:"thumb_url"` // ThumbWidth thumbnail width // // optional ThumbWidth int `json:"thumb_width"` // ThumbHeight thumbnail height // // optional ThumbHeight int `json:"thumb_height"` }
InlineQueryResultDocument is an inline query response document.
func NewInlineQueryResultDocument ¶
func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument
NewInlineQueryResultDocument creates a new inline query document.
type InlineQueryResultGIF ¶
type InlineQueryResultGIF struct { // Type of the result, must be gif. // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes. // // required ID string `json:"id"` // URL a valid URL for the GIF file. File size must not exceed 1MB. // // required URL string `json:"gif_url"` // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result. // // required ThumbURL string `json:"thumb_url"` // Width of the GIF // // optional Width int `json:"gif_width,omitempty"` // Height of the GIF // // optional Height int `json:"gif_height,omitempty"` // Duration of the GIF // // optional Duration int `json:"gif_duration,omitempty"` // Title for the result // // optional Title string `json:"title,omitempty"` // Caption of the GIF file to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption,omitempty"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the GIF animation. // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultGIF is an inline query response GIF.
func NewInlineQueryResultGIF ¶
func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF
NewInlineQueryResultGIF creates a new inline query GIF.
type InlineQueryResultGame ¶
type InlineQueryResultGame struct { // Type of the result, must be game // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // GameShortName short name of the game // // required GameShortName string `json:"game_short_name"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` }
InlineQueryResultGame is an inline query response game.
type InlineQueryResultLocation ¶
type InlineQueryResultLocation struct { // Type of the result, must be location // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 Bytes // // required ID string `json:"id"` // Latitude of the location in degrees // // required Latitude float64 `json:"latitude"` // Longitude of the location in degrees // // required Longitude float64 `json:"longitude"` // Title of the location // // required Title string `json:"title"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the location // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` // ThumbURL url of the thumbnail for the result // // optional ThumbURL string `json:"thumb_url"` // ThumbWidth thumbnail width // // optional ThumbWidth int `json:"thumb_width"` // ThumbHeight thumbnail height // // optional ThumbHeight int `json:"thumb_height"` }
InlineQueryResultLocation is an inline query response location.
func NewInlineQueryResultLocation ¶
func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation
NewInlineQueryResultLocation creates a new inline query location.
type InlineQueryResultMPEG4GIF ¶
type InlineQueryResultMPEG4GIF struct { // Type of the result, must be mpeg4_gif // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // URL a valid URL for the MP4 file. File size must not exceed 1MB // // required URL string `json:"mpeg4_url"` // Width video width // // optional Width int `json:"mpeg4_width"` // Height vVideo height // // optional Height int `json:"mpeg4_height"` // Duration video duration // // optional Duration int `json:"mpeg4_duration"` // ThumbURL url of the static (JPEG or GIF) or animated (MPEG4) thumbnail for the result. ThumbURL string `json:"thumb_url"` // Title for the result // // optional Title string `json:"title"` // Caption of the MPEG-4 file to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the video animation // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
func NewInlineQueryResultMPEG4GIF ¶
func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF
NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
type InlineQueryResultPhoto ¶
type InlineQueryResultPhoto struct { // Type of the result, must be article. // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 Bytes. // // required ID string `json:"id"` // URL a valid URL of the photo. Photo must be in jpeg format. // Photo size must not exceed 5MB. URL string `json:"photo_url"` // MimeType MimeType string `json:"mime_type"` // Width of the photo // // optional Width int `json:"photo_width"` // Height of the photo // // optional Height int `json:"photo_height"` // ThumbURL url of the thumbnail for the photo. // // optional ThumbURL string `json:"thumb_url"` // Title for the result // // optional Title string `json:"title"` // Description short description of the result // // optional Description string `json:"description"` // Caption of the photo to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the photo caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // ReplyMarkup inline keyboard attached to the message. // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the photo. // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultPhoto is an inline query response photo.
func NewInlineQueryResultPhoto ¶
func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto
NewInlineQueryResultPhoto creates a new inline query photo.
func NewInlineQueryResultPhotoWithThumb ¶
func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto
NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
type InlineQueryResultVenue ¶
type InlineQueryResultVenue struct { // Type of the result, must be venue // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 Bytes // // required ID string `json:"id"` // Latitude of the venue location in degrees // // required Latitude float64 `json:"latitude"` // Longitude of the venue location in degrees // // required Longitude float64 `json:"longitude"` // Title of the venue // // required Title string `json:"title"` // Address of the venue // // required Address string `json:"address"` // FoursquareID foursquare identifier of the venue if known // // optional FoursquareID string `json:"foursquare_id"` // FoursquareType foursquare type of the venue, if known. // (For example, “arts_entertainment/default”, “arts_entertainment/aquarium” or “food/icecream”.) // // optional FoursquareType string `json:"foursquare_type"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the venue // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` // ThumbURL url of the thumbnail for the result // // optional ThumbURL string `json:"thumb_url"` // ThumbWidth thumbnail width // // optional ThumbWidth int `json:"thumb_width"` // ThumbHeight thumbnail height // // optional ThumbHeight int `json:"thumb_height"` }
InlineQueryResultVenue is an inline query response venue.
func NewInlineQueryResultVenue ¶
func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue
NewInlineQueryResultVenue creates a new inline query venue.
type InlineQueryResultVideo ¶
type InlineQueryResultVideo struct { // Type of the result, must be video // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // URL a valid url for the embedded video player or video file // // required URL string `json:"video_url"` // MimeType of the content of video url, “text/html” or “video/mp4” // // required MimeType string `json:"mime_type"` // // ThumbURL url of the thumbnail (jpeg only) for the video // optional ThumbURL string `json:"thumb_url"` // Title for the result // // required Title string `json:"title"` // Caption of the video to be sent, 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // Width video width // // optional Width int `json:"video_width"` // Height video height // // optional Height int `json:"video_height"` // Duration video duration in seconds // // optional Duration int `json:"video_duration"` // Description short description of the result // // optional Description string `json:"description"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the video. // This field is required if InlineQueryResultVideo is used to send // an HTML-page as a result (e.g., a YouTube video). // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultVideo is an inline query response video.
func NewInlineQueryResultVideo ¶
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo
NewInlineQueryResultVideo creates a new inline query video.
type InlineQueryResultVoice ¶
type InlineQueryResultVoice struct { // Type of the result, must be voice // // required Type string `json:"type"` // ID unique identifier for this result, 1-64 bytes // // required ID string `json:"id"` // URL a valid URL for the voice recording // // required URL string `json:"voice_url"` // Title recording title // // required Title string `json:"title"` // Caption 0-1024 characters after entities parsing // // optional Caption string `json:"caption"` // Duration recording duration in seconds // // optional Duration int `json:"voice_duration"` // ReplyMarkup inline keyboard attached to the message // // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // InputMessageContent content of the message to be sent instead of the voice recording // // optional InputMessageContent interface{} `json:"input_message_content,omitempty"` }
InlineQueryResultVoice is an inline query response voice.
func NewInlineQueryResultVoice ¶
func NewInlineQueryResultVoice(id, url, title string) InlineQueryResultVoice
NewInlineQueryResultVoice creates a new inline query voice.
type InputContactMessageContent ¶
type InputContactMessageContent struct { // PhoneNumber contact's phone number PhoneNumber string `json:"phone_number"` // FirstName contact's first name FirstName string `json:"first_name"` // LastName contact's last name // // optional LastName string `json:"last_name"` }
InputContactMessageContent contains a contact for displaying as an inline query result.
type InputLocationMessageContent ¶
type InputLocationMessageContent struct { // Latitude of the location in degrees Latitude float64 `json:"latitude"` // Longitude of the location in degrees Longitude float64 `json:"longitude"` }
InputLocationMessageContent contains a location for displaying as an inline query result.
type InputMediaPhoto ¶
type InputMediaPhoto struct { // Type of the result, must be photo. Type string `json:"type"` // Media file to send. Pass a file_id to send a file that // exists on the Telegram servers (recommended), // pass an HTTP URL for Telegram to get a file from the Internet, // or pass “attach://<file_attach_name>” to upload a new one // using multipart/form-data under <file_attach_name> name. Media string `json:"media"` // Caption of the photo to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the photo caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` }
InputMediaPhoto contains a photo for displaying as part of a media group.
func NewInputMediaPhoto ¶
func NewInputMediaPhoto(media string) InputMediaPhoto
NewInputMediaPhoto creates a new InputMediaPhoto.
type InputMediaVideo ¶
type InputMediaVideo struct { // Type of the result, must be video. Type string `json:"type"` // Media file to send. Pass a file_id to send a file // that exists on the Telegram servers (recommended), // pass an HTTP URL for Telegram to get a file from the Internet, // or pass “attach://<file_attach_name>” to upload a new one // using multipart/form-data under <file_attach_name> name. Media string `json:"media"` // Caption of the video to be sent, 0-1024 characters after entities parsing. // // optional Caption string `json:"caption"` // ParseMode mode for parsing entities in the video caption. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // Width video width // // optional Width int `json:"width"` // Height video height // // optional Height int `json:"height"` // Duration video duration // // optional Duration int `json:"duration"` // SupportsStreaming pass True, if the uploaded video is suitable for streaming. // // optional SupportsStreaming bool `json:"supports_streaming"` }
InputMediaVideo contains a video for displaying as part of a media group.
func NewInputMediaVideo ¶
func NewInputMediaVideo(media string) InputMediaVideo
NewInputMediaVideo creates a new InputMediaVideo.
type InputTextMessageContent ¶
type InputTextMessageContent struct { // Text of the message to be sent, 1-4096 characters Text string `json:"message_text"` // ParseMode mode for parsing entities in the message text. // See formatting options for more details // (https://core.telegram.org/bots/api#formatting-options). // // optional ParseMode string `json:"parse_mode"` // DisableWebPagePreview disables link previews for links in the sent message // // optional DisableWebPagePreview bool `json:"disable_web_page_preview"` }
InputTextMessageContent contains text for displaying as an inline query result.
type InputVenueMessageContent ¶
type InputVenueMessageContent struct { // Latitude of the venue in degrees Latitude float64 `json:"latitude"` // Longitude of the venue in degrees Longitude float64 `json:"longitude"` // Title name of the venue Title string `json:"title"` // Address of the venue Address string `json:"address"` // FoursquareID foursquare identifier of the venue, if known // // optional FoursquareID string `json:"foursquare_id"` }
InputVenueMessageContent contains a venue for displaying as an inline query result.
type Invoice ¶
type Invoice struct { // Title product name Title string `json:"title"` // Description 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 // (see 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 currencies.json // (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). TotalAmount int `json:"total_amount"` }
Invoice contains basic information about an invoice.
type InvoiceConfig ¶
type InvoiceConfig struct { BaseChat Title string // required Description string // required Payload string // required ProviderToken string // required StartParameter string // required Currency string // required Prices *[]LabeledPrice // required PhotoURL string PhotoSize int PhotoWidth int PhotoHeight int NeedName bool NeedPhoneNumber bool NeedEmail bool NeedShippingAddress bool IsFlexible bool }
InvoiceConfig contains information for sendInvoice request.
func NewInvoice ¶
func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices *[]LabeledPrice) InvoiceConfig
NewInvoice creates a new Invoice request to the user.
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 if True, the user's phone number will be sent // as a contact when the button is pressed. // Available in private chats only. // // optional RequestContact bool `json:"request_contact"` // RequestLocation if True, the user's current location will be sent when the button is pressed. // Available in private chats only. // // optional RequestLocation bool `json:"request_location"` }
KeyboardButton is a button within a custom keyboard.
func NewKeyboardButton ¶
func NewKeyboardButton(text string) KeyboardButton
NewKeyboardButton creates a regular keyboard button.
func NewKeyboardButtonContact ¶
func NewKeyboardButtonContact(text string) KeyboardButton
NewKeyboardButtonContact creates a keyboard button that requests user contact information upon click.
func NewKeyboardButtonLocation ¶
func NewKeyboardButtonLocation(text string) KeyboardButton
NewKeyboardButtonLocation creates a keyboard button that requests user location information upon click.
func NewKeyboardButtonRow ¶
func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton
NewKeyboardButtonRow creates a row of keyboard buttons.
type KickChatMemberConfig ¶
type KickChatMemberConfig struct { ChatMemberConfig UntilDate int64 }
KickChatMemberConfig contains extra fields to kick user
type LabeledPrice ¶
type LabeledPrice struct { // Label portion label Label string `json:"label"` // Amount price of the product 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 // (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). Amount int `json:"amount"` }
LabeledPrice represents a portion of the price for goods or services.
type Location ¶
type Location struct { // Longitude as defined by sender Longitude float64 `json:"longitude"` // Latitude as defined by sender Latitude float64 `json:"latitude"` }
Location contains information about a place.
type LocationConfig ¶
LocationConfig contains information about a SendLocation request.
func NewLocation ¶
func NewLocation(chatID int64, latitude float64, longitude float64) LocationConfig
NewLocation shares your location.
chatID is where to send it, latitude and longitude are coordinates.
type MediaGroupConfig ¶
type MediaGroupConfig struct { BaseChat InputMedia []interface{} }
MediaGroupConfig contains information about a sendMediaGroup request.
func NewMediaGroup ¶
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig
NewMediaGroup creates a new media group. Files should be an array of two to ten InputMediaPhoto or InputMediaVideo.
type Message ¶
type Message struct { // MessageID is a unique message identifier inside this chat MessageID int `json:"message_id"` // From is a sender, empty for messages sent to channels; // // optional From *User `json:"from"` // Date of the message was sent in Unix time Date int `json:"date"` // Chat is the conversation the message belongs to Chat *Chat `json:"chat"` // ForwardFrom for forwarded messages, sender of the original message; // // optional ForwardFrom *User `json:"forward_from"` // ForwardFromChat for messages forwarded from channels, // information about the original channel; // // optional ForwardFromChat *Chat `json:"forward_from_chat"` // ForwardFromMessageID for messages forwarded from channels, // identifier of the original message in the channel; // // optional ForwardFromMessageID int `json:"forward_from_message_id"` // ForwardDate for forwarded messages, date the original message was sent in Unix time; // // optional ForwardDate int `json:"forward_date"` // ReplyToMessage for replies, the original message. // Note that the Message object in this field will not contain further ReplyToMessage fields // even if it itself is a reply; // // optional ReplyToMessage *Message `json:"reply_to_message"` // ViaBot through which the message was sent; // // optional ViaBot *User `json:"via_bot"` // EditDate of the message was last edited in Unix time; // // optional EditDate int `json:"edit_date"` // MediaGroupID is the unique identifier of a media message group this message belongs to; // // optional MediaGroupID string `json:"media_group_id"` // AuthorSignature is the signature of the post author for messages in channels; // // optional AuthorSignature string `json:"author_signature"` // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters; // // optional Text string `json:"text"` // Entities is for text messages, special entities like usernames, // URLs, bot commands, etc. that appear in the text; // // optional Entities *[]MessageEntity `json:"entities"` // CaptionEntities; // // optional CaptionEntities *[]MessageEntity `json:"caption_entities"` // Audio message is an audio file, information about the file; // // optional Audio *Audio `json:"audio"` // Document message is a general file, information about the file; // // optional Document *Document `json:"document"` // Animation message is an animation, information about the animation. // For backward compatibility, when this field is set, the document field will also be set; // // optional Animation *ChatAnimation `json:"animation"` // Game message is a game, information about the game; // // optional Game *Game `json:"game"` // Photo message is a photo, available sizes of the photo; // // optional Photo *[]PhotoSize `json:"photo"` // Sticker message is a sticker, information about the sticker; // // optional Sticker *Sticker `json:"sticker"` // Video message is a video, information about the video; // // optional Video *Video `json:"video"` // VideoNote message is a video note, information about the video message; // // optional VideoNote *VideoNote `json:"video_note"` // Voice message is a voice message, information about the file; // // optional Voice *Voice `json:"voice"` // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters; // // optional Caption string `json:"caption"` // Contact message is a shared contact, information about the contact; // // optional Contact *Contact `json:"contact"` // Location message is a shared location, information about the location; // // optional Location *Location `json:"location"` // Venue message is a venue, information about the venue. // For backward compatibility, when this field is set, the location field will also be set; // // optional Venue *Venue `json:"venue"` // NewChatMembers that were added to the group or supergroup // and information about them (the bot itself may be one of these members); // // optional NewChatMembers *[]User `json:"new_chat_members"` // LeftChatMember is a member was removed from the group, // information about them (this member may be the bot itself); // // optional LeftChatMember *User `json:"left_chat_member"` // NewChatTitle is a chat title was changed to this value; // // optional NewChatTitle string `json:"new_chat_title"` // NewChatPhoto is a chat photo was change to this value; // // optional NewChatPhoto *[]PhotoSize `json:"new_chat_photo"` // DeleteChatPhoto is a service message: the chat photo was deleted; // // optional DeleteChatPhoto bool `json:"delete_chat_photo"` // GroupChatCreated is a service message: the group has been created; // // optional GroupChatCreated bool `json:"group_chat_created"` // SuperGroupChatCreated is a 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 ReplyToMessage if someone replies to a very first message // in a directly created supergroup; // // optional SuperGroupChatCreated bool `json:"supergroup_chat_created"` // ChannelChatCreated is a 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 ReplyToMessage // if someone replies to a very first message in a channel; // // optional ChannelChatCreated bool `json:"channel_chat_created"` // MigrateToChatID is 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; // // optional MigrateToChatID int64 `json:"migrate_to_chat_id"` // MigrateFromChatID is 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; // // optional MigrateFromChatID int64 `json:"migrate_from_chat_id"` // PinnedMessage is a specified message was pinned. // Note that the Message object in this field will not contain further ReplyToMessage // fields even if it is itself a reply; // // optional PinnedMessage *Message `json:"pinned_message"` // Invoice message is an invoice for a payment; // // optional Invoice *Invoice `json:"invoice"` // SuccessfulPayment message is a service message about a successful payment, // information about the payment; // // optional SuccessfulPayment *SuccessfulPayment `json:"successful_payment"` // PassportData is a Telegram Passport data; // // optional PassportData *PassportData `json:"passport_data,omitempty"` }
Message is returned by almost every request, and contains data about almost anything.
func (*Message) Command ¶
Command checks if the message was a command and if it was, returns the command. If the Message was not a command, it returns an empty string.
If the command contains the at name syntax, it is removed. Use CommandWithAt() if you do not want that.
func (*Message) CommandArguments ¶
CommandArguments checks if the message was a command and if it was, returns all text after the command name. If the Message was not a command, it returns an empty string.
Note: The first character after the command name is omitted: - "/foo bar baz" yields "bar baz", not " bar baz" - "/foo-bar baz" yields "bar baz", too Even though the latter is not a command conforming to the spec, the API marks "/foo" as command entity.
func (*Message) CommandWithAt ¶
CommandWithAt checks if the message was a command and if it was, returns the command. If the Message was not a command, it returns an empty string.
If the command contains the at name syntax, it is not removed. Use Command() if you want that.
type MessageConfig ¶
MessageConfig contains information about a SendMessage request.
func NewMessage ¶
func NewMessage(chatID int64, text string) MessageConfig
NewMessage creates a new Message.
chatID is where to send it, text is the message text.
func NewMessageToChannel ¶
func NewMessageToChannel(username string, text string) MessageConfig
NewMessageToChannel creates a new Message that is sent to a channel by username.
username is the username of the channel, text is the message text, and the username should be in the form of `@username`.
type MessageEntity ¶
type MessageEntity struct { // Type of the entity. // Can be: // “mention” (@username), // “hashtag” (#hashtag), // “cashtag” ($USD), // “bot_command” (/start@jobs_bot), // “url” (https://telegram.org), // “email” (do-not-reply@telegram.org), // “phone_number” (+1-212-555-0123), // “bold” (bold text), // “italic” (italic text), // “underline” (underlined 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 Length int `json:"length"` // URL for “text_link” only, url that will be opened after user taps on the text // // optional URL string `json:"url"` // User for “text_mention” only, the mentioned user // // optional User *User `json:"user"` }
MessageEntity contains information about data in a Message.
func (MessageEntity) IsBold ¶
func (e MessageEntity) IsBold() bool
IsBold returns true if the type of the message entity is "bold" (bold text).
func (MessageEntity) IsCode ¶
func (e MessageEntity) IsCode() bool
IsCode returns true if the type of the message entity is "code" (monowidth string).
func (MessageEntity) IsCommand ¶
func (e MessageEntity) IsCommand() bool
IsCommand returns true if the type of the message entity is "bot_command".
func (MessageEntity) IsEmail ¶
func (e MessageEntity) IsEmail() bool
IsEmail returns true if the type of the message entity is "email".
func (MessageEntity) IsHashtag ¶
func (e MessageEntity) IsHashtag() bool
IsHashtag returns true if the type of the message entity is "hashtag".
func (MessageEntity) IsItalic ¶
func (e MessageEntity) IsItalic() bool
IsItalic returns true if the type of the message entity is "italic" (italic text).
func (MessageEntity) IsMention ¶
func (e MessageEntity) IsMention() bool
IsMention returns true if the type of the message entity is "mention" (@username).
func (MessageEntity) IsPre ¶
func (e MessageEntity) IsPre() bool
IsPre returns true if the type of the message entity is "pre" (monowidth block).
func (MessageEntity) IsTextLink ¶
func (e MessageEntity) IsTextLink() bool
IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
func (MessageEntity) IsUrl ¶
func (e MessageEntity) IsUrl() bool
IsUrl returns true if the type of the message entity is "url".
type OrderInfo ¶
type OrderInfo struct { // Name user name // // optional Name string `json:"name,omitempty"` // PhoneNumber user's phone number // // optional PhoneNumber string `json:"phone_number,omitempty"` // Email user email // // optional Email string `json:"email,omitempty"` // ShippingAddress user shipping address // // optional ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"` }
OrderInfo represents information about an order.
type Params ¶
Params represents a set of parameters that gets passed to a request.
func (Params) AddFirstValid ¶
AddFirstValid attempts to add the first item that is not a default value.
For example, AddFirstValid(0, "", "test") would add "test".
func (Params) AddInterface ¶
AddInterface adds an interface if it is not nill and can be JSON marshalled.
func (Params) AddNonEmpty ¶
AddNonEmpty adds a value if it not an empty string.
func (Params) AddNonZero ¶
AddNonZero adds a value if it is not zero.
func (Params) AddNonZero64 ¶
AddNonZero64 is the same as AddNonZero except uses an int64.
func (Params) AddNonZeroFloat ¶
AddNonZeroFloat adds a floating point value that is not zero.
type PassportData ¶
type PassportData struct { // Array with information about documents and other Telegram Passport // elements that was shared with the bot Data []EncryptedPassportElement `json:"data"` // Encrypted credentials required to decrypt the data Credentials *EncryptedCredentials `json:"credentials"` }
PassportData contains information about Telegram Passport data shared with the bot by the user.
type PassportElementError ¶
type PassportElementError interface{}
PassportElementError represents an error in the Telegram Passport element which was submitted that should be resolved by the user.
type PassportElementErrorDataField ¶
type PassportElementErrorDataField struct { // Error source, must be data Source string `json:"source"` // The section of the user's Telegram Passport which has the error, one // of "personal_details", "passport", "driver_license", "identity_card", // "internal_passport", "address" Type string `json:"type"` // Name of the data field which has the error FieldName string `json:"field_name"` // Base64-encoded data hash DataHash string `json:"data_hash"` // Error message Message string `json:"message"` }
PassportElementErrorDataField represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes.
type PassportElementErrorFile ¶
type PassportElementErrorFile struct { // Error source, must be file Source string `json:"source"` // The section of the user's Telegram Passport which has the issue, one // of "utility_bill", "bank_statement", "rental_agreement", // "passport_registration", "temporary_registration" Type string `json:"type"` // Base64-encoded file hash FileHash string `json:"file_hash"` // Error message Message string `json:"message"` }
PassportElementErrorFile represents an issue with a document scan. The error is considered resolved when the file with the document scan changes.
type PassportElementErrorFiles ¶
type PassportElementErrorFiles struct { // Error source, must be files Source string `json:"source"` // The section of the user's Telegram Passport which has the issue, one // of "utility_bill", "bank_statement", "rental_agreement", // "passport_registration", "temporary_registration" Type string `json:"type"` // List of base64-encoded file hashes FileHashes []string `json:"file_hashes"` // Error message Message string `json:"message"` }
PassportElementErrorFiles represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes.
type PassportElementErrorFrontSide ¶
type PassportElementErrorFrontSide struct { // Error source, must be front_side Source string `json:"source"` // The section of the user's Telegram Passport which has the issue, one // of "passport", "driver_license", "identity_card", "internal_passport" Type string `json:"type"` // Base64-encoded hash of the file with the front side of the document FileHash string `json:"file_hash"` // Error message Message string `json:"message"` }
PassportElementErrorFrontSide represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes.
type PassportElementErrorReverseSide ¶
type PassportElementErrorReverseSide struct { // Error source, must be reverse_side Source string `json:"source"` // The section of the user's Telegram Passport which has the issue, one // of "driver_license", "identity_card" Type string `json:"type"` // Base64-encoded hash of the file with the reverse side of the document FileHash string `json:"file_hash"` // Error message Message string `json:"message"` }
PassportElementErrorReverseSide represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes.
type PassportElementErrorSelfie ¶
type PassportElementErrorSelfie struct { // Error source, must be selfie Source string `json:"source"` // The section of the user's Telegram Passport which has the issue, one // of "passport", "driver_license", "identity_card", "internal_passport" Type string `json:"type"` // Base64-encoded hash of the file with the selfie FileHash string `json:"file_hash"` // Error message Message string `json:"message"` }
PassportElementErrorSelfie represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes.
type PassportFile ¶
type PassportFile struct { // Unique identifier for this file FileID string `json:"file_id"` // File size FileSize int `json:"file_size"` // Unix time when the file was uploaded FileDate int64 `json:"file_date"` }
PassportFile represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB.
type PassportRequestInfoConfig ¶
type PassportRequestInfoConfig struct { BotID int `json:"bot_id"` Scope *PassportScope `json:"scope"` Nonce string `json:"nonce"` PublicKey string `json:"public_key"` }
PassportRequestInfoConfig allows you to request passport info
type PassportScope ¶
type PassportScope struct { V int `json:"v"` Data []PassportScopeElement `json:"data"` }
PassportScope is the requested scopes of data.
type PassportScopeElement ¶
type PassportScopeElement interface {
ScopeType() string
}
PassportScopeElement supports using one or one of several elements.
type PassportScopeElementOne ¶
type PassportScopeElementOne struct { Type string `json:"type"` // One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email” Selfie bool `json:"selfie"` Translation bool `json:"translation"` NativeNames bool `json:"native_name"` }
PassportScopeElementOne requires the specified element be provided.
func (*PassportScopeElementOne) ScopeType ¶
func (eo *PassportScopeElementOne) ScopeType() string
ScopeType is the scope type.
type PassportScopeElementOneOfSeveral ¶
type PassportScopeElementOneOfSeveral struct { }
PassportScopeElementOneOfSeveral allows you to request any one of the requested documents.
func (*PassportScopeElementOneOfSeveral) ScopeType ¶
func (eo *PassportScopeElementOneOfSeveral) ScopeType() string
ScopeType is the scope type.
type PersonalDetails ¶
type PersonalDetails struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` MiddleName string `json:"middle_name"` BirthDate string `json:"birth_date"` Gender string `json:"gender"` CountryCode string `json:"country_code"` ResidenceCountryCode string `json:"residence_country_code"` FirstNameNative string `json:"first_name_native"` LastNameNative string `json:"last_name_native"` MiddleNameNative string `json:"middle_name_native"` }
PersonalDetails https://core.telegram.org/passport#personaldetails
type PhotoConfig ¶
PhotoConfig contains information about a SendPhoto request.
func NewPhotoShare ¶
func NewPhotoShare(chatID int64, fileID string) PhotoConfig
NewPhotoShare shares an existing photo. You may use this to reshare an existing photo without reuploading it.
chatID is where to send it, fileID is the ID of the file already uploaded.
func NewPhotoUpload ¶
func NewPhotoUpload(chatID int64, file interface{}) PhotoConfig
NewPhotoUpload creates a new photo uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
Note that you must send animated GIFs as a document.
type PhotoSize ¶
type PhotoSize struct { // FileID identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // Width photo width Width int `json:"width"` // Height photo height Height int `json:"height"` // FileSize file size // // optional FileSize int `json:"file_size"` }
PhotoSize contains information about photos.
type PinChatMessageConfig ¶
PinChatMessageConfig contains information of a message in a chat to pin.
type PreCheckoutConfig ¶
type PreCheckoutConfig struct { PreCheckoutQueryID string // required OK bool // required ErrorMessage string }
PreCheckoutConfig conatins information for answerPreCheckoutQuery request.
type PreCheckoutQuery ¶
type PreCheckoutQuery struct { // ID unique query identifier ID string `json:"id"` // From user who sent the query From *User `json:"from"` // Currency three-letter ISO 4217 currency code // // (see 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 currencies.json, // // (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). TotalAmount int `json:"total_amount"` // InvoicePayload bot specified invoice payload InvoicePayload string `json:"invoice_payload"` // ShippingOptionID identifier of the shipping option chosen by the user // // optional ShippingOptionID string `json:"shipping_option_id,omitempty"` // OrderInfo order info provided by the user // // optional OrderInfo *OrderInfo `json:"order_info,omitempty"` }
PreCheckoutQuery contains information about an incoming pre-checkout query.
type PromoteChatMemberConfig ¶
type PromoteChatMemberConfig struct { ChatMemberConfig CanChangeInfo *bool CanPostMessages *bool CanEditMessages *bool CanDeleteMessages *bool CanInviteUsers *bool CanRestrictMembers *bool CanPinMessages *bool CanPromoteMembers *bool }
PromoteChatMemberConfig contains fields to promote members of chat
type ReplyKeyboardHide ¶
type ReplyKeyboardHide struct { HideKeyboard bool `json:"hide_keyboard"` Selective bool `json:"selective"` // optional }
ReplyKeyboardHide allows the Bot to hide a custom keyboard.
func NewHideKeyboard ¶
func NewHideKeyboard(selective bool) ReplyKeyboardHide
NewHideKeyboard hides the keyboard, with the option for being selective or hiding for everyone.
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct { // Keyboard is an array of button rows, each represented by an Array of KeyboardButton objects Keyboard [][]KeyboardButton `json:"keyboard"` // ResizeKeyboard 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. // // optional ResizeKeyboard bool `json:"resize_keyboard"` // OneTimeKeyboard 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. // // optional OneTimeKeyboard bool `json:"one_time_keyboard"` // Selective use this parameter if you want to show the keyboard to 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 Message.ReplyToMessage not nil), sender of the original message. // // Example: A user requests to change the bot's language, // bot replies to the request with a keyboard to select the new language. // Other users in the group don't see the keyboard. // // optional Selective bool `json:"selective"` }
ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
func NewOneTimeReplyKeyboard ¶
func NewOneTimeReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup
NewOneTimeReplyKeyboard creates a new one time keyboard.
func NewReplyKeyboard ¶
func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup
NewReplyKeyboard creates a new regular keyboard with sane defaults.
type ReplyKeyboardRemove ¶
type ReplyKeyboardRemove struct { // RemoveKeyboard requests clients to remove the custom keyboard // (user will not be able to summon this keyboard; // if you want to hide the keyboard from sight but keep it accessible, // use one_time_keyboard in ReplyKeyboardMarkup). RemoveKeyboard bool `json:"remove_keyboard"` // Selective 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 Message.ReplyToMessage not nil), 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. // // optional Selective bool `json:"selective"` }
ReplyKeyboardRemove allows the Bot to hide a custom keyboard.
func NewRemoveKeyboard ¶
func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove
NewRemoveKeyboard hides the keyboard, with the option for being selective or hiding for everyone.
type ResponseParameters ¶
type ResponseParameters struct { MigrateToChatID int64 `json:"migrate_to_chat_id"` // optional RetryAfter int `json:"retry_after"` // optional }
ResponseParameters are various errors that can be returned in APIResponse.
type RestrictChatMemberConfig ¶
type RestrictChatMemberConfig struct { ChatMemberConfig UntilDate int64 CanSendMessages *bool CanSendMediaMessages *bool CanSendOtherMessages *bool CanAddWebPagePreviews *bool }
RestrictChatMemberConfig contains fields to restrict members of chat
type SecureData ¶
type SecureData map[string]*SecureValue
SecureData is a map of the fields and their encrypted values.
type SecureValue ¶
type SecureValue struct { Data *DataCredentials `json:"data"` FrontSide *FileCredentials `json:"front_side"` ReverseSide *FileCredentials `json:"reverse_side"` Selfie *FileCredentials `json:"selfie"` Translation []*FileCredentials `json:"translation"` Files []*FileCredentials `json:"files"` }
SecureValue contains encrypted values for a SecureData item.
type SendPollConfig ¶
type SendPollConfig struct { BaseChat Question string Options []string IsAnonymous bool Type string AllowsMultipleAnswers bool CorrectOptionID int64 Explanation string ExplanationParseMode string OpenPeriod int CloseDate int IsClosed bool }
SendPollConfig allows you to send a poll.
type SetChatDescriptionConfig ¶
SetChatDescriptionConfig contains information for change chat description.
type SetChatPhotoConfig ¶
type SetChatPhotoConfig struct {
BaseFile
}
SetChatPhotoConfig contains information for change chat photo
func NewSetChatPhotoShare ¶
func NewSetChatPhotoShare(chatID int64, fileID string) SetChatPhotoConfig
NewSetChatPhotoShare shares an existing photo. You may use this to reshare an existing photo without reuploading it.
chatID is where to send it, fileID is the ID of the file already uploaded.
func NewSetChatPhotoUpload ¶
func NewSetChatPhotoUpload(chatID int64, file interface{}) SetChatPhotoConfig
NewSetChatPhotoUpload creates a new chat photo uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
Note that you must send animated GIFs as a document.
type SetChatTitleConfig ¶
SetChatTitleConfig contains information for change chat title.
type SetGameScoreConfig ¶
type SetGameScoreConfig struct { UserID int Score int Force bool DisableEditMessage bool ChatID int64 ChannelUsername string MessageID int InlineMessageID string }
SetGameScoreConfig allows you to update the game score in a chat.
type ShippingAddress ¶
type ShippingAddress struct { // CountryCode ISO 3166-1 alpha-2 country code CountryCode string `json:"country_code"` // State if applicable State string `json:"state"` // City city 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 represents a shipping address.
type ShippingConfig ¶
type ShippingConfig struct { ShippingQueryID string // required OK bool // required ShippingOptions *[]ShippingOption ErrorMessage string }
ShippingConfig contains information for answerShippingQuery request.
type ShippingOption ¶
type ShippingOption struct { // ID shipping option identifier ID string `json:"id"` // Title option title Title string `json:"title"` // Prices list of price portions Prices *[]LabeledPrice `json:"prices"` }
ShippingOption represents one shipping option.
type ShippingQuery ¶
type ShippingQuery struct { // ID unique query identifier ID string `json:"id"` // From user who sent the query From *User `json:"from"` // InvoicePayload bot specified invoice payload InvoicePayload string `json:"invoice_payload"` // ShippingAddress user specified shipping address ShippingAddress *ShippingAddress `json:"shipping_address"` }
ShippingQuery contains information about an incoming shipping query.
type Sticker ¶
type Sticker struct { // FileUniqueID is an 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"` // FileID is an identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // Width sticker width Width int `json:"width"` // Height sticker height Height int `json:"height"` // Thumbnail sticker thumbnail in the .WEBP or .JPG format // // optional Thumbnail *PhotoSize `json:"thumb"` // Emoji associated with the sticker // // optional Emoji string `json:"emoji"` // FileSize // // optional FileSize int `json:"file_size"` // SetName of the sticker set to which the sticker belongs // // optional SetName string `json:"set_name"` // IsAnimated true, if the sticker is animated // // optional IsAnimated bool `json:"is_animated"` }
Sticker contains information about a sticker.
type StickerConfig ¶
type StickerConfig struct {
BaseFile
}
StickerConfig contains information about a SendSticker request.
func NewStickerShare ¶
func NewStickerShare(chatID int64, fileID string) StickerConfig
NewStickerShare shares an existing sticker. You may use this to reshare an existing sticker without reuploading it.
chatID is where to send it, fileID is the ID of the sticker already uploaded.
func NewStickerUpload ¶
func NewStickerUpload(chatID int64, file interface{}) StickerConfig
NewStickerUpload creates a new sticker uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type StickerSet ¶
type StickerSet struct { // Name sticker set name Name string `json:"name"` // Title sticker set title Title string `json:"title"` // IsAnimated true, if the sticker set contains animated stickers IsAnimated bool `json:"is_animated"` // ContainsMasks true, if the sticker set contains masks ContainsMasks bool `json:"contains_masks"` // Stickers list of all set stickers Stickers []Sticker `json:"stickers"` }
StickerSet contains information about an sticker set.
type SuccessfulPayment ¶
type SuccessfulPayment struct { // Currency three-letter ISO 4217 currency code // (see 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 currencies.json, // (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). TotalAmount int `json:"total_amount"` // InvoicePayload bot specified invoice payload InvoicePayload string `json:"invoice_payload"` // ShippingOptionID identifier of the shipping option chosen by the user // // optional ShippingOptionID string `json:"shipping_option_id,omitempty"` // OrderInfo order info provided by the user // // optional OrderInfo *OrderInfo `json:"order_info,omitempty"` // TelegramPaymentChargeID telegram payment identifier TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` // ProviderPaymentChargeID provider payment identifier ProviderPaymentChargeID string `json:"provider_payment_charge_id"` }
SuccessfulPayment contains basic information about a successful payment.
type UnpinChatMessageConfig ¶
type UnpinChatMessageConfig struct {
ChatID int64
}
UnpinChatMessageConfig contains information of chat to unpin.
type Update ¶
type Update struct { // UpdateID 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. UpdateID int `json:"update_id"` // Message new incoming message of any kind — text, photo, sticker, etc. // // optional Message *Message `json:"message"` // EditedMessage // // optional EditedMessage *Message `json:"edited_message"` // ChannelPost new version of a message that is known to the bot and was edited // // optional ChannelPost *Message `json:"channel_post"` // EditedChannelPost new incoming channel post of any kind — text, photo, sticker, etc. // // optional EditedChannelPost *Message `json:"edited_channel_post"` // InlineQuery new incoming inline query // // optional InlineQuery *InlineQuery `json:"inline_query"` // ChosenInlineResult is 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. // // optional ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result"` // CallbackQuery new incoming callback query // // optional CallbackQuery *CallbackQuery `json:"callback_query"` // ShippingQuery new incoming shipping query. Only for invoices with flexible price // // optional ShippingQuery *ShippingQuery `json:"shipping_query"` // PreCheckoutQuery new incoming pre-checkout query. Contains full information about checkout // // optional PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query"` }
Update is an update response, from GetUpdates.
type UpdateConfig ¶
UpdateConfig contains information about a GetUpdates request.
func NewUpdate ¶
func NewUpdate(offset int) UpdateConfig
NewUpdate gets updates since the last Offset.
offset is the last Update ID to include. You likely want to set this to the last Update ID plus 1.
type UpdatesChannel ¶
type UpdatesChannel <-chan Update
UpdatesChannel is the channel for getting updates.
func (UpdatesChannel) Clear ¶
func (ch UpdatesChannel) Clear()
Clear discards all unprocessed incoming updates.
type User ¶
type User struct { // ID is a unique identifier for this user or bot ID int `json:"id"` // FirstName user's or bot's first name FirstName string `json:"first_name"` // LastName user's or bot's last name // // optional LastName string `json:"last_name"` // UserName user's or bot's username // // optional UserName string `json:"username"` // LanguageCode IETF language tag of the user's language // more info: https://en.wikipedia.org/wiki/IETF_language_tag // // optional LanguageCode string `json:"language_code"` // IsBot true, if this user is a bot // // optional IsBot bool `json:"is_bot"` }
User represents a Telegram user or bot.
type UserProfilePhotos ¶
type UserProfilePhotos struct { // TotalCount 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 contains a set of user profile photos.
type UserProfilePhotosConfig ¶
UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.
func NewUserProfilePhotos ¶
func NewUserProfilePhotos(userID int) UserProfilePhotosConfig
NewUserProfilePhotos gets user profile photos.
userID is the ID of the user you wish to get profile photos from.
type Venue ¶
type Venue struct { // Location venue location Location Location `json:"location"` // Title name of the venue Title string `json:"title"` // Address of the venue Address string `json:"address"` // FoursquareID foursquare identifier of the venue // // optional FoursquareID string `json:"foursquare_id"` }
Venue contains information about a venue, including its Location.
type VenueConfig ¶
type VenueConfig struct { BaseChat Latitude float64 // required Longitude float64 // required Title string // required Address string // required FoursquareID string }
VenueConfig contains information about a SendVenue request.
type Video ¶
type Video struct { // FileID identifier for this file, which can be used to download or reuse the file FileID 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"` // Thumbnail video thumbnail // // optional Thumbnail *PhotoSize `json:"thumb"` // MimeType of a file as defined by sender // // optional MimeType string `json:"mime_type"` // FileSize file size // // optional FileSize int `json:"file_size"` }
Video contains information about a video.
type VideoConfig ¶
VideoConfig contains information about a SendVideo request.
func NewVideoShare ¶
func NewVideoShare(chatID int64, fileID string) VideoConfig
NewVideoShare shares an existing video. You may use this to reshare an existing video without reuploading it.
chatID is where to send it, fileID is the ID of the video already uploaded.
func NewVideoUpload ¶
func NewVideoUpload(chatID int64, file interface{}) VideoConfig
NewVideoUpload creates a new video uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type VideoNote ¶
type VideoNote struct { // FileID identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // Length video width and height (diameter of the video message) as defined by sender Length int `json:"length"` // Duration of the video in seconds as defined by sender Duration int `json:"duration"` // Thumbnail video thumbnail // // optional Thumbnail *PhotoSize `json:"thumb"` // FileSize file size // // optional FileSize int `json:"file_size"` }
VideoNote contains information about a video.
type VideoNoteConfig ¶
VideoNoteConfig contains information about a SendVideoNote request.
func NewVideoNoteShare ¶
func NewVideoNoteShare(chatID int64, length int, fileID string) VideoNoteConfig
NewVideoNoteShare shares an existing video. You may use this to reshare an existing video without reuploading it.
chatID is where to send it, fileID is the ID of the video already uploaded.
func NewVideoNoteUpload ¶
func NewVideoNoteUpload(chatID int64, length int, file interface{}) VideoNoteConfig
NewVideoNoteUpload creates a new video note uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type Voice ¶
type Voice struct { // FileID identifier for this file, which can be used to download or reuse the file FileID string `json:"file_id"` // Duration of the audio in seconds as defined by sender Duration int `json:"duration"` // MimeType of the file as defined by sender // // optional MimeType string `json:"mime_type"` // FileSize file size // // optional FileSize int `json:"file_size"` }
Voice contains information about a voice.
type VoiceConfig ¶
VoiceConfig contains information about a SendVoice request.
func NewVoiceShare ¶
func NewVoiceShare(chatID int64, fileID string) VoiceConfig
NewVoiceShare shares an existing voice. You may use this to reshare an existing voice without reuploading it.
chatID is where to send it, fileID is the ID of the video already uploaded.
func NewVoiceUpload ¶
func NewVoiceUpload(chatID int64, file interface{}) VoiceConfig
NewVoiceUpload creates a new voice uploader.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type WebhookConfig ¶
WebhookConfig contains information about a SetWebhook request.
func NewWebhook ¶
func NewWebhook(link string) WebhookConfig
NewWebhook creates a new webhook.
link is the url parsable link you wish to get the updates.
Example ¶
package main import ( "log" "net/http" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api" ) func main() { bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") if err != nil { log.Fatal(err) } bot.Debug = true log.Printf("Authorized on account %s", bot.Self.UserName) _, err = bot.SetWebhook(tgbotapi.NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")) if err != nil { log.Fatal(err) } info, err := bot.GetWebhookInfo() if err != nil { log.Fatal(err) } if info.LastErrorDate != 0 { log.Printf("[Telegram callback failed]%s", info.LastErrorMessage) } updates := bot.ListenForWebhook("/" + bot.Token) go http.ListenAndServeTLS("0.0.0.0:8443", "cert.pem", "key.pem", nil) for update := range updates { log.Printf("%+v\n", update) } }
Output:
func NewWebhookWithCert ¶
func NewWebhookWithCert(link string, file interface{}) WebhookConfig
NewWebhookWithCert creates a new webhook with a certificate.
link is the url you wish to get webhooks, file contains a string to a file, FileReader, or FileBytes.
type WebhookInfo ¶
type WebhookInfo struct { // URL webhook 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 number of updates awaiting delivery. PendingUpdateCount int `json:"pending_update_count"` // LastErrorDate unix time for the most recent error // that happened when trying to deliver an update via webhook. // // optional LastErrorDate int `json:"last_error_date"` // LastErrorMessage error message in human-readable format for the most recent error // that happened when trying to deliver an update via webhook. // // optional LastErrorMessage string `json:"last_error_message"` // MaxConnections maximum allowed number of simultaneous // HTTPS connections to the webhook for update delivery. // // optional MaxConnections int `json:"max_connections"` }
WebhookInfo is information about a currently set webhook.
func (WebhookInfo) IsSet ¶
func (info WebhookInfo) IsSet() bool
IsSet returns true if a webhook is currently set.