Documentation ¶
Overview ¶
Package tgbotapi has functions and types used for interacting with the Telegram Bot API.
Index ¶
- Constants
- func SetLogger(logger BotLogger) error
- func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error
- type APIResponse
- type AddStickerConfig
- type Animation
- type AnimationConfig
- type Audio
- type AudioConfig
- type BaseChat
- type BaseEdit
- type BaseFile
- type BaseInputMedia
- type BotAPI
- func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error)
- func (bot *BotAPI) GetChatAdministrators(config ChatAdministratorsConfig) ([]ChatMember, error)
- func (bot *BotAPI) GetChatMember(config GetChatMemberConfig) (ChatMember, error)
- func (bot *BotAPI) GetChatMembersCount(config ChatMemberCountConfig) (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 ChatInviteLinkConfig) (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
- func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error)
- func (bot *BotAPI) GetWebhookInfo() (WebhookInfo, error)
- func (bot *BotAPI) HandleUpdate(res http.ResponseWriter, req *http.Request) Update
- func (bot *BotAPI) IsMessageToMe(message Message) bool
- func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel
- func (bot *BotAPI) MakeRequest(endpoint string, params Params) (*APIResponse, error)
- func (bot *BotAPI) Request(c Chattable) (*APIResponse, error)
- func (bot *BotAPI) Send(c Chattable) (Message, error)
- func (bot *BotAPI) SendMediaGroup(config MediaGroupConfig) ([]Message, error)
- func (bot *BotAPI) SetAPIEndpoint(apiEndpoint string)
- func (bot *BotAPI) StopPoll(config StopPollConfig) (Poll, error)
- func (bot *BotAPI) StopReceivingUpdates()
- func (bot *BotAPI) UploadFiles(endpoint string, params Params, files []RequestFile) (*APIResponse, error)
- type BotCommand
- type BotLogger
- type CallbackConfig
- type CallbackGame
- type CallbackQuery
- type Chat
- type ChatActionConfig
- type ChatAdministratorsConfig
- type ChatAnimation
- type ChatConfig
- type ChatConfigWithUser
- type ChatInfoConfig
- type ChatInviteLinkConfig
- type ChatMember
- type ChatMemberConfig
- type ChatMemberCountConfig
- type ChatPermissions
- type ChatPhoto
- type Chattable
- type ChosenInlineResult
- type Contact
- type ContactConfig
- type Credentials
- type DataCredentials
- type DeleteChatPhotoConfig
- type DeleteChatStickerSetConfig
- type DeleteMessageConfig
- type DeleteStickerConfig
- type Dice
- type DiceConfig
- type Document
- type DocumentConfig
- type EditMessageCaptionConfig
- type EditMessageLiveLocationConfig
- type EditMessageMediaConfig
- type EditMessageReplyMarkupConfig
- type EditMessageTextConfig
- type EncryptedCredentials
- type EncryptedPassportElement
- type Error
- type File
- type FileBytes
- type FileConfig
- type FileCredentials
- type FileID
- type FileReader
- type FileURL
- type Fileable
- type ForceReply
- type ForwardConfig
- type Game
- type GameConfig
- type GameHighScore
- type GetChatMemberConfig
- type GetGameHighScoresConfig
- type GetMyCommandsConfig
- type GetStickerSetConfig
- type GroupChat
- 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 InlineQueryResultContact
- type InlineQueryResultDocument
- type InlineQueryResultGIF
- type InlineQueryResultGame
- type InlineQueryResultLocation
- type InlineQueryResultMPEG4GIF
- type InlineQueryResultPhoto
- type InlineQueryResultVenue
- type InlineQueryResultVideo
- type InlineQueryResultVoice
- type InputContactMessageContent
- type InputLocationMessageContent
- type InputMediaAnimation
- type InputMediaAudio
- type InputMediaDocument
- type InputMediaPhoto
- type InputMediaVideo
- type InputTextMessageContent
- type InputVenueMessageContent
- type Invoice
- type InvoiceConfig
- type KeyboardButton
- type KeyboardButtonPollType
- type KickChatMemberConfig
- type LabeledPrice
- type LeaveChatConfig
- type Location
- type LocationConfig
- type LoginURL
- type MaskPosition
- 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 NewStickerSetConfig
- 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 Poll
- type PollAnswer
- type PollOption
- type PreCheckoutConfig
- type PreCheckoutQuery
- type PromoteChatMemberConfig
- type RemoveWebhookConfig
- type ReplyKeyboardHide
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type RequestFile
- type ResponseParameters
- type RestrictChatMemberConfig
- type SecureData
- type SecureValue
- type SendPollConfig
- type SetChatAdministratorCustomTitle
- type SetChatDescriptionConfig
- type SetChatPermissionsConfig
- type SetChatPhotoConfig
- type SetChatStickerSetConfig
- type SetChatTitleConfig
- type SetGameScoreConfig
- type SetMyCommandsConfig
- type SetStickerPositionConfig
- type SetStickerSetThumbConfig
- type ShippingAddress
- type ShippingConfig
- type ShippingOption
- type ShippingQuery
- type Sticker
- type StickerConfig
- type StickerSet
- type StopMessageLiveLocationConfig
- type StopPollConfig
- type SuccessfulPayment
- type UnbanChatMemberConfig
- type UnpinChatMessageConfig
- type Update
- type UpdateConfig
- type UpdatesChannel
- type UploadStickerConfig
- 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" ChatRecordVideoNote = "record_video_note" ChatUploadVideoNote = "upload_video_note" )
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 WriteToHTTPResponse ¶
func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error
WriteToHTTPResponse writes the request to the HTTP ResponseWriter.
It doesn't support uploading files.
See https://core.telegram.org/bots/api#making-requests-when-getting-updates for details.
Types ¶
type APIResponse ¶
type APIResponse struct { Ok bool `json:"ok"` Result json.RawMessage `json:"result,omitempty"` ErrorCode int `json:"error_code,omitempty"` Description string `json:"description,omitempty"` Parameters *ResponseParameters `json:"parameters,omitempty"` }
APIResponse is a response from the Telegram API with the result stored raw.
type AddStickerConfig ¶
type AddStickerConfig struct { UserID int64 Name string PNGSticker interface{} TGSSticker interface{} Emojis string MaskPosition *MaskPosition }
AddStickerConfig allows you to add a sticker to a set.
type Animation ¶
type Animation struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Thumb PhotoSize `json:"thumb"` FileName string `json:"file_name"` MimeType string `json:"mime_type"` FileSize int `json:"file_size"` }
Animation is a GIF animation demonstrating the game.
type AnimationConfig ¶
type AnimationConfig struct { BaseFile Duration int Thumb interface{} Caption string ParseMode string }
AnimationConfig contains information about a SendAnimation request.
func NewAnimation ¶
func NewAnimation(chatID int64, file interface{}) AnimationConfig
NewAnimation creates a new sendAnimation request.
type Audio ¶
type Audio struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Duration int `json:"duration"` Performer string `json:"performer,omitempty"` // optional Title string `json:"title,omitempty"` // optional MimeType string `json:"mime_type,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional }
Audio contains information about audio.
type AudioConfig ¶
type AudioConfig struct { BaseFile Thumb interface{} Caption string ParseMode string Duration int Performer string Title string }
AudioConfig contains information about a SendAudio request.
func NewAudio ¶
func NewAudio(chatID int64, file interface{}) AudioConfig
NewAudio creates a new sendAudio request.
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{} }
BaseFile is a base type for all file config types.
type BaseInputMedia ¶
type BaseInputMedia struct { Type string `json:"type"` Media interface{} `json:"media"` Caption string `json:"caption,omitempty"` ParseMode string `json:"parse_mode,omitempty"` }
BaseInputMedia is a base type for the InputMedia types.
type BotAPI ¶
type BotAPI struct { Token string `json:"token"` Debug bool `json:"debug"` Buffer int `json:"buffer"` Self User `json:"-"` Client *http.Client `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 ¶
bot, err := NewBotAPI("MyAwesomeBotToken") if err != nil { panic(err) } bot.Debug = true log.Printf("Authorized on account %s", bot.Self.UserName) u := NewUpdate(0) u.Timeout = 60 updates := 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 := NewMessage(update.Message.Chat.ID, update.Message.Text) msg.ReplyToMessageID = update.Message.MessageID bot.Send(msg) }
Output:
func NewBotAPIWithClient ¶
NewBotAPIWithClient creates a new BotAPI instance and allows you to pass a http.Client.
It requires a token, provided by @BotFather on Telegram.
func (*BotAPI) GetChat ¶
func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error)
GetChat gets information about a chat.
func (*BotAPI) GetChatAdministrators ¶
func (bot *BotAPI) GetChatAdministrators(config ChatAdministratorsConfig) ([]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 GetChatMemberConfig) (ChatMember, error)
GetChatMember gets a specific chat member.
func (*BotAPI) GetChatMembersCount ¶
func (bot *BotAPI) GetChatMembersCount(config ChatMemberCountConfig) (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 ChatInviteLinkConfig) (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 currently registered commands.
func (*BotAPI) GetStickerSet ¶
func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
GetStickerSet returns a StickerSet.
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
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) ListenForWebhook ¶
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel
ListenForWebhook registers a http handler for a webhook.
func (*BotAPI) MakeRequest ¶
func (bot *BotAPI) MakeRequest(endpoint string, params Params) (*APIResponse, error)
MakeRequest makes a request to a specific endpoint with our token.
func (*BotAPI) Request ¶
func (bot *BotAPI) Request(c Chattable) (*APIResponse, error)
Request sends a Chattable to Telegram, and returns the APIResponse.
func (*BotAPI) Send ¶
Send will send a Chattable item to Telegram and provides the returned Message.
func (*BotAPI) SendMediaGroup ¶
func (bot *BotAPI) SendMediaGroup(config MediaGroupConfig) ([]Message, error)
SendMediaGroup sends a media group and returns the resulting messages.
func (*BotAPI) SetAPIEndpoint ¶
SetAPIEndpoint changes the Telegram Bot API endpoint used by the instance.
func (*BotAPI) StopPoll ¶
func (bot *BotAPI) StopPoll(config StopPollConfig) (Poll, error)
StopPoll stops a poll and returns the result.
func (*BotAPI) StopReceivingUpdates ¶
func (bot *BotAPI) StopReceivingUpdates()
StopReceivingUpdates stops the go routine which receives updates
func (*BotAPI) UploadFiles ¶
func (bot *BotAPI) UploadFiles(endpoint string, params Params, files []RequestFile) (*APIResponse, error)
UploadFiles makes a request to the API with files.
type BotCommand ¶
BotCommand represents Telegram's understanding of a 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 string `json:"id"` From *User `json:"from"` Message *Message `json:"message,omitempty"` // optional InlineMessageID string `json:"inline_message_id,omitempty"` // optional ChatInstance string `json:"chat_instance"` Data string `json:"data,omitempty"` // optional GameShortName string `json:"game_short_name,omitempty"` // optional }
CallbackQuery is data sent when a keyboard button with callback data is clicked.
type Chat ¶
type Chat struct { ID int64 `json:"id"` Type string `json:"type"` Title string `json:"title,omitempty"` // optional UserName string `json:"username,omitempty"` // optional FirstName string `json:"first_name,omitempty"` // optional LastName string `json:"last_name,omitempty"` // optional AllMembersAreAdmins bool `json:"all_members_are_administrators,omitempty"` // deprecated, optional Photo *ChatPhoto `json:"photo,omitempty"` // optional Description string `json:"description,omitempty"` // optional InviteLink string `json:"invite_link,omitempty"` // optional PinnedMessage *Message `json:"pinned_message,omitempty"` // optional Permissions *ChatPermissions `json:"permissions,omitempty"` // optional SlowModeDelay int `json:"slow_mode_delay,omitempty"` // optional StickerSetName string `json:"sticker_set_name,omitempty"` // optional CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"` // optional }
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 ChatAdministratorsConfig ¶
type ChatAdministratorsConfig struct {
ChatConfig
}
ChatAdministratorsConfig contains information about getting chat administrators.
type ChatAnimation ¶
type ChatAnimation struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Width int `json:"width"` Height int `json:"height"` Duration int `json:"duration"` Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional FileName string `json:"file_name,omitempty"` // optional MimeType string `json:"mime_type,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional }
ChatAnimation contains information about an animation.
type ChatConfig ¶
ChatConfig contains information about getting information on a chat.
type ChatConfigWithUser ¶
ChatConfigWithUser contains information about a chat and a user.
type ChatInfoConfig ¶
type ChatInfoConfig struct {
ChatConfig
}
ChatInfoConfig contains information about getting chat information.
type ChatInviteLinkConfig ¶
type ChatInviteLinkConfig struct {
ChatConfig
}
ChatInviteLinkConfig contains information about getting a chat link.
Note that generating a new link will revoke any previous links.
type ChatMember ¶
type ChatMember struct { User *User `json:"user"` Status string `json:"status"` CustomTitle string `json:"custom_title,omitempty"` // optional UntilDate int64 `json:"until_date,omitempty"` // optional CanBeEdited bool `json:"can_be_edited,omitempty"` // optional CanPostMessages bool `json:"can_post_messages,omitempty"` // optional CanEditMessages bool `json:"can_edit_messages,omitempty"` // optional CanDeleteMessages bool `json:"can_delete_messages,omitempty"` // optional CanRestrictMembers bool `json:"can_restrict_members,omitempty"` // optional CanPromoteMembers bool `json:"can_promote_members,omitempty"` // optional CanChangeInfo bool `json:"can_change_info,omitempty"` // optional CanInviteUsers bool `json:"can_invite_users,omitempty"` // optional CanPinMessages bool `json:"can_pin_messages,omitempty"` // optional IsChatMember bool `json:"is_member,omitempty"` // optional CanSendMessages bool `json:"can_send_messages,omitempty"` // optional CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"` // optional CanSendPolls bool `json:"can_send_polls,omitempty"` // optional CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"` // optional CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"` // optional }
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 ChatMemberCountConfig ¶
type ChatMemberCountConfig struct {
ChatConfig
}
ChatMemberCountConfig contains information about getting the number of users in a chat.
type ChatPermissions ¶
type ChatPermissions struct { CanSendMessages bool `json:"can_send_messages"` CanSendMediaMessages bool `json:"can_send_media_messages"` CanSendPolls bool `json:"can_send_polls"` CanSendOtherMessages bool `json:"can_send_other_messages"` CanAddWebPagePreviews bool `json:"can_add_web_page_previews"` CanChangeInfo bool `json:"can_change_info"` CanInviteUsers bool `json:"can_invite_users"` CanPinMessages bool `json:"can_pin_messages"` }
ChatPermissions describes actions that a non-administrator user is allowed to take in a chat. All fields are optional.
type ChatPhoto ¶
type ChatPhoto struct { SmallFileID string `json:"small_file_id"` SmallFileUniqueID string `json:"small_file_unique_id"` BigFileID string `json:"big_file_id"` BigFileUniqueID string `json:"big_file_unique_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 string `json:"result_id"` From *User `json:"from"` Location *Location `json:"location"` InlineMessageID string `json:"inline_message_id"` Query string `json:"query"` }
ChosenInlineResult is an inline query result chosen by a User
type Contact ¶
type Contact struct { PhoneNumber string `json:"phone_number"` FirstName string `json:"first_name"` LastName string `json:"last_name,omitempty"` // optional UserID int `json:"user_id,omitempty"` // optional VCard string `json:"vcard,omitempty"` // optional }
Contact contains information about a contact.
Note that LastName and UserID may be empty.
type ContactConfig ¶
type ContactConfig struct { BaseChat PhoneNumber string FirstName string LastName string VCard string }
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 ¶
DeleteChatPhotoConfig allows you to delete a group, supergroup, or channel's photo.
func NewDeleteChatPhoto ¶
func NewDeleteChatPhoto(chatID int64, photo interface{}) DeleteChatPhotoConfig
NewDeleteChatPhoto allows you to delete the photo for a chat.
type DeleteChatStickerSetConfig ¶
DeleteChatStickerSetConfig allows you to remove a supergroup's sticker set.
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 DeleteStickerConfig ¶
type DeleteStickerConfig struct {
Sticker string
}
DeleteStickerConfig allows you to delete a sticker from a set.
type DiceConfig ¶
DiceConfig allows you to send a random dice roll to Telegram.
Emoji may be one of the following: 🎲 (1-6), 🎯 (1-6), 🏀 (1-5).
func NewDiceWithEmoji ¶
func NewDiceWithEmoji(chatID int64, emoji string) DiceConfig
NewDiceWithEmoji allows you to send a random roll of one of many types.
Emoji may be 🎲 (1-6), 🎯 (1-6), or 🏀 (1-5).
func NewSendDice
deprecated
func NewSendDice(chatID int64) DiceConfig
NewSendDice allows you to send a random dice roll.
Deprecated: Use NewDice instead.
type Document ¶
type Document struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional FileName string `json:"file_name,omitempty"` // optional MimeType string `json:"mime_type,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional }
Document contains information about a document.
type DocumentConfig ¶
DocumentConfig contains information about a SendDocument request.
func NewDocument ¶
func NewDocument(chatID int64, file interface{}) DocumentConfig
NewDocument creates a new sendDocument request.
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 EditMessageLiveLocationConfig ¶
type EditMessageLiveLocationConfig struct { BaseEdit Latitude float64 // required Longitude float64 // required }
EditMessageLiveLocationConfig allows you to update a live location.
type EditMessageMediaConfig ¶
type EditMessageMediaConfig struct { BaseEdit Media interface{} }
EditMessageMediaConfig allows you to make an editMessageMedia request.
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.
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 string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` FileSize int `json:"file_size,omitempty"` // optional FilePath string `json:"file_path,omitempty"` // optional }
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.
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 bool `json:"force_reply"` Selective bool `json:"selective"` // optional }
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 string `json:"title"` Description string `json:"description"` Photo []PhotoSize `json:"photo"` Text string `json:"text"` TextEntities []MessageEntity `json:"text_entities"` 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 int `json:"position"` User User `json:"user"` Score int `json:"score"` }
GameHighScore is a user's score and position on the leaderboard.
type GetChatMemberConfig ¶
type GetChatMemberConfig struct {
ChatConfigWithUser
}
GetChatMemberConfig is information about getting a specific member in a chat.
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 GetMyCommandsConfig ¶
type GetMyCommandsConfig struct{}
GetMyCommandsConfig gets a list of the currently registered commands.
type GetStickerSetConfig ¶
type GetStickerSetConfig struct {
Name string
}
GetStickerSetConfig allows you to get the stickers in a 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.
Example ¶
bot, err := NewBotAPI("MyAwesomeBotToken") // create new bot if err != nil { panic(err) } log.Printf("Authorized on account %s", bot.Self.UserName) u := NewUpdate(0) u.Timeout = 60 updates := bot.GetUpdatesChan(u) for update := range updates { if update.InlineQuery == nil { // if no inline query, ignore it continue } article := NewInlineQueryResultArticle(update.InlineQuery.ID, "Echo", update.InlineQuery.Query) article.Description = update.InlineQuery.Query inlineConf := InlineConfig{ InlineQueryID: update.InlineQuery.ID, IsPersonal: true, CacheTime: 0, Results: []interface{}{article}, } if _, err := bot.Request(inlineConf); err != nil { log.Println(err) } }
Output:
type InlineKeyboardButton ¶
type InlineKeyboardButton struct { Text string `json:"text"` URL *string `json:"url,omitempty"` // optional LoginURL *LoginURL `json:"login_url,omitempty"` // optional CallbackData *string `json:"callback_data,omitempty"` // optional SwitchInlineQuery *string `json:"switch_inline_query,omitempty"` // optional SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"` // optional CallbackGame *CallbackGame `json:"callback_game,omitempty"` // optional Pay bool `json:"pay,omitempty"` // optional }
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 [][]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 string `json:"id"` From *User `json:"from"` Location *Location `json:"location,omitempty"` // optional Query string `json:"query"` Offset string `json:"offset"` }
InlineQuery is a Query from Telegram for an inline request.
type InlineQueryResultArticle ¶
type InlineQueryResultArticle struct { Type string `json:"type"` // required ID string `json:"id"` // required Title string `json:"title"` // required InputMessageContent interface{} `json:"input_message_content,omitempty"` // required ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` URL string `json:"url"` HideURL bool `json:"hide_url"` Description string `json:"description"` ThumbURL string `json:"thumb_url"` ThumbWidth int `json:"thumb_width"` 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 string `json:"type"` // required ID string `json:"id"` // required URL string `json:"audio_url"` // required Title string `json:"title"` // required Caption string `json:"caption"` Performer string `json:"performer"` Duration int `json:"audio_duration"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required AudioID string `json:"audio_file_id"` // required Caption string `json:"caption"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required DocumentID string `json:"document_file_id"` // required Title string `json:"title"` // required Caption string `json:"caption"` Description string `json:"description"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required GifID string `json:"gif_file_id"` // required Title string `json:"title"` Caption string `json:"caption"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required MGifID string `json:"mpeg4_file_id"` // required Title string `json:"title"` Caption string `json:"caption"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 photo.
type InlineQueryResultCachedPhoto ¶
type InlineQueryResultCachedPhoto struct { Type string `json:"type"` // required ID string `json:"id"` // required PhotoID string `json:"photo_file_id"` // required Title string `json:"title"` Description string `json:"description"` Caption string `json:"caption"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required StickerID string `json:"sticker_file_id"` // required Title string `json:"title"` // required ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required VideoID string `json:"video_file_id"` // required Title string `json:"title"` // required Description string `json:"description"` Caption string `json:"caption"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required VoiceID string `json:"voice_file_id"` // required Title string `json:"title"` // required Caption string `json:"caption"` ParseMode string `json:"parse_mode"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 InlineQueryResultContact ¶
type InlineQueryResultContact struct { Type string `json:"type"` // required ID string `json:"id"` // required PhoneNumber string `json:"phone_number"` // required FirstName string `json:"first_name"` // required LastName string `json:"last_name"` VCard string `json:"vcard"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"` ThumbURL string `json:"thumb_url"` ThumbWidth int `json:"thumb_width"` ThumbHeight int `json:"thumb_height"` }
InlineQueryResultContact is an inline query response contact.
type InlineQueryResultDocument ¶
type InlineQueryResultDocument struct { Type string `json:"type"` // required ID string `json:"id"` // required Title string `json:"title"` // required Caption string `json:"caption"` URL string `json:"document_url"` // required MimeType string `json:"mime_type"` // required Description string `json:"description"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"` ThumbURL string `json:"thumb_url"` ThumbWidth int `json:"thumb_width"` 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 string `json:"type"` // required ID string `json:"id"` // required URL string `json:"gif_url"` // required ThumbURL string `json:"thumb_url"` // required ThumbMimeType string `json:"thumb_mime_type"` Width int `json:"gif_width,omitempty"` Height int `json:"gif_height,omitempty"` Duration int `json:"gif_duration,omitempty"` Title string `json:"title,omitempty"` Caption string `json:"caption,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` ID string `json:"id"` GameShortName string `json:"game_short_name"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` }
InlineQueryResultGame is an inline query response game.
type InlineQueryResultLocation ¶
type InlineQueryResultLocation struct { Type string `json:"type"` // required ID string `json:"id"` // required Latitude float64 `json:"latitude"` // required Longitude float64 `json:"longitude"` // required LivePeriod int `json:"live_period"` // optional Title string `json:"title"` // required ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"` ThumbURL string `json:"thumb_url"` ThumbWidth int `json:"thumb_width"` 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 string `json:"type"` // required ID string `json:"id"` // required URL string `json:"mpeg4_url"` // required Width int `json:"mpeg4_width"` Height int `json:"mpeg4_height"` Duration int `json:"mpeg4_duration"` ThumbURL string `json:"thumb_url"` ThumbMimeType string `json:"thumb_mime_type"` Title string `json:"title"` Caption string `json:"caption"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required URL string `json:"photo_url"` // required MimeType string `json:"mime_type"` Width int `json:"photo_width"` Height int `json:"photo_height"` ThumbURL string `json:"thumb_url"` Title string `json:"title"` Description string `json:"description"` Caption string `json:"caption"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required Latitude float64 `json:"latitude"` // required Longitude float64 `json:"longitude"` // required Title string `json:"title"` // required Address string `json:"address"` // required FoursquareID string `json:"foursquare_id"` FoursquareType string `json:"foursquare_type"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` InputMessageContent interface{} `json:"input_message_content,omitempty"` ThumbURL string `json:"thumb_url"` ThumbWidth int `json:"thumb_width"` 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 string `json:"type"` // required ID string `json:"id"` // required URL string `json:"video_url"` // required MimeType string `json:"mime_type"` // required ThumbURL string `json:"thumb_url"` Title string `json:"title"` Caption string `json:"caption"` Width int `json:"video_width"` Height int `json:"video_height"` Duration int `json:"video_duration"` Description string `json:"description"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"type"` // required ID string `json:"id"` // required URL string `json:"voice_url"` // required Title string `json:"title"` // required Caption string `json:"caption"` Duration int `json:"voice_duration"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` 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 string `json:"phone_number"` FirstName string `json:"first_name"` LastName string `json:"last_name"` VCard string `json:"vcard"` }
InputContactMessageContent contains a contact for displaying as an inline query result.
type InputLocationMessageContent ¶
type InputLocationMessageContent struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` }
InputLocationMessageContent contains a location for displaying as an inline query result.
type InputMediaAnimation ¶
type InputMediaAnimation struct { BaseInputMedia Width int `json:"width"` Height int `json:"height"` Duration int `json:"duration"` }
InputMediaAnimation is an animation to send as part of a media group.
func NewInputMediaAnimation ¶
func NewInputMediaAnimation(media interface{}) InputMediaAnimation
NewInputMediaAnimation creates a new InputMediaAnimation.
type InputMediaAudio ¶
type InputMediaAudio struct { BaseInputMedia Duration int `json:"duration"` Performer string `json:"performer"` Title string `json:"title"` }
InputMediaAudio is a audio to send as part of a media group.
func NewInputMediaAudio ¶
func NewInputMediaAudio(media interface{}) InputMediaAudio
NewInputMediaAudio creates a new InputMediaAudio.
type InputMediaDocument ¶
type InputMediaDocument struct {
BaseInputMedia
}
InputMediaDocument is a audio to send as part of a media group.
func NewInputMediaDocument ¶
func NewInputMediaDocument(media interface{}) InputMediaDocument
NewInputMediaDocument creates a new InputMediaDocument.
type InputMediaPhoto ¶
type InputMediaPhoto struct {
BaseInputMedia
}
InputMediaPhoto is a photo to send as part of a media group.
func NewInputMediaPhoto ¶
func NewInputMediaPhoto(media interface{}) InputMediaPhoto
NewInputMediaPhoto creates a new InputMediaPhoto.
type InputMediaVideo ¶
type InputMediaVideo struct { BaseInputMedia Thumb interface{} Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` Duration int `json:"duration,omitempty"` SupportsStreaming bool `json:"supports_streaming,omitempty"` }
InputMediaVideo is a video to send as part of a media group.
func NewInputMediaVideo ¶
func NewInputMediaVideo(media interface{}) InputMediaVideo
NewInputMediaVideo creates a new InputMediaVideo.
type InputTextMessageContent ¶
type InputTextMessageContent struct { Text string `json:"message_text"` ParseMode string `json:"parse_mode"` DisableWebPagePreview bool `json:"disable_web_page_preview"` }
InputTextMessageContent contains text for displaying as an inline query result.
type InputVenueMessageContent ¶
type InputVenueMessageContent struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` Title string `json:"title"` Address string `json:"address"` FoursquareID string `json:"foursquare_id"` }
InputVenueMessageContent contains a venue for displaying as an inline query result.
type Invoice ¶
type Invoice struct { Title string `json:"title"` Description string `json:"description"` StartParameter string `json:"start_parameter"` Currency string `json:"currency"` 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 ProviderData string PhotoURL string PhotoSize int PhotoWidth int PhotoHeight int NeedName bool NeedPhoneNumber bool NeedEmail bool NeedShippingAddress bool SendPhoneNumberToProvider bool SendEmailToProvider 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 string `json:"text"` RequestContact bool `json:"request_contact"` RequestLocation bool `json:"request_location"` RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"` }
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 KeyboardButtonPollType ¶
type KeyboardButtonPollType struct {
Type string `json:"type"`
}
KeyboardButtonPollType represents type of a poll, which is allowed to be created and sent when the corresponding button is pressed.
type KickChatMemberConfig ¶
type KickChatMemberConfig struct { ChatMemberConfig UntilDate int64 }
KickChatMemberConfig contains extra fields to kick user
type LabeledPrice ¶
LabeledPrice represents a portion of the price for goods or services.
type LeaveChatConfig ¶
LeaveChatConfig allows you to leave a chat.
type LocationConfig ¶
type LocationConfig struct { BaseChat Latitude float64 // required Longitude float64 // required LivePeriod int // optional }
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 LoginURL ¶
type LoginURL struct { URL string `json:"url"` ForwardText string `json:"forward_text"` BotUsername string `json:"bot_username"` RequestWriteAccess bool `json:"request_write_access"` }
LoginURL is the parameters for the login inline keyboard button type.
type MaskPosition ¶
type MaskPosition struct { Point string `json:"point"` XShift float32 `json:"x_shift"` YShift float32 `json:"y_shift"` Scale float32 `json:"scale"` FileID string `json:"file_id"` Width int `json:"width"` Height int `json:"height"` Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional Emoji string `json:"emoji,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional SetName string `json:"set_name,omitempty"` // optional }
MaskPosition is the position of a mask.
type MediaGroupConfig ¶
type MediaGroupConfig struct { ChatID int64 ChannelUsername string Media []interface{} DisableNotification bool ReplyToMessageID int }
MediaGroupConfig allows you to send a group of media.
Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
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 int `json:"message_id"` From *User `json:"from,omitempty"` // optional Date int `json:"date"` Chat *Chat `json:"chat"` ForwardFrom *User `json:"forward_from,omitempty"` // optional ForwardFromChat *Chat `json:"forward_from_chat,omitempty"` // optional ForwardFromMessageID int `json:"forward_from_message_id,omitempty"` // optional ForwardSignature string `json:"forward_signature,omitempty"` // optional ForwardSenderName string `json:"forward_sender_name,omitempty"` // optional ForwardDate int `json:"forward_date,omitempty"` // optional ReplyToMessage *Message `json:"reply_to_message,omitempty"` // optional ViaBot *User `json:"via_bot"` // optional EditDate int `json:"edit_date,omitempty"` // optional MediaGroupID string `json:"media_group_id,omitempty"` // optional AuthorSignature string `json:"author_signature,omitempty"` // optional Text string `json:"text,omitempty"` // optional Entities []MessageEntity `json:"entities,omitempty"` // optional CaptionEntities []MessageEntity `json:"caption_entities,omitempty"` // optional Audio *Audio `json:"audio,omitempty"` // optional Document *Document `json:"document,omitempty"` // optional Animation *ChatAnimation `json:"animation,omitempty"` // optional Game *Game `json:"game,omitempty"` // optional Photo []PhotoSize `json:"photo,omitempty"` // optional Sticker *Sticker `json:"sticker,omitempty"` // optional Video *Video `json:"video,omitempty"` // optional VideoNote *VideoNote `json:"video_note,omitempty"` // optional Voice *Voice `json:"voice,omitempty"` // optional Caption string `json:"caption,omitempty"` // optional Contact *Contact `json:"contact,omitempty"` // optional Location *Location `json:"location,omitempty"` // optional Venue *Venue `json:"venue,omitempty"` // optional Poll *Poll `json:"poll,omitempty"` // optional Dice *Dice `json:"dice,omitempty"` // optional NewChatMembers []User `json:"new_chat_members,omitempty"` // optional LeftChatMember *User `json:"left_chat_member,omitempty"` // optional NewChatTitle string `json:"new_chat_title,omitempty"` // optional NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"` // optional DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"` // optional GroupChatCreated bool `json:"group_chat_created,omitempty"` // optional SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"` // optional ChannelChatCreated bool `json:"channel_chat_created,omitempty"` // optional MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // optional MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"` // optional PinnedMessage *Message `json:"pinned_message,omitempty"` // optional Invoice *Invoice `json:"invoice,omitempty"` // optional SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"` // optional ConnectedWebsite string `json:"connected_website,omitempty"` // optional PassportData *PassportData `json:"passport_data,omitempty"` // optional ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` // optional }
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.
type MessageEntity ¶
type MessageEntity struct { Type string `json:"type"` Offset int `json:"offset"` Length int `json:"length"` URL string `json:"url,omitempty"` // optional User *User `json:"user,omitempty"` // optional Language string `json:"language,omitempty"` // optional }
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 NewStickerSetConfig ¶
type NewStickerSetConfig struct { UserID int64 Name string Title string PNGSticker interface{} TGSSticker interface{} Emojis string ContainsMasks bool MaskPosition *MaskPosition }
NewStickerSetConfig allows creating a new sticker set.
You must set either PNGSticker or TGSSticker.
type OrderInfo ¶
type OrderInfo struct { Name string `json:"name,omitempty"` PhoneNumber string `json:"phone_number,omitempty"` Email string `json:"email,omitempty"` 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"` FileUniqueID string `json:"file_unique_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 NewPhoto ¶
func NewPhoto(chatID int64, file interface{}) PhotoConfig
NewPhoto creates a new sendPhoto request.
Note that you must send animated GIFs as a document.
func NewPhotoToChannel ¶
func NewPhotoToChannel(username string, file interface{}) PhotoConfig
NewPhotoToChannel creates a new photo uploader to send a photo to a channel.
Note that you must send animated GIFs as a document.
type PhotoSize ¶
type PhotoSize struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Width int `json:"width"` Height int `json:"height"` FileSize int `json:"file_size,omitempty"` // optional }
PhotoSize contains information about photos.
type PinChatMessageConfig ¶
type PinChatMessageConfig struct { ChatID int64 ChannelUsername string MessageID int DisableNotification bool }
PinChatMessageConfig contains information of a message in a chat to pin.
type Poll ¶
type Poll struct { ID string `json:"id"` Question string `json:"question"` Options []PollOption `json:"options"` IsClosed bool `json:"is_closed"` IsAnonymous bool `json:"is_anonymous"` Type string `json:"type"` AllowsMultipleAnswers bool `json:"allows_multiple_answers"` CorrectOptionID int `json:"correct_option_id,omitempty"` // optional Explanation string `json:"explanation,omitempty"` // optional ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"` // optional OpenPeriod int `json:"open_period,omitempty"` // optional CloseDate int `json:"close_date,omitempty"` // optional }
Poll contains information about a poll.
type PollAnswer ¶
type PollAnswer struct { PollID string `json:"poll_id"` User User `json:"user"` OptionIDs []int `json:"option_ids"` }
PollAnswer represents an answer of a user in a non-anonymous poll.
type PollOption ¶
PollOption contains information about one answer option in a poll.
type PreCheckoutConfig ¶
type PreCheckoutConfig struct { PreCheckoutQueryID string // required OK bool // required ErrorMessage string }
PreCheckoutConfig conatins information for answerPreCheckoutQuery request.
type PreCheckoutQuery ¶
type PreCheckoutQuery struct { ID string `json:"id"` From *User `json:"from"` Currency string `json:"currency"` TotalAmount int `json:"total_amount"` InvoicePayload string `json:"invoice_payload"` ShippingOptionID string `json:"shipping_option_id,omitempty"` 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 RemoveWebhookConfig ¶
type RemoveWebhookConfig struct { }
RemoveWebhookConfig is a helper to remove a webhook.
type ReplyKeyboardHide ¶
type ReplyKeyboardHide struct { HideKeyboard bool `json:"hide_keyboard"` Selective bool `json:"selective,omitempty"` // 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 [][]KeyboardButton `json:"keyboard"` ResizeKeyboard bool `json:"resize_keyboard,omitempty"` // optional OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"` // optional Selective bool `json:"selective,omitempty"` // optional }
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 bool `json:"remove_keyboard"` 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 RequestFile ¶
type RequestFile struct { // The multipart upload field name. Name string // The file to upload. File interface{} }
RequestFile represents a file associated with a request. May involve uploading a file, or passing an existing ID.
type ResponseParameters ¶
type ResponseParameters struct { MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // optional RetryAfter int `json:"retry_after,omitempty"` // optional }
ResponseParameters are various errors that can be returned in APIResponse.
type RestrictChatMemberConfig ¶
type RestrictChatMemberConfig struct { ChatMemberConfig UntilDate int64 Permissions *ChatPermissions }
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 SetChatAdministratorCustomTitle ¶
type SetChatAdministratorCustomTitle struct { ChatMemberConfig CustomTitle string }
SetChatAdministratorCustomTitle sets the title of an administrative user promoted by the bot for a chat.
type SetChatDescriptionConfig ¶
SetChatDescriptionConfig allows you to set the description of a supergroup or channel.
func NewChatDescription ¶
func NewChatDescription(chatID int64, description string) SetChatDescriptionConfig
NewChatDescription allows you to update the description of a chat.
type SetChatPermissionsConfig ¶
type SetChatPermissionsConfig struct { ChatConfig Permissions *ChatPermissions }
SetChatPermissionsConfig allows you to set default permissions for the members in a group. The bot must be an administrator and have rights to restrict members.
type SetChatPhotoConfig ¶
type SetChatPhotoConfig struct {
BaseFile
}
SetChatPhotoConfig allows you to set a group, supergroup, or channel's photo.
func NewChatPhoto ¶
func NewChatPhoto(chatID int64, photo interface{}) SetChatPhotoConfig
NewChatPhoto allows you to update the photo for a chat.
type SetChatStickerSetConfig ¶
type SetChatStickerSetConfig struct { ChatID int64 SuperGroupUsername string StickerSetName string }
SetChatStickerSetConfig allows you to set the sticker set for a supergroup.
type SetChatTitleConfig ¶
SetChatTitleConfig allows you to set the title of something other than a private chat.
func NewChatTitle ¶
func NewChatTitle(chatID int64, title string) SetChatTitleConfig
NewChatTitle allows you to update the title of a chat.
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 SetMyCommandsConfig ¶
type SetMyCommandsConfig struct {
// contains filtered or unexported fields
}
SetMyCommandsConfig sets a list of commands the bot understands.
func NewSetMyCommands ¶
func NewSetMyCommands(commands ...BotCommand) SetMyCommandsConfig
NewSetMyCommands allows you to set the registered commands.
type SetStickerPositionConfig ¶
SetStickerPositionConfig allows you to change the position of a sticker in a set.
type SetStickerSetThumbConfig ¶
SetStickerSetThumbConfig allows you to set the thumbnail for a sticker set.
type ShippingAddress ¶
type ShippingAddress struct { CountryCode string `json:"country_code"` State string `json:"state"` City string `json:"city"` StreetLine1 string `json:"street_line1"` StreetLine2 string `json:"street_line2"` PostCode string `json:"post_code"` }
ShippingAddress represents a shipping address.
type 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 string `json:"id"` Title string `json:"title"` Prices []LabeledPrice `json:"prices"` }
ShippingOption represents one shipping option.
type ShippingQuery ¶
type ShippingQuery struct { ID string `json:"id"` From *User `json:"from"` InvoicePayload string `json:"invoice_payload"` ShippingAddress *ShippingAddress `json:"shipping_address"` }
ShippingQuery contains information about an incoming shipping query.
type Sticker ¶
type Sticker struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Width int `json:"width"` Height int `json:"height"` IsAnimated bool `json:"is_animated"` Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional Emoji string `json:"emoji,omitempty"` // optional SetName string `json:"set_name,omitempty"` // optional MaskPosition MaskPosition `json:"mask_position,omitempty"` //optional FileSize int `json:"file_size,omitempty"` // optional }
Sticker contains information about a sticker.
type StickerConfig ¶
type StickerConfig struct {
BaseFile
}
StickerConfig contains information about a SendSticker request.
func NewSticker ¶
func NewSticker(chatID int64, file interface{}) StickerConfig
NewSticker creates a new sendSticker request.
type StickerSet ¶
type StickerSet struct { Name string `json:"name"` Title string `json:"title"` IsAnimated bool `json:"is_animated"` ContainsMasks bool `json:"contains_masks"` Stickers []Sticker `json:"stickers"` Thumb *PhotoSize `json:"thumb"` }
StickerSet is a collection of stickers.
type StopMessageLiveLocationConfig ¶
type StopMessageLiveLocationConfig struct {
BaseEdit
}
StopMessageLiveLocationConfig stops updating a live location.
type StopPollConfig ¶
type StopPollConfig struct {
BaseEdit
}
StopPollConfig allows you to stop a poll sent by the bot.
func NewStopPoll ¶
func NewStopPoll(chatID int64, messageID int) StopPollConfig
NewStopPoll allows you to stop a poll.
type SuccessfulPayment ¶
type SuccessfulPayment struct { Currency string `json:"currency"` TotalAmount int `json:"total_amount"` InvoicePayload string `json:"invoice_payload"` ShippingOptionID string `json:"shipping_option_id,omitempty"` OrderInfo *OrderInfo `json:"order_info,omitempty"` TelegramPaymentChargeID string `json:"telegram_payment_charge_id"` ProviderPaymentChargeID string `json:"provider_payment_charge_id"` }
SuccessfulPayment contains basic information about a successful payment.
type UnbanChatMemberConfig ¶
type UnbanChatMemberConfig struct {
ChatMemberConfig
}
UnbanChatMemberConfig allows you to unban a user.
type UnpinChatMessageConfig ¶
UnpinChatMessageConfig contains information of chat to unpin.
type Update ¶
type Update struct { UpdateID int `json:"update_id"` Message *Message `json:"message,omitempty"` EditedMessage *Message `json:"edited_message,omitempty"` ChannelPost *Message `json:"channel_post,omitempty"` EditedChannelPost *Message `json:"edited_channel_post,omitempty"` InlineQuery *InlineQuery `json:"inline_query,omitempty"` ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"` CallbackQuery *CallbackQuery `json:"callback_query,omitempty"` ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"` PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"` Poll *Poll `json:"poll,omitempty"` PollAnswer *PollAnswer `json:"poll_answer,omitempty"` }
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 UploadStickerConfig ¶
type UploadStickerConfig struct { UserID int64 PNGSticker interface{} }
UploadStickerConfig allows you to upload a sticker for use in a set later.
type User ¶
type User struct { ID int `json:"id"` FirstName string `json:"first_name"` LastName string `json:"last_name,omitempty"` // optional UserName string `json:"username,omitempty"` // optional LanguageCode string `json:"language_code,omitempty"` // optional IsBot bool `json:"is_bot,omitempty"` // optional CanJoinGroups bool `json:"can_join_groups,omitempty"` // optional CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"` // optional SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"` // optional }
User is a user on Telegram.
type UserProfilePhotos ¶
type UserProfilePhotos struct { TotalCount int `json:"total_count"` 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 Location `json:"location"` Title string `json:"title"` Address string `json:"address"` FoursquareID string `json:"foursquare_id,omitempty"` // optional }
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 string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Width int `json:"width"` Height int `json:"height"` Duration int `json:"duration"` Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional MimeType string `json:"mime_type,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional }
Video contains information about a video.
type VideoConfig ¶
type VideoConfig struct { BaseFile Thumb interface{} Duration int Caption string ParseMode string SupportsStreaming bool }
VideoConfig contains information about a SendVideo request.
func NewVideo ¶
func NewVideo(chatID int64, file interface{}) VideoConfig
NewVideo creates a new sendVideo request.
type VideoNote ¶
type VideoNote struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Length int `json:"length"` Duration int `json:"duration"` Thumbnail *PhotoSize `json:"thumb,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional }
VideoNote contains information about a video.
type VideoNoteConfig ¶
VideoNoteConfig contains information about a SendVideoNote request.
func NewVideoNote ¶
func NewVideoNote(chatID int64, length int, file interface{}) VideoNoteConfig
NewVideoNote creates a new sendVideoNote request.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
type Voice ¶
type Voice struct { FileID string `json:"file_id"` FileUniqueID string `json:"file_unique_id"` Duration int `json:"duration"` MimeType string `json:"mime_type,omitempty"` // optional FileSize int `json:"file_size,omitempty"` // optional }
Voice contains information about a voice.
type VoiceConfig ¶
VoiceConfig contains information about a SendVoice request.
func NewVoice ¶
func NewVoice(chatID int64, file interface{}) VoiceConfig
NewVoice creates a new sendVoice request.
type WebhookConfig ¶
type WebhookConfig struct { URL *url.URL Certificate interface{} MaxConnections int AllowedUpdates []string }
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 ¶
bot, err := NewBotAPI("MyAwesomeBotToken") if err != nil { panic(err) } bot.Debug = true log.Printf("Authorized on account %s", bot.Self.UserName) _, err = bot.Request(NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, "cert.pem")) if err != nil { panic(err) } info, err := bot.GetWebhookInfo() if err != nil { panic(err) } if info.LastErrorDate != 0 { log.Printf("failed to set webhook: %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 string `json:"url"` HasCustomCertificate bool `json:"has_custom_certificate"` PendingUpdateCount int `json:"pending_update_count"` LastErrorDate int `json:"last_error_date"` // optional LastErrorMessage string `json:"last_error_message"` // optional MaxConnections int `json:"max_connections"` // optional }
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.