tgbotapi package - github.com/go-telegram-bot-api/telegram-bot-api/v5 - Go Packages
Package tgbotapi has functions and types used for interacting with the Telegram Bot API.
- Constants
- func EscapeText(parseMode string, text string) string
- func SetLogger(logger BotLogger) error
- func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error
- type APIResponse
- type AddStickerConfig
- type Animation
- type AnimationConfig
- type ApproveChatJoinRequestConfig
- type Audio
- type AudioConfig
- type BanChatMemberConfig
- type BanChatSenderChatConfig
- type BaseChat
- type BaseEdit
- type BaseFile
- type BaseInputMedia
- type BotAPI
- func (bot *BotAPI) CopyMessage(config CopyMessageConfig) (MessageID, error)
- 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) GetMyCommandsWithConfig(config GetMyCommandsConfig) ([]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(r *http.Request) (*Update, error)
- func (bot *BotAPI) IsMessageToMe(message Message) bool
- func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel
- func (bot *BotAPI) ListenForWebhookRespReqFormat(w http.ResponseWriter, r *http.Request) 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 BotCommandScope
- func NewBotCommandScopeAllChatAdministrators() BotCommandScope
- func NewBotCommandScopeAllGroupChats() BotCommandScope
- func NewBotCommandScopeAllPrivateChats() BotCommandScope
- func NewBotCommandScopeChat(chatID int64) BotCommandScope
- func NewBotCommandScopeChatAdministrators(chatID int64) BotCommandScope
- func NewBotCommandScopeChatMember(chatID, userID int64) BotCommandScope
- func NewBotCommandScopeDefault() BotCommandScope
- type BotLogger
- type CallbackConfig
- type CallbackGame
- type CallbackQuery
- type Chat
- type ChatActionConfig
- type ChatAdministratorsConfig
- type ChatConfig
- type ChatConfigWithUser
- type ChatInfoConfig
- type ChatInviteLink
- type ChatInviteLinkConfig
- type ChatJoinRequest
- type ChatLocation
- type ChatMember
- type ChatMemberConfig
- type ChatMemberCountConfig
- type ChatMemberUpdated
- type ChatPermissions
- type ChatPhoto
- type Chattable
- type ChosenInlineResult
- type CloseConfig
- type Contact
- type ContactConfig
- type CopyMessageConfig
- type CreateChatInviteLinkConfig
- type Credentials
- type DataCredentials
- type DeclineChatJoinRequest
- type DeleteChatPhotoConfig
- type DeleteChatStickerSetConfig
- type DeleteMessageConfig
- type DeleteMyCommandsConfig
- type DeleteStickerConfig
- type DeleteWebhookConfig
- type Dice
- type DiceConfig
- type Document
- type DocumentConfig
- type EditChatInviteLinkConfig
- 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 FilePath
- 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 HTTPClient
- type IDDocumentData
- type InlineConfig
- type InlineKeyboardButton
- func NewInlineKeyboardButtonData(text, data string) InlineKeyboardButton
- func NewInlineKeyboardButtonLoginURL(text string, loginURL LoginURL) InlineKeyboardButton
- func NewInlineKeyboardButtonSwitch(text, sw string) InlineKeyboardButton
- func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton
- func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []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 InputInvoiceMessageContent
- 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 LogOutConfig
- type LoginURL
- type MaskPosition
- type MediaGroupConfig
- type Message
- type MessageAutoDeleteTimerChanged
- 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 MessageID
- 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 ProximityAlertTriggered
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type RequestFile
- type RequestFileData
- type ResponseParameters
- type RestrictChatMemberConfig
- type RevokeChatInviteLinkConfig
- 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 UnbanChatSenderChatConfig
- type UnpinAllChatMessagesConfig
- 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 VoiceChatEnded
- type VoiceChatParticipantsInvited
- type VoiceChatScheduled
- type VoiceChatStarted
- type VoiceConfig
- type WebhookConfig
- type WebhookInfo
const ( APIEndpoint = "https://api.telegram.org/bot%s/%s" FileEndpoint = "https://api.telegram.org/file/bot%s/%s" )
Telegram constants
const ( ChatTyping = "typing" ChatUploadPhoto = "upload_photo" ChatRecordVideo = "record_video" ChatUploadVideo = "upload_video" ChatRecordVoice = "record_voice" ChatUploadVoice = "upload_voice" ChatUploadDocument = "upload_document" ChatChooseSticker = "choose_sticker" 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 ( UpdateTypeMessage = "message" UpdateTypeEditedMessage = "edited_message" UpdateTypeChannelPost = "channel_post" UpdateTypeEditedChannelPost = "edited_channel_post" UpdateTypeInlineQuery = "inline_query" UpdateTypeChosenInlineResult = "chosen_inline_result" UpdateTypeCallbackQuery = "callback_query" UpdateTypeShippingQuery = "shipping_query" UpdateTypePreCheckoutQuery = "pre_checkout_query" UpdateTypePoll = "poll" UpdateTypePollAnswer = "poll_answer" UpdateTypeMyChatMember = "my_chat_member" UpdateTypeChatMember = "chat_member" )
Constant values for update types
API errors
Library errors
This section is empty.
EscapeText takes an input text and escape Telegram markup symbols. In this way we can send a text without being afraid of having to escape the characters manually. Note that you don't have to include the formatting style in the input text, or it will be escaped too. If there is an error, an empty string will be returned.
parseMode is the text formatting mode (ModeMarkdown, ModeMarkdownV2 or ModeHTML) text is the input string that will be escaped
SetLogger specifies the logger that the package should use.
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 struct {
UserID int64
Name string
PNGSticker RequestFileData
TGSSticker RequestFileData
Emojis string
MaskPosition *MaskPosition
}
AddStickerConfig allows you to add a sticker to a set.
type Animation 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"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
Animation represents an animation file.
type AnimationConfig struct {
BaseFile
Duration int
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
}
AnimationConfig contains information about a SendAnimation request.
NewAnimation creates a new sendAnimation request.
type ApproveChatJoinRequestConfig struct {
ChatConfig
UserID int64
}
ApproveChatJoinRequestConfig allows you to approve a chat join request.
type Audio struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Duration int `json:"duration"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
Thumbnail *PhotoSize `json:"thumb,omitempty"`
}
Audio represents an audio file to be treated as music by the Telegram clients.
AudioConfig contains information about a SendAudio request.
NewAudio creates a new sendAudio request.
type BanChatMemberConfig struct {
ChatMemberConfig
UntilDate int64
RevokeMessages bool
}
BanChatMemberConfig contains extra fields to kick user.
type BanChatSenderChatConfig struct {
ChatID int64
ChannelUsername string
SenderChatID int64
UntilDate int
}
BanChatSenderChatConfig bans a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
type BaseChat struct {
ChatID int64
ChannelUsername string
ReplyToMessageID int
ReplyMarkup interface{}
DisableNotification bool
AllowSendingWithoutReply bool
}
BaseChat is base type for all chat config types.
type BaseEdit struct {
ChatID int64
ChannelUsername string
MessageID int
InlineMessageID string
ReplyMarkup *InlineKeyboardMarkup
}
BaseEdit is base type of all chat edits.
type BaseFile struct {
BaseChat
File RequestFileData
}
BaseFile is a base type for all file config types.
type BaseInputMedia struct {
Type string `json:"type"`
Media RequestFileData `json:"media"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities"`
}
BaseInputMedia is a base type for the InputMedia types.
type BotAPI struct {
Token string `json:"token"`
Debug bool `json:"debug"`
Buffer int `json:"buffer"`
Self User `json:"-"`
Client HTTPClient `json:"-"`
}
BotAPI allows you to interact with the Telegram Bot API.
NewBotAPI creates a new BotAPI instance.
It requires a token, provided by @BotFather on Telegram.
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)
}
NewBotAPIWithAPIEndpoint creates a new BotAPI instance and allows you to pass API endpoint.
It requires a token, provided by @BotFather on Telegram and API endpoint.
func NewBotAPIWithClient(token, apiEndpoint string, client HTTPClient) (*BotAPI, error)
NewBotAPIWithClient creates a new BotAPI instance and allows you to pass a http.Client.
It requires a token, provided by @BotFather on Telegram and API endpoint.
func (bot *BotAPI) CopyMessage(config CopyMessageConfig) (MessageID, error)
CopyMessage copy messages of any kind. The method is analogous to the method forwardMessage, but the copied message doesn't have a link to the original message. Returns the MessageID of the sent message on success.
func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error)
GetChat gets information about a chat.
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 (bot *BotAPI) GetChatMember(config GetChatMemberConfig) (ChatMember, error)
GetChatMember gets a specific chat member.
func (bot *BotAPI) GetChatMembersCount(config ChatMemberCountConfig) (int, error)
GetChatMembersCount gets the number of users in a chat.
func (bot *BotAPI) GetFile(config FileConfig) (File, error)
GetFile returns a File which can download a file from Telegram.
Requires FileID.
GetFileDirectURL returns direct URL to file
It requires the FileID.
func (bot *BotAPI) GetGameHighScores(config GetGameHighScoresConfig) ([]GameHighScore, error)
GetGameHighScores allows you to get the high scores for a game.
GetInviteLink get InviteLink for a chat
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) GetMyCommandsWithConfig ¶
func (bot *BotAPI) GetMyCommandsWithConfig(config GetMyCommandsConfig) ([]BotCommand, error)
GetMyCommandsWithConfig gets the currently registered commands with a config.
func (bot *BotAPI) GetStickerSet(config GetStickerSetConfig) (StickerSet, error)
GetStickerSet returns a StickerSet.
func (bot *BotAPI) GetUpdates(config UpdateConfig) ([]Update, error)
GetUpdates fetches updates. If a WebHook is set, this will not return any data!
Offset, Limit, Timeout, and AllowedUpdates 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 (bot *BotAPI) GetUpdatesChan(config UpdateConfig) UpdatesChannel
GetUpdatesChan starts and returns a channel for getting updates.
func (bot *BotAPI) GetUserProfilePhotos(config UserProfilePhotosConfig) (UserProfilePhotos, error)
GetUserProfilePhotos gets a user's profile photos.
It requires UserID. Offset and Limit are optional.
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
IsMessageToMe returns true if message directed to this bot.
It requires the Message.
func (bot *BotAPI) ListenForWebhook(pattern string) UpdatesChannel
ListenForWebhook registers a http handler for a webhook.
ListenForWebhookRespReqFormat registers a http handler for a single incoming webhook.
MakeRequest makes a request to a specific endpoint with our token.
Request sends a Chattable to Telegram, and returns the APIResponse.
Send will send a Chattable item to Telegram and provides the returned Message.
func (bot *BotAPI) SendMediaGroup(config MediaGroupConfig) ([]Message, error)
SendMediaGroup sends a media group and returns the resulting messages.
SetAPIEndpoint changes the Telegram Bot API endpoint used by the instance.
func (bot *BotAPI) StopPoll(config StopPollConfig) (Poll, error)
StopPoll stops a poll and returns the result.
func (bot *BotAPI) StopReceivingUpdates()
StopReceivingUpdates stops the go routine which receives updates
UploadFiles makes a request to the API with files.
type BotCommand ¶
BotCommand represents a bot command.
type BotCommandScope ¶
type BotCommandScope struct {
Type string `json:"type"`
ChatID int64 `json:"chat_id,omitempty"`
UserID int64 `json:"user_id,omitempty"`
}
BotCommandScope represents the scope to which bot commands are applied.
It contains the fields for all types of scopes, different types only support specific (or no) fields.
func NewBotCommandScopeAllChatAdministrators ¶
func NewBotCommandScopeAllChatAdministrators() BotCommandScope
NewBotCommandScopeAllChatAdministrators represents the scope of bot commands, covering all group and supergroup chat administrators.
func NewBotCommandScopeAllGroupChats ¶
func NewBotCommandScopeAllGroupChats() BotCommandScope
NewBotCommandScopeAllGroupChats represents the scope of bot commands, covering all group and supergroup chats.
func NewBotCommandScopeAllPrivateChats ¶
func NewBotCommandScopeAllPrivateChats() BotCommandScope
NewBotCommandScopeAllPrivateChats represents the scope of bot commands, covering all private chats.
func NewBotCommandScopeChat ¶
func NewBotCommandScopeChat(chatID int64) BotCommandScope
NewBotCommandScopeChat represents the scope of bot commands, covering a specific chat.
func NewBotCommandScopeChatAdministrators ¶
func NewBotCommandScopeChatAdministrators(chatID int64) BotCommandScope
NewBotCommandScopeChatAdministrators represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
func NewBotCommandScopeChatMember ¶
func NewBotCommandScopeChatMember(chatID, userID int64) BotCommandScope
NewBotCommandScopeChatMember represents the scope of bot commands, covering a specific member of a group or supergroup chat.
func NewBotCommandScopeDefault ¶
func NewBotCommandScopeDefault() BotCommandScope
NewBotCommandScopeDefault represents the default scope of bot commands.
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 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.
NewCallback creates a new callback message.
func NewCallbackWithAlert(id, text string) CallbackConfig
NewCallbackWithAlert creates a new callback message that alerts the user.
type CallbackGame struct{}
CallbackGame is for starting a game in an inline keyboard button.
type CallbackQuery struct {
ID string `json:"id"`
From *User `json:"from"`
Message *Message `json:"message,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
ChatInstance string `json:"chat_instance"`
Data string `json:"data,omitempty"`
GameShortName string `json:"game_short_name,omitempty"`
}
CallbackQuery represents an incoming callback query from a callback button in an inline keyboard. If the button that originated the query was attached to a message sent by the bot, the field message will be present. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be present. Exactly one of the fields data or game_short_name will be present.
type Chat struct {
ID int64 `json:"id"`
Type string `json:"type"`
Title string `json:"title,omitempty"`
UserName string `json:"username,omitempty"`
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
Photo *ChatPhoto `json:"photo"`
Bio string `json:"bio,omitempty"`
HasPrivateForwards bool `json:"has_private_forwards,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Permissions *ChatPermissions `json:"permissions,omitempty"`
SlowModeDelay int `json:"slow_mode_delay,omitempty"`
MessageAutoDeleteTime int `json:"message_auto_delete_time,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
StickerSetName string `json:"sticker_set_name,omitempty"`
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
LinkedChatID int64 `json:"linked_chat_id,omitempty"`
Location *ChatLocation `json:"location"`
}
Chat represents a chat.
func (c Chat) ChatConfig() ChatConfig
ChatConfig returns a ChatConfig struct for chat related methods.
ChatActionConfig contains information about a SendChatAction request.
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 struct {
ChatConfig
}
ChatAdministratorsConfig contains information about getting chat administrators.
ChatConfig contains information about getting information on a chat.
ChatConfigWithUser contains information about a chat and a user.
type ChatInfoConfig struct {
ChatConfig
}
ChatInfoConfig contains information about getting chat information.
type ChatInviteLink struct {
InviteLink string `json:"invite_link"`
Creator User `json:"creator"`
CreatesJoinRequest bool `json:"creates_join_request"`
IsPrimary bool `json:"is_primary"`
IsRevoked bool `json:"is_revoked"`
Name string `json:"name"`
ExpireDate int `json:"expire_date"`
MemberLimit int `json:"member_limit"`
PendingJoinRequestCount int `json:"pending_join_request_count"`
}
ChatInviteLink represents an invite link for a chat.
type ChatInviteLinkConfig struct {
ChatConfig
}
ChatInviteLinkConfig contains information about getting a chat link.
Note that generating a new link will revoke any previous links.
type ChatJoinRequest struct {
Chat Chat `json:"chat"`
From User `json:"from"`
Date int `json:"date"`
Bio string `json:"bio"`
InviteLink *ChatInviteLink `json:"invite_link"`
}
ChatJoinRequest represents a join request sent to a chat.
ChatLocation represents a location to which a chat is connected.
type ChatMember struct {
User *User `json:"user"`
Status string `json:"status"`
CustomTitle string `json:"custom_title,omitempty"`
IsAnonymous bool `json:"is_anonymous"`
UntilDate int64 `json:"until_date,omitempty"`
CanBeEdited bool `json:"can_be_edited,omitempty"`
CanManageChat bool `json:"can_manage_chat"`
CanPostMessages bool `json:"can_post_messages,omitempty"`
CanEditMessages bool `json:"can_edit_messages,omitempty"`
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
CanManageVoiceChats bool `json:"can_manage_voice_chats"`
CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
CanPromoteMembers bool `json:"can_promote_members,omitempty"`
CanChangeInfo bool `json:"can_change_info,omitempty"`
CanInviteUsers bool `json:"can_invite_users,omitempty"`
CanPinMessages bool `json:"can_pin_messages,omitempty"`
IsMember bool `json:"is_member"`
CanSendMessages bool `json:"can_send_messages,omitempty"`
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
CanSendPolls bool `json:"can_send_polls,omitempty"`
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
}
ChatMember contains information about one member of a chat.
func (chat ChatMember) HasLeft() bool
HasLeft returns if the ChatMember left the chat.
func (chat ChatMember) IsAdministrator() bool
IsAdministrator returns if the ChatMember is a chat administrator.
func (chat ChatMember) IsCreator() bool
IsCreator returns if the ChatMember was the creator of the chat.
func (chat ChatMember) WasKicked() bool
WasKicked returns if the ChatMember was kicked from the chat.
ChatMemberConfig contains information about a user in a chat for use with administrative functions such as kicking or unbanning a user.
type ChatMemberCountConfig struct {
ChatConfig
}
ChatMemberCountConfig contains information about getting the number of users in a chat.
type ChatMemberUpdated struct {
Chat Chat `json:"chat"`
From User `json:"from"`
Date int `json:"date"`
OldChatMember ChatMember `json:"old_chat_member"`
NewChatMember ChatMember `json:"new_chat_member"`
InviteLink *ChatInviteLink `json:"invite_link"`
}
ChatMemberUpdated represents changes in the status of a chat member.
type ChatPermissions struct {
CanSendMessages bool `json:"can_send_messages,omitempty"`
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
CanSendPolls bool `json:"can_send_polls,omitempty"`
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
CanChangeInfo bool `json:"can_change_info,omitempty"`
CanInviteUsers bool `json:"can_invite_users,omitempty"`
CanPinMessages bool `json:"can_pin_messages,omitempty"`
}
ChatPermissions describes actions that a non-administrator user is allowed to take in a chat. All fields are optional.
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 interface {
}
Chattable is any config type that can be sent.
type ChosenInlineResult struct {
ResultID string `json:"result_id"`
From *User `json:"from"`
Location *Location `json:"location,omitempty"`
InlineMessageID string `json:"inline_message_id,omitempty"`
Query string `json:"query"`
}
ChosenInlineResult is an inline query result chosen by a User
type CloseConfig struct{}
CloseConfig is a request to close the bot instance on a local server.
Note that you may not close an instance for the first 10 minutes after the bot has started.
type Contact struct {
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
UserID int64 `json:"user_id,omitempty"`
VCard string `json:"vcard,omitempty"`
}
Contact represents a phone contact.
Note that LastName and UserID may be empty.
ContactConfig allows you to send a contact.
NewContact allows you to send a shared contact.
type CopyMessageConfig struct {
BaseChat
FromChatID int64
FromChannelUsername string
MessageID int
Caption string
ParseMode string
CaptionEntities []MessageEntity
}
CopyMessageConfig contains information about a copyMessage request.
NewCopyMessage creates a new copy message.
chatID is where to send it, fromChatID is the source chat, and messageID is the ID of the original message.
type CreateChatInviteLinkConfig struct {
ChatConfig
Name string
ExpireDate int
MemberLimit int
CreatesJoinRequest bool
}
CreateChatInviteLinkConfig allows you to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The link can be revoked using the RevokeChatInviteLinkConfig.
type Credentials struct {
Data SecureData `json:"secure_data"`
Nonce string `json:"nonce"`
}
Credentials contains encrypted data.
DataCredentials contains information required to decrypt data.
type DeclineChatJoinRequest struct {
ChatConfig
UserID int64
}
DeclineChatJoinRequest allows you to decline a chat join request.
DeleteChatPhotoConfig allows you to delete a group, supergroup, or channel's photo.
func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig
NewDeleteChatPhoto allows you to delete the photo for a chat.
DeleteChatStickerSetConfig allows you to remove a supergroup's sticker set.
DeleteMessageConfig contains information of a message in a chat to delete.
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig
NewDeleteMessage creates a request to delete a message.
type DeleteStickerConfig struct {
Sticker string
}
DeleteStickerConfig allows you to delete a sticker from a set.
type DeleteWebhookConfig struct {
DropPendingUpdates bool
}
DeleteWebhookConfig is a helper to delete a webhook.
Dice represents an animated emoji that displays a random value.
DiceConfig contains information about a sendDice request.
NewDice allows you to send a random dice roll.
NewDiceWithEmoji allows you to send a random roll of one of many types.
Emoji may be 🎲 (1-6), 🎯 (1-6), or 🏀 (1-5).
type Document struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Thumbnail *PhotoSize `json:"thumb,omitempty"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
Document represents a general file.
type DocumentConfig struct {
BaseFile
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
DisableContentTypeDetection bool
}
DocumentConfig contains information about a SendDocument request.
NewDocument creates a new sendDocument request.
type EditChatInviteLinkConfig struct {
ChatConfig
InviteLink string
Name string
ExpireDate int
MemberLimit int
CreatesJoinRequest bool
}
EditChatInviteLinkConfig allows you to edit a non-primary invite link created by the bot. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
type EditMessageCaptionConfig struct {
BaseEdit
Caption string
ParseMode string
CaptionEntities []MessageEntity
}
EditMessageCaptionConfig allows you to modify the caption of a message.
NewEditMessageCaption allows you to edit the caption of a message.
type EditMessageLiveLocationConfig struct {
BaseEdit
Latitude float64
Longitude float64
HorizontalAccuracy float64
Heading int
ProximityAlertRadius int
}
EditMessageLiveLocationConfig allows you to update a live location.
type EditMessageMediaConfig struct {
BaseEdit
Media interface{}
}
EditMessageMediaConfig allows you to make an editMessageMedia request.
type EditMessageReplyMarkupConfig struct {
BaseEdit
}
EditMessageReplyMarkupConfig allows you to modify the reply markup of a message.
func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKeyboardMarkup) EditMessageReplyMarkupConfig
NewEditMessageReplyMarkup allows you to edit the inline keyboard markup.
type EditMessageTextConfig struct {
BaseEdit
Text string
ParseMode string
Entities []MessageEntity
DisableWebPagePreview bool
}
EditMessageTextConfig allows you to modify the text in a message.
NewEditMessageText allows you to edit the text of a message.
type EncryptedCredentials struct {
Data string `json:"data"`
Hash string `json:"hash"`
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 struct {
Type string `json:"type"`
Data string `json:"data,omitempty"`
PhoneNumber string `json:"phone_number,omitempty"`
Email string `json:"email,omitempty"`
Files []PassportFile `json:"files,omitempty"`
FrontSide *PassportFile `json:"front_side,omitempty"`
ReverseSide *PassportFile `json:"reverse_side,omitempty"`
Selfie *PassportFile `json:"selfie,omitempty"`
}
EncryptedPassportElement contains information about documents or other Telegram Passport elements shared with the bot by the user.
Error is an error containing extra information returned by the Telegram API.
type File struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
FileSize int `json:"file_size,omitempty"`
FilePath string `json:"file_path,omitempty"`
}
File contains information about a file to download from Telegram.
Link returns a full path to the download URL for a File.
It requires the Bot token to create the link.
FileBytes contains information about a set of bytes to upload as a File.
type FileConfig struct {
FileID string
}
FileConfig has information about a file hosted on Telegram.
FileCredentials contains information required to decrypt files.
FileReader contains information about a reader to upload as a File.
func (fr FileReader) NeedsUpload() bool
type Fileable interface {
Chattable
}
Fileable is any config type that can be sent that includes a file.
type ForceReply struct {
ForceReply bool `json:"force_reply"`
InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
Selective bool `json:"selective,omitempty"`
}
ForceReply when receiving a message with this object, Telegram clients will display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply'). This can be extremely useful if you want to create user-friendly step-by-step interfaces without having to sacrifice privacy mode.
ForwardConfig contains information about a ForwardMessage request.
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 struct {
Title string `json:"title"`
Description string `json:"description"`
Photo []PhotoSize `json:"photo"`
Text string `json:"text,omitempty"`
TextEntities []MessageEntity `json:"text_entities,omitempty"`
Animation Animation `json:"animation,omitempty"`
}
Game represents a game. Use BotFather to create and edit games, their short names will act as unique identifiers.
type 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 struct {
ChatConfigWithUser
}
GetChatMemberConfig is information about getting a specific member in a chat.
type GetGameHighScoresConfig struct {
UserID int64
ChatID int64
ChannelUsername string
MessageID int
InlineMessageID string
}
GetGameHighScoresConfig allows you to fetch the high scores for a game.
type GetMyCommandsConfig ¶
type GetMyCommandsConfig struct {
Scope *BotCommandScope
LanguageCode string
}
GetMyCommandsConfig gets a list of the currently registered commands.
func NewGetMyCommandsWithScope ¶
func NewGetMyCommandsWithScope(scope BotCommandScope) GetMyCommandsConfig
NewGetMyCommandsWithScope allows you to set the registered commands for a given scope.
func NewGetMyCommandsWithScopeAndLanguage ¶
func NewGetMyCommandsWithScopeAndLanguage(scope BotCommandScope, languageCode string) GetMyCommandsConfig
NewGetMyCommandsWithScopeAndLanguage allows you to set the registered commands for a given scope and language code.
type GetStickerSetConfig struct {
Name string
}
GetStickerSetConfig allows you to get the stickers in a set.
HTTPClient is the type needed for the bot to perform HTTP requests.
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.
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)
}
}
type InlineKeyboardButton struct {
Text string `json:"text"`
URL *string `json:"url,omitempty"`
LoginURL *LoginURL `json:"login_url,omitempty"`
CallbackData *string `json:"callback_data,omitempty"`
SwitchInlineQuery *string `json:"switch_inline_query,omitempty"`
SwitchInlineQueryCurrentChat *string `json:"switch_inline_query_current_chat,omitempty"`
CallbackGame *CallbackGame `json:"callback_game,omitempty"`
Pay bool `json:"pay,omitempty"`
}
InlineKeyboardButton represents one button of an inline keyboard. You must use exactly one of the optional fields.
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(text, data string) InlineKeyboardButton
NewInlineKeyboardButtonData creates an inline keyboard button with text and data for a callback.
func NewInlineKeyboardButtonLoginURL(text string, loginURL LoginURL) InlineKeyboardButton
NewInlineKeyboardButtonLoginURL creates an inline keyboard button with text which goes to a LoginURL.
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(text, url string) InlineKeyboardButton
NewInlineKeyboardButtonURL creates an inline keyboard button with text which goes to a URL.
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton
NewInlineKeyboardRow creates an inline keyboard row with buttons.
type InlineKeyboardMarkup struct {
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
InlineKeyboardMarkup represents an inline keyboard that appears right next to the message it belongs to.
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) InlineKeyboardMarkup
NewInlineKeyboardMarkup creates a new inline keyboard.
type InlineQuery struct {
ID string `json:"id"`
From *User `json:"from"`
Query string `json:"query"`
Offset string `json:"offset"`
ChatType string `json:"chat_type"`
Location *Location `json:"location,omitempty"`
}
InlineQuery is a Query from Telegram for an inline request.
type InlineQueryResultArticle ¶
type InlineQueryResultArticle struct {
Type string `json:"type"`
ID string `json:"id"`
Title string `json:"title"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
URL string `json:"url,omitempty"`
HideURL bool `json:"hide_url,omitempty"`
Description string `json:"description,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
ThumbWidth int `json:"thumb_width,omitempty"`
ThumbHeight int `json:"thumb_height,omitempty"`
}
InlineQueryResultArticle represents a link to an article or web page.
type InlineQueryResultAudio struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"audio_url"`
Title string `json:"title"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Performer string `json:"performer,omitempty"`
Duration int `json:"audio_duration,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultAudio is an inline query response audio.
func NewInlineQueryResultAudio(id, url, title string) InlineQueryResultAudio
NewInlineQueryResultAudio creates a new inline query audio.
type InlineQueryResultCachedAudio struct {
Type string `json:"type"`
ID string `json:"id"`
AudioID string `json:"audio_file_id"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedAudio is an inline query response with cached audio.
func NewInlineQueryResultCachedAudio(id, audioID string) InlineQueryResultCachedAudio
NewInlineQueryResultCachedAudio create a new inline query with cached photo.
type InlineQueryResultCachedDocument struct {
Type string `json:"type"`
ID string `json:"id"`
DocumentID string `json:"document_file_id"`
Title string `json:"title,omitempty"`
Caption string `json:"caption,omitempty"`
Description string `json:"description,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedDocument is an inline query response with cached document.
func NewInlineQueryResultCachedDocument(id, documentID, title string) InlineQueryResultCachedDocument
NewInlineQueryResultCachedDocument create a new inline query with cached photo.
type InlineQueryResultCachedGIF struct {
Type string `json:"type"`
ID string `json:"id"`
GIFID string `json:"gif_file_id"`
Title string `json:"title,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedGIF is an inline query response with cached gif.
func NewInlineQueryResultCachedGIF(id, gifID string) InlineQueryResultCachedGIF
NewInlineQueryResultCachedGIF create a new inline query with cached photo.
type InlineQueryResultCachedMPEG4GIF struct {
Type string `json:"type"`
ID string `json:"id"`
MPEG4FileID string `json:"mpeg4_file_id"`
Title string `json:"title,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
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(id, MPEG4GIFID string) InlineQueryResultCachedMPEG4GIF
NewInlineQueryResultCachedMPEG4GIF create a new inline query with cached MPEG4 GIF.
type InlineQueryResultCachedPhoto struct {
Type string `json:"type"`
ID string `json:"id"`
PhotoID string `json:"photo_file_id"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedPhoto is an inline query response with cached photo.
func NewInlineQueryResultCachedPhoto(id, photoID string) InlineQueryResultCachedPhoto
NewInlineQueryResultCachedPhoto create a new inline query with cached photo.
type InlineQueryResultCachedSticker struct {
Type string `json:"type"`
ID string `json:"id"`
StickerID string `json:"sticker_file_id"`
Title string `json:"title"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedSticker is an inline query response with cached sticker.
func NewInlineQueryResultCachedSticker(id, stickerID, title string) InlineQueryResultCachedSticker
NewInlineQueryResultCachedSticker create a new inline query with cached sticker.
type InlineQueryResultCachedVideo struct {
Type string `json:"type"`
ID string `json:"id"`
VideoID string `json:"video_file_id"`
Title string `json:"title"`
Description string `json:"description,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedVideo is an inline query response with cached video.
func NewInlineQueryResultCachedVideo(id, videoID, title string) InlineQueryResultCachedVideo
NewInlineQueryResultCachedVideo create a new inline query with cached video.
type InlineQueryResultCachedVoice struct {
Type string `json:"type"`
ID string `json:"id"`
VoiceID string `json:"voice_file_id"`
Title string `json:"title"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultCachedVoice is an inline query response with cached voice.
func NewInlineQueryResultCachedVoice(id, voiceID, title string) InlineQueryResultCachedVoice
NewInlineQueryResultCachedVoice create a new inline query with cached photo.
type InlineQueryResultContact struct {
Type string `json:"type"`
ID string `json:"id"`
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
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 struct {
Type string `json:"type"`
ID string `json:"id"`
Title string `json:"title"`
Caption string `json:"caption,omitempty"`
URL string `json:"document_url"`
MimeType string `json:"mime_type"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
ThumbWidth int `json:"thumb_width,omitempty"`
ThumbHeight int `json:"thumb_height,omitempty"`
}
InlineQueryResultDocument is an inline query response document.
func NewInlineQueryResultDocument(id, url, title, mimeType string) InlineQueryResultDocument
NewInlineQueryResultDocument creates a new inline query document.
type InlineQueryResultGIF struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"gif_url"`
ThumbURL string `json:"thumb_url"`
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"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultGIF is an inline query response GIF.
func NewInlineQueryResultGIF(id, url string) InlineQueryResultGIF
NewInlineQueryResultGIF creates a new inline query GIF.
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 struct {
Type string `json:"type"`
ID string `json:"id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
LivePeriod int `json:"live_period"`
Heading int `json:"heading"`
ProximityAlertRadius int `json:"proximity_alert_radius"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
ThumbWidth int `json:"thumb_width,omitempty"`
ThumbHeight int `json:"thumb_height,omitempty"`
}
InlineQueryResultLocation is an inline query response location.
func NewInlineQueryResultLocation(id, title string, latitude, longitude float64) InlineQueryResultLocation
NewInlineQueryResultLocation creates a new inline query location.
type InlineQueryResultMPEG4GIF struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"mpeg4_url"`
Width int `json:"mpeg4_width"`
Height int `json:"mpeg4_height"`
Duration int `json:"mpeg4_duration"`
ThumbURL string `json:"thumb_url"`
Title string `json:"title,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
func NewInlineQueryResultMPEG4GIF(id, url string) InlineQueryResultMPEG4GIF
NewInlineQueryResultMPEG4GIF creates a new inline query MPEG4 GIF.
type InlineQueryResultPhoto struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"photo_url"`
MimeType string `json:"mime_type"`
Width int `json:"photo_width,omitempty"`
Height int `json:"photo_height,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultPhoto is an inline query response photo.
func NewInlineQueryResultPhoto(id, url string) InlineQueryResultPhoto
NewInlineQueryResultPhoto creates a new inline query photo.
func NewInlineQueryResultPhotoWithThumb(id, url, thumb string) InlineQueryResultPhoto
NewInlineQueryResultPhotoWithThumb creates a new inline query photo.
type InlineQueryResultVenue struct {
Type string `json:"type"`
ID string `json:"id"`
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
ThumbURL string `json:"thumb_url,omitempty"`
ThumbWidth int `json:"thumb_width,omitempty"`
ThumbHeight int `json:"thumb_height,omitempty"`
}
InlineQueryResultVenue is an inline query response venue.
func NewInlineQueryResultVenue(id, title, address string, latitude, longitude float64) InlineQueryResultVenue
NewInlineQueryResultVenue creates a new inline query venue.
type InlineQueryResultVideo struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"video_url"`
MimeType string `json:"mime_type"`
ThumbURL string `json:"thumb_url,omitempty"`
Title string `json:"title"`
Caption string `json:"caption,omitempty"`
Width int `json:"video_width,omitempty"`
Height int `json:"video_height,omitempty"`
Duration int `json:"video_duration,omitempty"`
Description string `json:"description,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultVideo is an inline query response video.
func NewInlineQueryResultVideo(id, url string) InlineQueryResultVideo
NewInlineQueryResultVideo creates a new inline query video.
type InlineQueryResultVoice struct {
Type string `json:"type"`
ID string `json:"id"`
URL string `json:"voice_url"`
Title string `json:"title"`
Caption string `json:"caption,omitempty"`
ParseMode string `json:"parse_mode,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Duration int `json:"voice_duration,omitempty"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
InlineQueryResultVoice is an inline query response voice.
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,omitempty"`
VCard string `json:"vcard,omitempty"`
}
InputContactMessageContent contains a contact for displaying as an inline query result.
type InputInvoiceMessageContent ¶
type InputInvoiceMessageContent struct {
Title string `json:"title"`
Description string `json:"description"`
Payload string `json:"payload"`
ProviderToken string `json:"provider_token"`
Currency string `json:"currency"`
Prices []LabeledPrice `json:"prices"`
MaxTipAmount int `json:"max_tip_amount,omitempty"`
SuggestedTipAmounts []int `json:"suggested_tip_amounts,omitempty"`
ProviderData string `json:"provider_data,omitempty"`
PhotoURL string `json:"photo_url,omitempty"`
PhotoSize int `json:"photo_size,omitempty"`
PhotoWidth int `json:"photo_width,omitempty"`
PhotoHeight int `json:"photo_height,omitempty"`
NeedName bool `json:"need_name,omitempty"`
NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
NeedEmail bool `json:"need_email,omitempty"`
NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
SendPhoneNumberToProvider bool `json:"send_phone_number_to_provider,omitempty"`
SendEmailToProvider bool `json:"send_email_to_provider,omitempty"`
IsFlexible bool `json:"is_flexible,omitempty"`
}
InputInvoiceMessageContent represents the content of an invoice message to be sent as the result of an inline query.
type InputLocationMessageContent ¶
type InputLocationMessageContent struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy"`
LivePeriod int `json:"live_period,omitempty"`
Heading int `json:"heading"`
ProximityAlertRadius int `json:"proximity_alert_radius"`
}
InputLocationMessageContent contains a location for displaying as an inline query result.
type InputMediaAnimation struct {
BaseInputMedia
Thumb RequestFileData `json:"thumb,omitempty"`
Width int `json:"width,omitempty"`
Height int `json:"height,omitempty"`
Duration int `json:"duration,omitempty"`
}
InputMediaAnimation is an animation to send as part of a media group.
func NewInputMediaAnimation(media RequestFileData) InputMediaAnimation
NewInputMediaAnimation creates a new InputMediaAnimation.
type InputMediaAudio struct {
BaseInputMedia
Thumb RequestFileData `json:"thumb,omitempty"`
Duration int `json:"duration,omitempty"`
Performer string `json:"performer,omitempty"`
Title string `json:"title,omitempty"`
}
InputMediaAudio is an audio to send as part of a media group.
func NewInputMediaAudio(media RequestFileData) InputMediaAudio
NewInputMediaAudio creates a new InputMediaAudio.
type InputMediaDocument struct {
BaseInputMedia
Thumb RequestFileData `json:"thumb,omitempty"`
DisableContentTypeDetection bool `json:"disable_content_type_detection,omitempty"`
}
InputMediaDocument is a general file to send as part of a media group.
func NewInputMediaDocument(media RequestFileData) InputMediaDocument
NewInputMediaDocument creates a new InputMediaDocument.
type InputMediaPhoto struct {
BaseInputMedia
}
InputMediaPhoto is a photo to send as part of a media group.
func NewInputMediaPhoto(media RequestFileData) InputMediaPhoto
NewInputMediaPhoto creates a new InputMediaPhoto.
type InputMediaVideo struct {
BaseInputMedia
Thumb RequestFileData `json:"thumb,omitempty"`
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(media RequestFileData) InputMediaVideo
NewInputMediaVideo creates a new InputMediaVideo.
type InputTextMessageContent ¶
type InputTextMessageContent struct {
Text string `json:"message_text"`
ParseMode string `json:"parse_mode,omitempty"`
Entities []MessageEntity `json:"entities,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
}
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,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id"`
GooglePlaceType string `json:"google_place_type"`
}
InputVenueMessageContent contains a venue for displaying as an inline query result.
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.
InvoiceConfig contains information for sendInvoice request.
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 struct {
Text string `json:"text"`
RequestContact bool `json:"request_contact,omitempty"`
RequestLocation bool `json:"request_location,omitempty"`
RequestPoll *KeyboardButtonPollType `json:"request_poll,omitempty"`
}
KeyboardButton represents one button of the reply keyboard. For simple text buttons String can be used instead of this object to specify text of the button. Optional fields request_contact, request_location, and request_poll are mutually exclusive.
NewKeyboardButton creates a regular keyboard button.
func NewKeyboardButtonContact(text string) KeyboardButton
NewKeyboardButtonContact creates a keyboard button that requests user contact information upon click.
func NewKeyboardButtonLocation(text string) KeyboardButton
NewKeyboardButtonLocation creates a keyboard button that requests user location information upon click.
func NewKeyboardButtonRow(buttons ...KeyboardButton) []KeyboardButton
NewKeyboardButtonRow creates a row of keyboard buttons.
type KeyboardButtonPollType struct {
Type string `json:"type"`
}
KeyboardButtonPollType represents type of poll, which is allowed to be created and sent when the corresponding button is pressed.
type KickChatMemberConfig = BanChatMemberConfig
KickChatMemberConfig contains extra fields to ban user.
This was renamed to BanChatMember in later versions of the Telegram Bot API.
LabeledPrice represents a portion of the price for goods or services.
LeaveChatConfig allows you to leave a chat.
type Location struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
LivePeriod int `json:"live_period,omitempty"`
Heading int `json:"heading,omitempty"`
ProximityAlertRadius int `json:"proximity_alert_radius,omitempty"`
}
Location represents a point on the map.
LocationConfig contains information about a SendLocation request.
NewLocation shares your location.
chatID is where to send it, latitude and longitude are coordinates.
type LogOutConfig struct{}
LogOutConfig is a request to log out of the cloud Bot API server.
Note that you may not log back in for at least 10 minutes.
type LoginURL struct {
URL string `json:"url"`
ForwardText string `json:"forward_text,omitempty"`
BotUsername string `json:"bot_username,omitempty"`
RequestWriteAccess bool `json:"request_write_access,omitempty"`
}
LoginURL represents a parameter of the inline keyboard button used to automatically authorize a user. Serves as a great replacement for the Telegram Login Widget when the user is coming from Telegram. All the user needs to do is tap/click a button and confirm that they want to log in.
type MaskPosition struct {
Point string `json:"point"`
XShift float64 `json:"x_shift"`
YShift float64 `json:"y_shift"`
Scale float64 `json:"scale"`
}
MaskPosition describes the position on faces where a mask should be placed by default.
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(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 struct {
MessageID int `json:"message_id"`
From *User `json:"from,omitempty"`
SenderChat *Chat `json:"sender_chat,omitempty"`
Date int `json:"date"`
Chat *Chat `json:"chat"`
ForwardFrom *User `json:"forward_from,omitempty"`
ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
ForwardFromMessageID int `json:"forward_from_message_id,omitempty"`
ForwardSignature string `json:"forward_signature,omitempty"`
ForwardSenderName string `json:"forward_sender_name,omitempty"`
ForwardDate int `json:"forward_date,omitempty"`
IsAutomaticForward bool `json:"is_automatic_forward,omitempty"`
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
ViaBot *User `json:"via_bot,omitempty"`
EditDate int `json:"edit_date,omitempty"`
HasProtectedContent bool `json:"has_protected_content,omitempty"`
MediaGroupID string `json:"media_group_id,omitempty"`
AuthorSignature string `json:"author_signature,omitempty"`
Text string `json:"text,omitempty"`
Entities []MessageEntity `json:"entities,omitempty"`
Animation *Animation `json:"animation,omitempty"`
Audio *Audio `json:"audio,omitempty"`
Document *Document `json:"document,omitempty"`
Photo []PhotoSize `json:"photo,omitempty"`
Sticker *Sticker `json:"sticker,omitempty"`
Video *Video `json:"video,omitempty"`
VideoNote *VideoNote `json:"video_note,omitempty"`
Voice *Voice `json:"voice,omitempty"`
Caption string `json:"caption,omitempty"`
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
Contact *Contact `json:"contact,omitempty"`
Dice *Dice `json:"dice,omitempty"`
Game *Game `json:"game,omitempty"`
Poll *Poll `json:"poll,omitempty"`
Venue *Venue `json:"venue,omitempty"`
Location *Location `json:"location,omitempty"`
NewChatMembers []User `json:"new_chat_members,omitempty"`
LeftChatMember *User `json:"left_chat_member,omitempty"`
NewChatTitle string `json:"new_chat_title,omitempty"`
NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
GroupChatCreated bool `json:"group_chat_created,omitempty"`
SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
MessageAutoDeleteTimerChanged *MessageAutoDeleteTimerChanged `json:"message_auto_delete_timer_changed"`
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Invoice *Invoice `json:"invoice,omitempty"`
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
ConnectedWebsite string `json:"connected_website,omitempty"`
PassportData *PassportData `json:"passport_data,omitempty"`
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered"`
VoiceChatScheduled *VoiceChatScheduled `json:"voice_chat_scheduled"`
VoiceChatStarted *VoiceChatStarted `json:"voice_chat_started"`
VoiceChatEnded *VoiceChatEnded `json:"voice_chat_ended"`
VoiceChatParticipantsInvited *VoiceChatParticipantsInvited `json:"voice_chat_participants_invited"`
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
Message represents a message.
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.
Time converts the message timestamp into a Time.
type MessageAutoDeleteTimerChanged struct {
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
}
MessageAutoDeleteTimerChanged represents a service message about a change in auto-delete timer settings.
type MessageConfig struct {
BaseChat
Text string
ParseMode string
Entities []MessageEntity
DisableWebPagePreview bool
}
MessageConfig contains information about a SendMessage request.
NewMessage creates a new Message.
chatID is where to send it, text is the message text.
NewMessageToChannel creates a new Message that is sent to a channel by username.
username is the username of the channel, text is the message text, and the username should be in the form of `@username`.
type MessageEntity struct {
Type string `json:"type"`
Offset int `json:"offset"`
Length int `json:"length"`
URL string `json:"url,omitempty"`
User *User `json:"user,omitempty"`
Language string `json:"language,omitempty"`
}
MessageEntity represents one special entity in a text message.
IsBold returns true if the type of the message entity is "bold" (bold text).
IsCode returns true if the type of the message entity is "code" (monowidth string).
func (MessageEntity) IsCommand ¶
IsCommand returns true if the type of the message entity is "bot_command".
IsEmail returns true if the type of the message entity is "email".
IsHashtag returns true if the type of the message entity is "hashtag".
IsItalic returns true if the type of the message entity is "italic" (italic text).
IsMention returns true if the type of the message entity is "mention" (@username).
IsPre returns true if the type of the message entity is "pre" (monowidth block).
func (e MessageEntity) IsTextLink() bool
IsTextLink returns true if the type of the message entity is "text_link" (clickable text URL).
IsURL returns true if the type of the message entity is "url".
ParseURL attempts to parse a URL contained within a MessageEntity.
type MessageID struct {
MessageID int `json:"message_id"`
}
MessageID represents a unique message identifier.
NewStickerSetConfig allows creating a new sticker set.
You must set either PNGSticker or TGSSticker.
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.
Params represents a set of parameters that gets passed to a request.
AddBool adds a value of a bool if it is true.
AddFirstValid attempts to add the first item that is not a default value.
For example, AddFirstValid(0, "", "test") would add "test".
AddInterface adds an interface if it is not nil and can be JSON marshalled.
AddNonZero adds a value if it is not zero.
AddNonZero64 is the same as AddNonZero except uses an int64.
AddNonZeroFloat adds a floating point value that is not zero.
type PassportData struct {
Data []EncryptedPassportElement `json:"data"`
Credentials *EncryptedCredentials `json:"credentials"`
}
PassportData contains information about Telegram Passport data shared with the bot by the user.
type PassportElementError interface{}
PassportElementError represents an error in the Telegram Passport element which was submitted that should be resolved by the user.
type PassportElementErrorDataField struct {
Source string `json:"source"`
Type string `json:"type"`
FieldName string `json:"field_name"`
DataHash string `json:"data_hash"`
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 struct {
Source string `json:"source"`
Type string `json:"type"`
FileHash string `json:"file_hash"`
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 struct {
Source string `json:"source"`
Type string `json:"type"`
FileHashes []string `json:"file_hashes"`
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 struct {
Source string `json:"source"`
Type string `json:"type"`
FileHash string `json:"file_hash"`
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 struct {
Source string `json:"source"`
Type string `json:"type"`
FileHash string `json:"file_hash"`
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 struct {
Source string `json:"source"`
Type string `json:"type"`
FileHash string `json:"file_hash"`
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 struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
FileSize int `json:"file_size"`
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 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 struct {
V int `json:"v"`
Data []PassportScopeElement `json:"data"`
}
PassportScope is the requested scopes of data.
type PassportScopeElement interface {
ScopeType() string
}
PassportScopeElement supports using one or one of several elements.
type PassportScopeElementOne struct {
Type string `json:"type"`
Selfie bool `json:"selfie"`
Translation bool `json:"translation"`
NativeNames bool `json:"native_name"`
}
PassportScopeElementOne requires the specified element be provided.
ScopeType is the scope type.
type PassportScopeElementOneOfSeveral struct {
}
PassportScopeElementOneOfSeveral allows you to request any one of the requested documents.
ScopeType is the scope type.
type PhotoConfig struct {
BaseFile
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
}
PhotoConfig contains information about a SendPhoto request.
NewPhoto creates a new sendPhoto request.
chatID is where to send it, file is a string path to the file, FileReader, or FileBytes.
Note that you must send animated GIFs as a document.
func NewPhotoToChannel(username string, file RequestFileData) 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 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"`
}
PhotoSize represents one size of a photo or a file / sticker thumbnail.
type PinChatMessageConfig struct {
ChatID int64
ChannelUsername string
MessageID int
DisableNotification bool
}
PinChatMessageConfig contains information of a message in a chat to pin.
type Poll struct {
ID string `json:"id"`
Question string `json:"question"`
Options []PollOption `json:"options"`
TotalVoterCount int `json:"total_voter_count"`
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"`
Explanation string `json:"explanation,omitempty"`
ExplanationEntities []MessageEntity `json:"explanation_entities,omitempty"`
OpenPeriod int `json:"open_period,omitempty"`
CloseDate int `json:"close_date,omitempty"`
}
Poll contains information about a poll.
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.
PollOption contains information about one answer option in a poll.
PreCheckoutConfig conatins information for answerPreCheckoutQuery request.
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 struct {
ChatMemberConfig
IsAnonymous bool
CanManageChat bool
CanChangeInfo bool
CanPostMessages bool
CanEditMessages bool
CanDeleteMessages bool
CanManageVoiceChats bool
CanInviteUsers bool
CanRestrictMembers bool
CanPinMessages bool
CanPromoteMembers bool
}
PromoteChatMemberConfig contains fields to promote members of chat
type ProximityAlertTriggered struct {
Traveler User `json:"traveler"`
Watcher User `json:"watcher"`
Distance int `json:"distance"`
}
ProximityAlertTriggered represents a service message sent when a user in the chat triggers a proximity alert sent by another user.
type ReplyKeyboardMarkup struct {
Keyboard [][]KeyboardButton `json:"keyboard"`
ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
InputFieldPlaceholder string `json:"input_field_placeholder,omitempty"`
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardMarkup represents a custom keyboard with reply options.
func NewOneTimeReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup
NewOneTimeReplyKeyboard creates a new one time keyboard.
func NewReplyKeyboard(rows ...[]KeyboardButton) ReplyKeyboardMarkup
NewReplyKeyboard creates a new regular keyboard with sane defaults.
type ReplyKeyboardRemove struct {
RemoveKeyboard bool `json:"remove_keyboard"`
Selective bool `json:"selective,omitempty"`
}
ReplyKeyboardRemove Upon receiving a message with this object, Telegram clients will remove the current custom keyboard and display the default letter-keyboard. By default, custom keyboards are displayed until a new keyboard is sent by a bot. An exception is made for one-time keyboards that are hidden immediately after the user presses a button.
func NewRemoveKeyboard(selective bool) ReplyKeyboardRemove
NewRemoveKeyboard hides the keyboard, with the option for being selective or hiding for everyone.
type RequestFile struct {
Name string
Data RequestFileData
}
RequestFile represents a file associated with a field name.
RequestFileData represents the data to be used for a file.
type ResponseParameters struct {
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
RetryAfter int `json:"retry_after,omitempty"`
}
ResponseParameters are various errors that can be returned in APIResponse.
type RestrictChatMemberConfig struct {
ChatMemberConfig
UntilDate int64
Permissions *ChatPermissions
}
RestrictChatMemberConfig contains fields to restrict members of chat
type RevokeChatInviteLinkConfig struct {
ChatConfig
InviteLink string
}
RevokeChatInviteLinkConfig allows you to revoke an invite link created by the bot. If the primary link is revoked, a new link is automatically generated. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
SecureData is a map of the fields and their encrypted values.
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.
SendPollConfig allows you to send a poll.
NewPoll allows you to create a new poll.
type SetChatAdministratorCustomTitle struct {
ChatMemberConfig
CustomTitle string
}
SetChatAdministratorCustomTitle sets the title of an administrative user promoted by the bot for a chat.
SetChatDescriptionConfig allows you to set the description of a supergroup or channel.
NewChatDescription allows you to update the description of a chat.
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 struct {
BaseFile
}
SetChatPhotoConfig allows you to set a group, supergroup, or channel's photo.
NewChatPhoto allows you to update the photo for a chat.
type SetChatStickerSetConfig struct {
ChatID int64
SuperGroupUsername string
StickerSetName string
}
SetChatStickerSetConfig allows you to set the sticker set for a supergroup.
SetChatTitleConfig allows you to set the title of something other than a private chat.
NewChatTitle allows you to update the title of a chat.
SetGameScoreConfig allows you to update the game score in a chat.
type SetMyCommandsConfig ¶
type SetMyCommandsConfig struct {
Commands []BotCommand
Scope *BotCommandScope
LanguageCode string
}
SetMyCommandsConfig sets a list of commands the bot understands.
func NewSetMyCommands ¶
func NewSetMyCommands(commands ...BotCommand) SetMyCommandsConfig
NewSetMyCommands allows you to set the registered commands.
func NewSetMyCommandsWithScope ¶
func NewSetMyCommandsWithScope(scope BotCommandScope, commands ...BotCommand) SetMyCommandsConfig
NewSetMyCommandsWithScope allows you to set the registered commands for a given scope.
func NewSetMyCommandsWithScopeAndLanguage ¶
func NewSetMyCommandsWithScopeAndLanguage(scope BotCommandScope, languageCode string, commands ...BotCommand) SetMyCommandsConfig
NewSetMyCommandsWithScopeAndLanguage allows you to set the registered commands for a given scope and language code.
SetStickerPositionConfig allows you to change the position of a sticker in a set.
type SetStickerSetThumbConfig struct {
Name string
UserID int64
Thumb RequestFileData
}
SetStickerSetThumbConfig allows you to set the thumbnail for a sticker set.
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 struct {
ShippingQueryID string
OK bool
ShippingOptions []ShippingOption
ErrorMessage string
}
ShippingConfig contains information for answerShippingQuery request.
type ShippingOption struct {
ID string `json:"id"`
Title string `json:"title"`
Prices []LabeledPrice `json:"prices"`
}
ShippingOption represents one shipping option.
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 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,omitempty"`
Thumbnail *PhotoSize `json:"thumb,omitempty"`
Emoji string `json:"emoji,omitempty"`
SetName string `json:"set_name,omitempty"`
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
Sticker represents a sticker.
type StickerConfig struct {
BaseFile
}
StickerConfig contains information about a SendSticker request.
NewSticker creates a new sendSticker request.
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"`
Thumbnail *PhotoSize `json:"thumb"`
}
StickerSet represents a sticker set.
type StopMessageLiveLocationConfig struct {
BaseEdit
}
StopMessageLiveLocationConfig stops updating a live location.
type StopPollConfig struct {
BaseEdit
}
StopPollConfig allows you to stop a poll sent by the bot.
NewStopPoll allows you to stop a poll.
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 struct {
ChatMemberConfig
OnlyIfBanned bool
}
UnbanChatMemberConfig allows you to unban a user.
UnbanChatSenderChatConfig unbans a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights.
UnpinAllChatMessagesConfig contains information of all messages to unpin in a chat.
UnpinChatMessageConfig contains information of a chat message to unpin.
If MessageID is not specified, it will unpin the most recent pin.
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"`
MyChatMember *ChatMemberUpdated `json:"my_chat_member"`
ChatMember *ChatMemberUpdated `json:"chat_member"`
ChatJoinRequest *ChatJoinRequest `json:"chat_join_request"`
}
Update is an update response, from GetUpdates.
CallbackData returns the callback query data, if it exists.
UpdateConfig contains information about a GetUpdates request.
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 <-chan Update
UpdatesChannel is the channel for getting updates.
func (ch UpdatesChannel) Clear()
Clear discards all unprocessed incoming updates.
type UploadStickerConfig struct {
UserID int64
PNGSticker RequestFileData
}
UploadStickerConfig allows you to upload a sticker for use in a set later.
type User struct {
ID int64 `json:"id"`
IsBot bool `json:"is_bot,omitempty"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
UserName string `json:"username,omitempty"`
LanguageCode string `json:"language_code,omitempty"`
CanJoinGroups bool `json:"can_join_groups,omitempty"`
CanReadAllGroupMessages bool `json:"can_read_all_group_messages,omitempty"`
SupportsInlineQueries bool `json:"supports_inline_queries,omitempty"`
}
User represents a Telegram user or bot.
String displays a simple text version of a user.
It is normally a user's username, but falls back to a first/last name as available.
type UserProfilePhotos struct {
TotalCount int `json:"total_count"`
Photos [][]PhotoSize `json:"photos"`
}
UserProfilePhotos contains a set of user profile photos.
UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.
func NewUserProfilePhotos(userID int64) UserProfilePhotosConfig
NewUserProfilePhotos gets user profile photos.
userID is the ID of the user you wish to get profile photos from.
type Venue struct {
Location Location `json:"location"`
Title string `json:"title"`
Address string `json:"address"`
FoursquareID string `json:"foursquare_id,omitempty"`
FoursquareType string `json:"foursquare_type,omitempty"`
GooglePlaceID string `json:"google_place_id,omitempty"`
GooglePlaceType string `json:"google_place_type,omitempty"`
}
Venue represents a venue.
VenueConfig contains information about a SendVenue request.
NewVenue allows you to send a venue and its location.
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"`
FileName string `json:"file_name,omitempty"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
Video represents a video file.
type VideoConfig struct {
BaseFile
Thumb RequestFileData
Duration int
Caption string
ParseMode string
CaptionEntities []MessageEntity
SupportsStreaming bool
}
VideoConfig contains information about a SendVideo request.
NewVideo creates a new sendVideo request.
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"`
FileSize int `json:"file_size,omitempty"`
}
VideoNote object represents a video message.
type VideoNoteConfig struct {
BaseFile
Thumb RequestFileData
Duration int
Length int
}
VideoNoteConfig contains information about a SendVideoNote request.
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 struct {
FileID string `json:"file_id"`
FileUniqueID string `json:"file_unique_id"`
Duration int `json:"duration"`
MimeType string `json:"mime_type,omitempty"`
FileSize int `json:"file_size,omitempty"`
}
Voice represents a voice note.
type VoiceChatEnded struct {
Duration int `json:"duration"`
}
VoiceChatEnded represents a service message about a voice chat ended in the chat.
type VoiceChatParticipantsInvited struct {
Users []User `json:"users"`
}
VoiceChatParticipantsInvited represents a service message about new members invited to a voice chat.
type VoiceChatScheduled struct {
StartDate int `json:"start_date"`
}
VoiceChatScheduled represents a service message about a voice chat scheduled in the chat.
Time converts the scheduled start date into a Time.
type VoiceChatStarted struct{}
VoiceChatStarted represents a service message about a voice chat started in the chat.
type VoiceConfig struct {
BaseFile
Thumb RequestFileData
Caption string
ParseMode string
CaptionEntities []MessageEntity
Duration int
}
VoiceConfig contains information about a SendVoice request.
NewVoice creates a new sendVoice request.
type WebhookConfig struct {
URL *url.URL
Certificate RequestFileData
IPAddress string
MaxConnections int
AllowedUpdates []string
DropPendingUpdates bool
}
WebhookConfig contains information about a SetWebhook request.
NewWebhook creates a new webhook.
link is the url parsable link you wish to get the updates.
bot, err := NewBotAPI("MyAwesomeBotToken")
if err != nil {
panic(err)
}
bot.Debug = true
log.Printf("Authorized on account %s", bot.Self.UserName)
wh, err := NewWebhookWithCert("https://www.google.com:8443/"+bot.Token, FilePath("cert.pem"))
if err != nil {
panic(err)
}
_, err = bot.Request(wh)
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)
}
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 struct {
URL string `json:"url"`
HasCustomCertificate bool `json:"has_custom_certificate"`
PendingUpdateCount int `json:"pending_update_count"`
IPAddress string `json:"ip_address,omitempty"`
LastErrorDate int `json:"last_error_date,omitempty"`
LastErrorMessage string `json:"last_error_message,omitempty"`
MaxConnections int `json:"max_connections,omitempty"`
AllowedUpdates []string `json:"allowed_updates,omitempty"`
}
WebhookInfo is information about a currently set webhook.
IsSet returns true if a webhook is currently set.