Documentation ¶
Index ¶
- Constants
- Variables
- func GetUpdates(ctx context.Context, api *API, cfg UpdateCfg, out chan<- Update) error
- func IsAPIError(err error) bool
- func IsForbiddenError(err error) bool
- func IsRequiredError(err error) bool
- func IsUnauthorizedError(err error) bool
- func IsValidToken(token string) bool
- func IsValidationError(err error) bool
- func NewHInlineKeyboard(prefix string, text []string, data []string) [][]InlineKeyboardButton
- func NewHKeyboard(buttons ...string) [][]KeyboardButton
- func NewKeyboard(buttons [][]string) [][]KeyboardButton
- func NewVInlineKeyboard(prefix string, text []string, data []string) [][]InlineKeyboardButton
- func NewVKeyboard(buttons ...string) [][]KeyboardButton
- type API
- func (c *API) AnswerCallbackQuery(ctx context.Context, cfg AnswerCallbackCfg) (bool, error)
- func (c *API) AnswerInlineQuery(ctx context.Context, cfg AnswerInlineQueryCfg) (bool, error)
- func (c *API) Debug(val bool)
- func (c *API) DebugFunc(f DebugFunc)
- func (c *API) DownloadFile(ctx context.Context, cfg FileCfg, w io.Writer) error
- func (c *API) Edit(ctx context.Context, cfg Method) (*EditResult, error)
- func (c *API) EditMessageCaption(ctx context.Context, cfg EditMessageCaptionCfg) (*EditResult, error)
- func (c *API) EditMessageReplyMarkup(ctx context.Context, cfg EditMessageReplyMarkupCfg) (*EditResult, error)
- func (c *API) EditMessageText(ctx context.Context, cfg EditMessageTextCfg) (*EditResult, error)
- func (c *API) ForwardMessage(ctx context.Context, cfg ForwardMessageCfg) (*Message, error)
- func (c *API) GetChat(ctx context.Context, cfg GetChatCfg) (*Chat, error)
- func (c *API) GetChatAdministrators(ctx context.Context, cfg GetChatAdministratorsCfg) ([]ChatMember, error)
- func (c *API) GetChatMember(ctx context.Context, cfg GetChatMemberCfg) (*ChatMember, error)
- func (c *API) GetChatMembersCount(ctx context.Context, cfg GetChatMembersCountCfg) (int, error)
- func (c *API) GetFile(ctx context.Context, cfg FileCfg) (*File, error)
- func (c *API) GetMe(ctx context.Context) (*User, error)
- func (c *API) GetUpdates(ctx context.Context, cfg UpdateCfg) ([]Update, error)
- func (c *API) GetUserProfilePhotos(ctx context.Context, cfg UserProfilePhotosCfg) (*UserProfilePhotos, error)
- func (c *API) Invoke(ctx context.Context, m Method, dst interface{}) error
- func (c *API) KickChatMember(ctx context.Context, cfg KickChatMemberCfg) (bool, error)
- func (c *API) LeaveChat(ctx context.Context, cfg LeaveChatCfg) (bool, error)
- func (c *API) Send(ctx context.Context, cfg Messenger) (*Message, error)
- func (c *API) SendAudio(ctx context.Context, cfg AudioCfg) (*Message, error)
- func (c *API) SendChatAction(ctx context.Context, cfg ChatActionCfg) error
- func (c *API) SendContact(ctx context.Context, cfg ContactCfg) (*Message, error)
- func (c *API) SendDocument(ctx context.Context, cfg DocumentCfg) (*Message, error)
- func (c *API) SendMessage(ctx context.Context, cfg MessageCfg) (*Message, error)
- func (c *API) SendPhoto(ctx context.Context, cfg PhotoCfg) (*Message, error)
- func (c *API) SendSticker(ctx context.Context, cfg StickerCfg) (*Message, error)
- func (c *API) SendVenue(ctx context.Context, cfg VenueCfg) (*Message, error)
- func (c *API) SendVideo(ctx context.Context, cfg VideoCfg) (*Message, error)
- func (c *API) SendVoice(ctx context.Context, cfg VoiceCfg) (*Message, error)
- func (c *API) SetWebhook(ctx context.Context, cfg WebhookCfg) error
- func (c *API) UnbanChatMember(ctx context.Context, cfg UnbanChatMemberCfg) (bool, error)
- type APIError
- type APIResponse
- type AnswerCallbackCfg
- type AnswerInlineQueryCfg
- type Audio
- type AudioCfg
- type BaseChat
- type BaseEdit
- type BaseFile
- type BaseInlineQueryResult
- type BaseMessage
- type CallbackQuery
- type Chat
- type ChatActionCfg
- type ChatMember
- type ChosenInlineResult
- type Contact
- type ContactCfg
- type DebugFunc
- type Document
- type DocumentCfg
- type EditMessageCaptionCfg
- type EditMessageReplyMarkupCfg
- type EditMessageTextCfg
- type EditResult
- type File
- type FileCfg
- type Filer
- type ForceReply
- type ForwardMessageCfg
- type GetChatAdministratorsCfg
- type GetChatCfg
- type GetChatMemberCfg
- type GetChatMembersCountCfg
- type HTTPDoer
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type InlineQuery
- type InlineQueryResult
- type InlineQueryResultArticle
- type InlineQueryResultAudio
- type InlineQueryResultContact
- type InlineQueryResultDocument
- type InlineQueryResultGIF
- type InlineQueryResultLocation
- type InlineQueryResultMPEG4GIF
- type InlineQueryResultPhoto
- type InlineQueryResultVenue
- type InlineQueryResultVideo
- type InlineQueryResultVoice
- type InlineThumb
- type InputContactMessageContent
- type InputFile
- type InputLocationMessageContent
- type InputMessageContent
- type InputTextMessageContent
- type InputVenueMessageContent
- type KeyboardButton
- type KickChatMemberCfg
- type LeaveChatCfg
- type Location
- type LocationCfg
- type MarkInlineQueryResult
- type MarkInputMessageContent
- type MarkReplyMarkup
- type MeCfg
- type Message
- type MessageCfg
- type MessageEntity
- type Messenger
- type MetaFile
- type Method
- type PhotoCfg
- type PhotoSize
- type ReplyKeyboardHide
- type ReplyKeyboardMarkup
- type ReplyMarkup
- type RequiredError
- type Size
- type Sticker
- type StickerCfg
- type UnbanChatMemberCfg
- type Update
- type UpdateCfg
- type User
- type UserProfilePhotos
- type UserProfilePhotosCfg
- type ValidationError
- type Venue
- type VenueCfg
- type Video
- type VideoCfg
- type Voice
- type VoiceCfg
- type WebhookCfg
Constants ¶
const ( // APIEndpoint is the endpoint for all API methods, // with formatting for Sprintf. APIEndpoint = "https://api.telegram.org/bot%s/%s" // FileEndpoint is the endpoint for downloading a file from Telegram. FileEndpoint = "https://api.telegram.org/file/bot%s/%s" )
const ( PrivateChatType = "private" GroupChatType = "group" SuperGroupChatType = "supergroup" ChannelChatType = "channel" )
Type of chat
const ( ActionTyping = "typing" ActionUploadPhoto = "upload_photo" ActionRecordVideo = "record_video" ActionUploadVideo = "upload_video" ActionRecordAudio = "record_audio" ActionUploadAudio = "upload_audio" ActionUploadDocument = "upload_document" ActionFindLocation = "find_location" )
Type of action to broadcast.
Choose one, depending on what the user is about to receive:
typing for text messages upload_photo for photos record_video or upload_video for videos record_audio or upload_audio for audio files upload_document for general files find_location for location data
const ( MarkdownMode = "Markdown" HTMLMode = "HTML" )
Constant values for ParseMode in MessageCfg.
const ( // @username MentionEntityType = "mention" HashTagEntityType = "hashtag" BotCommandEntityType = "bot_command" URLEntityType = "url" EmailEntityType = "email" BoldEntityType = "bold" // bold text ItalicEntityType = "italic" // italic text CodeEntityType = "code" // monowidth string PreEntityType = "pre" // monowidth block TextLinkEntityType = "text_link" // for clickable text URLs TextMentionEntityType = "text_mention" // for users without usernames )
EntityType constants helps to set type of entity in MessageEntity object
const ( MemberStatus = "member" CreatorMemberStatus = "creator" AdministratorMemberStatus = "administrator" LeftMemberStatus = "left" KickedMemberStatus = "kicked" )
ChatMember possible statuses
Variables ¶
var DefaultDebugFunc = func(msg string, fields map[string]interface{}) { log.Printf("%s %v", msg, fields) }
DefaultDebugFunc prints debug message to default logger
Functions ¶
func GetUpdates ¶
GetUpdates runs loop and requests updates from telegram. It breaks loop, close out channel and returns error if something happened during update cycle.
func IsForbiddenError ¶
IsForbiddenError checks if error is forbidden
func IsRequiredError ¶
IsRequiredError checks if error is RequiredError
func IsUnauthorizedError ¶
IsUnauthorizedError checks if error is unauthorized
func IsValidToken ¶
IsValidToken returns true if token is a valid telegram bot token
Token format is like: 110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsawq
func IsValidationError ¶
IsValidationError checks if error is ValidationError
func NewHInlineKeyboard ¶
func NewHInlineKeyboard(prefix string, text []string, data []string) [][]InlineKeyboardButton
NewHInlineKeyboard creates inline keyboard with horizontal buttons only. [ first ] [ second ] [ third ]
func NewHKeyboard ¶
func NewHKeyboard(buttons ...string) [][]KeyboardButton
NewHKeyboard creates keyboard with horizontal buttons only. [ first ] [ second ] [ third ]
func NewKeyboard ¶
func NewKeyboard(buttons [][]string) [][]KeyboardButton
NewKeyboard creates keyboard by matrix i*j.
func NewVInlineKeyboard ¶
func NewVInlineKeyboard(prefix string, text []string, data []string) [][]InlineKeyboardButton
NewVInlineKeyboard creates inline keyboard with vertical buttons only [ first ] [ second ] [ third ]
func NewVKeyboard ¶
func NewVKeyboard(buttons ...string) [][]KeyboardButton
NewVKeyboard creates keyboard with vertical buttons only [ first ] [ second ] [ third ]
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API implements Telegram bot API described on https://core.telegram.org/bots/api
func NewWithClient ¶
NewWithClient returns API instance with custom http client
func (*API) AnswerCallbackQuery ¶
AnswerCallbackQuery sends a response to an inline query callback.
func (*API) AnswerInlineQuery ¶
AnswerInlineQuery sends answers to an inline query. On success, True is returned. No more than 50 results per query are allowed.
func (*API) Edit ¶
Edit method allows you to change an existing message in the message history instead of sending a new one with a result of an action. This is most useful for messages with inline keyboards using callback queries, but can also help reduce clutter in conversations with regular chat bots. Please note, that it is currently only possible to edit messages without reply_markup or with inline keyboards.
You can use this method directly or one of: EditMessageText, EditMessageCaption, EditMessageReplyMarkup,
func (*API) EditMessageCaption ¶
func (c *API) EditMessageCaption( ctx context.Context, cfg EditMessageCaptionCfg) (*EditResult, error)
EditMessageCaption modifies the caption of message. Use this method to edit only the caption of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
func (*API) EditMessageReplyMarkup ¶
func (c *API) EditMessageReplyMarkup( ctx context.Context, cfg EditMessageReplyMarkupCfg) (*EditResult, error)
EditMessageReplyMarkup modifies the reply markup of message. Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
func (*API) EditMessageText ¶
func (c *API) EditMessageText( ctx context.Context, cfg EditMessageTextCfg) (*EditResult, error)
EditMessageText modifies the text of message. Use this method to edit only the text of messages sent by the bot or via the bot (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
func (*API) ForwardMessage ¶
ForwardMessage forwards messages of any kind.
func (*API) GetChat ¶
GetChat returns up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
func (*API) GetChatAdministrators ¶
func (c *API) GetChatAdministrators( ctx context.Context, cfg GetChatAdministratorsCfg) ([]ChatMember, error)
GetChatAdministrators returns a list of administrators in a chat. On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
func (*API) GetChatMember ¶
func (c *API) GetChatMember( ctx context.Context, cfg GetChatMemberCfg) (*ChatMember, error)
GetChatMember returns information about a member of a chat.
func (*API) GetChatMembersCount ¶
GetChatMembersCount returns the number of members in a chat.
func (*API) GetFile ¶
GetFile returns a File which can download a file from Telegram.
Requires FileID.
func (*API) GetUpdates ¶
GetUpdates requests incoming updates using long polling. This method will not work if an outgoing webhook is set up. In order to avoid getting duplicate updates, recalculate offset after each server response.
func (*API) GetUserProfilePhotos ¶
func (c *API) GetUserProfilePhotos( ctx context.Context, cfg UserProfilePhotosCfg) (*UserProfilePhotos, error)
GetUserProfilePhotos requests a list of profile pictures for a user.
func (*API) Invoke ¶
Invoke is a generic method that helps to make request to Telegram Api. Use particular methods instead (e.x. GetMe, GetUpdates etc). The only case when this method seems useful is when Telegram Api has method that still doesn't exist in this implementation.
func (*API) KickChatMember ¶
KickChatMember kicks a user from a group or a supergroup. In the case of supergroups, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the group for this to work. Returns True on success.
func (*API) LeaveChat ¶
LeaveChat method helps your bot to leave a group, supergroup or channel. Returns True on success.
func (*API) SendChatAction ¶
func (c *API) SendChatAction(ctx context.Context, cfg ChatActionCfg) error
SendChatAction tells the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
func (*API) SendContact ¶
SendContact sends phone contact message.
func (*API) SendDocument ¶
SendDocument sends Document.
func (*API) SendMessage ¶
SendMessage sends text message.
func (*API) SendSticker ¶
SendSticker sends message with sticker.
func (*API) SetWebhook ¶
func (c *API) SetWebhook(ctx context.Context, cfg WebhookCfg) error
SetWebhook sets a webhook. Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON‐serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts.
If this is set, GetUpdates will not get any data!
If you do not have a legitimate TLS certificate, you need to include your self signed certificate with the config.
func (*API) UnbanChatMember ¶
UnbanChatMember unbans a previously kicked user in a supergroup. The user will not return to the group automatically, but will be able to join via link, etc. The bot must be an administrator in the group for this to work. Returns True on success.
type APIError ¶
type APIError struct { Description string `json:"description"` // ErrorCode contents are subject to change in the future. ErrorCode int `json:"error_code"` }
APIError contains error information from response
type APIResponse ¶
type APIResponse struct { Ok bool `json:"ok"` Result *json.RawMessage `json:"result"` ErrorCode int `json:"error_code,omitempty"` Description string `json:"description,omitempty"` }
APIResponse is a response from the Telegram API with the result stored raw.
type AnswerCallbackCfg ¶
type AnswerCallbackCfg struct { CallbackQueryID string `json:"callback_query_id"` Text string `json:"text"` ShowAlert bool `json:"show_alert"` }
AnswerCallbackCfg contains information on making a anserCallbackQuery response.
func NewAnswerCallback ¶
func NewAnswerCallback(id, text string) AnswerCallbackCfg
NewAnswerCallback creates a new callback message.
func NewAnswerCallbackWithAlert ¶
func NewAnswerCallbackWithAlert(id, text string) AnswerCallbackCfg
NewAnswerCallbackWithAlert creates a new callback message that alerts the user.
type AnswerInlineQueryCfg ¶
type AnswerInlineQueryCfg struct { // Unique identifier for the answered query InlineQueryID string `json:"inline_query_id"` Results []InlineQueryResult `json:"results"` // The maximum amount of time in seconds // that the result of the inline query may be cached on the server. // Defaults to 300. CacheTime int `json:"cache_time,omitempty"` // Pass True, if results may be cached on the server side // only for the user that sent the query. // By default, results may be returned to any user // who sends the same query IsPersonal bool `json:"is_personal,omitempty"` // Pass the offset that a client should send in the next query // with the same text to receive more results. // Pass an empty string if there are no more results // or if you don‘t support pagination. // Offset length can’t exceed 64 bytes. NextOffset string `json:"next_offset,omitempty"` // If passed, clients will display a button with specified text // that switches the user to a private chat with the bot and // sends the bot a start message with the parameter switch_pm_parameter SwitchPMText string `json:"switch_pm_text,omitempty"` // Parameter for the start message sent to the bot // when user presses the switch button SwitchPMParameter string `json:"switch_pm_parameter"` }
AnswerInlineQueryCfg contains information on making an InlineQuery response.
func (AnswerInlineQueryCfg) Name ¶
func (cfg AnswerInlineQueryCfg) Name() string
Name returns method name
type Audio ¶
type Audio struct { MetaFile // Duration of the recording in seconds as defined by sender. Duration int `json:"duration"` // Performer of the audio as defined by sender // or by audio tags. Optional. Performer string `json:"performer,omitempty"` // Title of the audio as defined by sender // or by audio tags. Optional. Title string `json:"title,omitempty"` // MIMEType of the file as defined by sender. Optional. MIMEType string `json:"mime_type,omitempty"` }
Audio object represents an audio file to be treated as music by the Telegram clients.
type AudioCfg ¶
AudioCfg contains information about a SendAudio request. Use it to send information about an audio Implements Filer and Messenger interfaces.
type BaseChat ¶
type BaseChat struct { // Unique identifier for the target chat ID int64 // Username of the target channel (in the format @channelusername) ChannelUsername string }
BaseChat describes chat settings. It's an abstract type.
You must set ID or ChannelUsername.
type BaseEdit ¶
type BaseEdit struct { // Required if inline_message_id is not specified. // Unique identifier for the target chat or // username of the target channel (in the format @channelusername) ChatID int64 ChannelUsername string // Required if inline_message_id is not specified. // Unique identifier of the sent message MessageID int64 // Required if chat_id and message_id are not specified. // Identifier of the inline message InlineMessageID string // Only InlineKeyboardMarkup supported right now. ReplyMarkup ReplyMarkup }
BaseEdit is base type of all chat edits.
type BaseFile ¶
type BaseFile struct { BaseMessage FileID string MimeType string InputFile InputFile }
BaseFile describes file settings. It's an abstract type.
type BaseInlineQueryResult ¶
type BaseInlineQueryResult struct { Type string `json:"type"` // required ID string `json:"id"` // required InputMessageContent InputMessageContent `json:"input_message_content,omitempty"` // ReplyMarkup supports only InlineKeyboardMarkup for InlineQueryResult ReplyMarkup ReplyMarkup `json:"reply_markup,omitempty"` }
BaseInlineQueryResult is a base class for InlineQueryResult
type BaseMessage ¶
type BaseMessage struct { BaseChat // If the message is a reply, ID of the original message ReplyToMessageID int64 // Additional interface options. // A JSON-serialized object for a custom reply keyboard, // instructions to hide keyboard or to force a reply from the user. ReplyMarkup ReplyMarkup // Sends the message silently. // iOS users will not receive a notification, // Android users will receive a notification with no sound. // Other apps coming soon. DisableNotification bool }
BaseMessage is a base type for all message config types. Implements Messenger interface.
func (BaseMessage) Message ¶
func (BaseMessage) Message() *Message
Message returns instance of *Message type.
type CallbackQuery ¶
type CallbackQuery struct { // Unique identifier for this query ID string `json:"id"` // Sender From *User `json:"from"` // Message with the callback button that originated the query. // Note that message content and message date // will not be available if the message is too old. Optional. Message *Message `json:"message,omitempty"` // Identifier of the message sent via the bot in inline mode, // that originated the query. Optional. InlineMessageID string `json:"inline_message_id,omitempty"` // Data associated with the callback button. // Be aware that a bad client can send arbitrary data in this field Data string `json:"data"` }
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 presented. If the button was attached to a message sent via the bot (in inline mode), the field inline_message_id will be presented.
type Chat ¶
type Chat struct { // ID is a Unique identifier for this chat, not exceeding 1e13 by absolute value. ID int64 `json:"id"` // Type of chat, can be either “private”, “group”, "supergroup" or “channel” Type string `json:"type"` Title string `json:"title,omitempty"` FirstName string `json:"first_name,omitempty"` LastName string `json:"last_name,omitempty"` Username string `json:"username,omitempty"` }
Chat object represents a Telegram user, bot or group chat. Title for channels and group chats
type ChatActionCfg ¶
type ChatActionCfg struct { BaseChat // Type of action to broadcast. // Choose one, depending on what the user is about to receive: // typing for text messages, upload_photo for photos, // record_video or upload_video for videos, // record_audio or upload_audio for audio files, // upload_document for general files, // find_location for location data. // Use one of constants: ActionTyping, ActionFindLocation, etc Action string }
ChatActionCfg contains information about a SendChatAction request. Action field is required.
func NewChatAction ¶
func NewChatAction(chatID int64, action string) ChatActionCfg
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 Action constants.
type ChatMember ¶
type ChatMember struct { // Information about the user. User User `json:"user"` // The member's status in the chat. // One of MemberStatus constants. Status string `json:"status"` }
ChatMember object contains information about one member of the chat.
type ChosenInlineResult ¶
type ChosenInlineResult struct { // ResultID is a unique identifier for the result that was chosen. ResultID string `json:"result_id"` // From is a user that chose the result. From User `json:"from"` // Query is used to obtain the result. Query string `json:"query"` }
ChosenInlineResult represents a result of an inline query that was chosen by the user and sent to their chat partner
type Contact ¶
type Contact struct { PhoneNumber string `json:"phone_number"` FirstName string `json:"first_name"` // UserID is a contact's user identifier in Telegram. Optional. UserID int64 `json:"user_id,omitempty"` LastName string `json:"last_name,omitempty"` }
Contact object represents a phone contact of Telegram user
type ContactCfg ¶
type ContactCfg struct { BaseMessage Contact }
ContactCfg contains information about a SendContact request. Use it to send information about a venue Implements Messenger interface.
type Document ¶
type Document struct { MetaFile // Document thumbnail as defined by sender. Optional. Thumb *PhotoSize `json:"thumb,omitempty"` // Original filename as defined by sender. Optional. FileName string `json:"file_name,omitempty"` // MIMEType of the file as defined by sender. Optional. MIMEType string `json:"mime_type,omitempty"` }
Document object represents a general file (as opposed to Photo or Audio). Telegram users can send files of any type of up to 1.5 GB in size.
type DocumentCfg ¶
type DocumentCfg struct {
BaseFile
}
DocumentCfg contains information about a SendDocument request. Use it to send information about a documents Implements Filer and Messenger interfaces.
func (DocumentCfg) Field ¶
func (cfg DocumentCfg) Field() string
Field returns name for document file data
type EditMessageCaptionCfg ¶
EditMessageCaptionCfg allows you to modify the caption of a message.
func NewEditMessageCaption ¶
func NewEditMessageCaption(chatID, messageID int64, caption string) EditMessageCaptionCfg
NewEditMessageCaption allows you to edit the caption of a message.
func (EditMessageCaptionCfg) Name ¶
func (EditMessageCaptionCfg) Name() string
Name returns method name
type EditMessageReplyMarkupCfg ¶
type EditMessageReplyMarkupCfg struct {
BaseEdit
}
EditMessageReplyMarkupCfg allows you to modify the reply markup of a message.
func NewEditMessageReplyMarkup ¶
func NewEditMessageReplyMarkup(chatID, messageID int64, replyMarkup *InlineKeyboardMarkup) EditMessageReplyMarkupCfg
NewEditMessageReplyMarkup allows you to edit the inline keyboard markup.
func (EditMessageReplyMarkupCfg) Name ¶
func (EditMessageReplyMarkupCfg) Name() string
Name returns method name
type EditMessageTextCfg ¶
type EditMessageTextCfg struct { BaseEdit // New text of the message Text string // Send Markdown or HTML, if you want Telegram apps // to show bold, italic, fixed-width text // or inline URLs in your bot's message. Optional. ParseMode string // Disables link previews for links in this message. Optional. DisableWebPagePreview bool }
EditMessageTextCfg allows you to modify the text in a message.
func NewEditMessageText ¶
func NewEditMessageText(chatID, messageID int64, text string) EditMessageTextCfg
NewEditMessageText allows you to edit the text of a message.
type EditResult ¶
EditResult is an option type, because telegram may return bool or Message
func (*EditResult) UnmarshalJSON ¶
func (e *EditResult) UnmarshalJSON(data []byte) error
UnmarshalJSON helps to parse EditResult. On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
type File ¶
type File struct { MetaFile // FilePath is a relative path to file. // Use https://api.telegram.org/file/bot<token>/<file_path> // to get the file. FilePath string `json:"file_path,omitempty"` // Link is inserted by Api client after GetFile request Link string `json:"link"` }
File object represents any sort of file. The file can be downloaded via the Link. It is guaranteed that the link will be valid for at least 1 hour. When the link expires, a new one can be requested by calling GetFile. Maximum file size to download is 20 MB.
type FileCfg ¶
type FileCfg struct {
FileID string
}
FileCfg has information about a file hosted on Telegram.
type Filer ¶
type Filer interface { // Field name for file data Field() string // File data File() InputFile // Exist returns true if file exists on telegram servers Exist() bool // Reset removes FileID and sets new InputFile // Reset(InputFile) // GetFileID returns fileID if it's exist GetFileID() string }
Filer is any config type that can be sent that includes a file.
type ForceReply ¶
type ForceReply struct { MarkReplyMarkup ForceReply bool `json:"force_reply"` Selective bool `json:"selective"` // optional }
ForceReply allows the Bot to have users directly reply to it without additional interaction. Implements ReplyMarkup interface.
type ForwardMessageCfg ¶
type ForwardMessageCfg struct { BaseChat // Unique identifier for the chat where the original message was sent FromChat BaseChat // Unique message identifier MessageID int64 // Sends the message silently. // iOS users will not receive a notification, // Android users will receive a notification with no sound. // Other apps coming soon. DisableNotification bool }
ForwardMessageCfg contains information about a ForwardMessage request. Use it to forward messages of any kind Implements Messenger interface.
func NewForwardMessage ¶
func NewForwardMessage(chatID, fromChatID, messageID int64) ForwardMessageCfg
NewForwardMessage creates a new Message.
chatID is where to send it, text is the message text.
func (ForwardMessageCfg) Message ¶
func (ForwardMessageCfg) Message() *Message
Message returns instance of *Message type.
type GetChatAdministratorsCfg ¶
type GetChatAdministratorsCfg struct {
BaseChat
}
GetChatAdministratorsCfg contains information about a getChat request.
func (GetChatAdministratorsCfg) Name ¶
func (cfg GetChatAdministratorsCfg) Name() string
Name returns method name
type GetChatCfg ¶
type GetChatCfg struct {
BaseChat
}
GetChatCfg contains information about a getChat request.
type GetChatMemberCfg ¶
GetChatMemberCfg contains information about a getChatMember request.
type GetChatMembersCountCfg ¶
type GetChatMembersCountCfg struct {
BaseChat
}
GetChatMembersCountCfg contains information about a getChatMemberCount request.
func (GetChatMembersCountCfg) Name ¶
func (cfg GetChatMembersCountCfg) Name() string
Name returns method name
type InlineKeyboardButton ¶
type InlineKeyboardButton struct { // Label text on the button Text string `json:"text"` // HTTP url to be opened when button is pressed. Optional. URL string `json:"url,omitempty"` // Data to be sent in a callback query to the bot // when button is pressed. Optional. CallbackData string `json:"callback_data,omitempty"` // If set, pressing the button will prompt the user // to select one of their chats, open that chat // and insert the bot‘s username and the specified inline query // in the input field. Can be empty, // in which case just the bot’s username will be inserted. // Optional. // // Note: This offers an easy way for users // to start using your bot in inline mode // when they are currently in a private chat with it. // Especially useful when combined with switch_pm... actions // – in this case the user will be automatically returned to the chat // they switched from, skipping the chat selection screen. SwitchInlineQuery string `json:"switch_inline_query,omitempty"` }
InlineKeyboardButton object represents one button of an inline keyboard. You must use exactly one of the optional fields.
Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct { MarkReplyMarkup InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"` }
InlineKeyboardMarkup object represents an inline keyboard that appears right next to the message it belongs to.
Warning: Inline keyboards are currently being tested and are only available in one‐on‐one chats (i.e., user‐bot or user‐user in the case of inline bots). Note: This will only work in Telegram versions released after 9 April, 2016. Older clients will display unsupported message.
type InlineQuery ¶
type InlineQuery struct { // ID is a unique identifier for this query. ID string `json:"id"` // From is a sender. From User `json:"from"` // Sender location, only for bots that request user location. // Optional. Location *Location `json:"location,omitempty"` // Query is a text of the query. Query string `json:"query"` // Offset of the results to be returned, can be controlled by the bot. Offset string `json:"offset"` }
InlineQuery is an incoming inline query. When the user sends an empty query, your bot could return some default or trending results.
type InlineQueryResult ¶
type InlineQueryResult interface {
// InlineQueryResult is a fake method that helps to identify implementations
InlineQueryResult()
}
InlineQueryResult interface represents one result of an inline query. Telegram clients currently support results of the following 19 types:
- InlineQueryResultCachedAudio - InlineQueryResultCachedDocument - InlineQueryResultCachedGif - InlineQueryResultCachedMpeg4Gif - InlineQueryResultCachedPhoto - InlineQueryResultCachedSticker - InlineQueryResultCachedVideo - InlineQueryResultCachedVoice - InlineQueryResultArticle - InlineQueryResultAudio - InlineQueryResultContact - InlineQueryResultDocument - InlineQueryResultGif - InlineQueryResultLocation - InlineQueryResultMpeg4Gif - InlineQueryResultPhoto - InlineQueryResultVenue - InlineQueryResultVideo - InlineQueryResultVoice
type InlineQueryResultArticle ¶
type InlineQueryResultArticle struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb Title string `json:"title"` // required URL string `json:"url,omitempty"` // Optional. Pass True, if you don't want the URL // to be shown in the message HideURL bool `json:"hide_url,omitempty"` Description string `json:"description,omitempty"` }
InlineQueryResultArticle is an inline query response article.
func NewInlineQueryResultArticle ¶
func NewInlineQueryResultArticle(id, title, messageText string) *InlineQueryResultArticle
NewInlineQueryResultArticle creates a new inline query article.
type InlineQueryResultAudio ¶
type InlineQueryResultAudio struct { MarkInlineQueryResult BaseInlineQueryResult AudioURL string `json:"audio_url"` // required Title string `json:"title"` // required Performer string `json:"performer"` AudioDuration int `json:"audio_duration"` }
InlineQueryResultAudio is an inline query response audio.
type InlineQueryResultContact ¶
type InlineQueryResultContact struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb Contact }
InlineQueryResultContact represents a contact with a phone number. By default, this contact will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the contact.
type InlineQueryResultDocument ¶
type InlineQueryResultDocument struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb DocumentURL string `json:"document_url"` // required // Mime type of the content of the file, // either “application/pdf” or “application/zip” MimeType string `json:"mime_type"` // required // Title for the result Title string `json:"title"` // required // Optional. Caption of the document to be sent, 0-200 characters Caption string `json:"caption,omitempty"` // Optional. Short description of the result Description string `json:"description,omitempty"` }
InlineQueryResultDocument is an inline query response document.
type InlineQueryResultGIF ¶
type InlineQueryResultGIF struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb // A valid URL for the GIF file. File size must not exceed 1MB GifURL string `json:"gif_url"` // required GifWidth int `json:"gif_width,omitempty"` GifHeight int `json:"gif_height,omitempty"` Title string `json:"title,omitempty"` Caption string `json:"caption,omitempty"` }
InlineQueryResultGIF is an inline query response GIF.
type InlineQueryResultLocation ¶
type InlineQueryResultLocation struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb Latitude float64 `json:"latitude"` // required Longitude float64 `json:"longitude"` // required Title string `json:"title"` // required }
InlineQueryResultLocation is an inline query response location.
type InlineQueryResultMPEG4GIF ¶
type InlineQueryResultMPEG4GIF struct { MarkInlineQueryResult BaseInlineQueryResult MPEG4URL string `json:"mpeg4_url"` // required MPEG4Width int `json:"mpeg4_width,omitempty"` MPEG4Height int `json:"mpeg4_height,omitempty"` Title string `json:"title,omitempty"` Caption string `json:"caption,omitempty"` }
InlineQueryResultMPEG4GIF is an inline query response MPEG4 GIF.
type InlineQueryResultPhoto ¶
type InlineQueryResultPhoto struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb PhotoURL string `json:"photo_url"` // required PhotoWidth int `json:"photo_width,omitempty"` PhotoHeight int `json:"photo_height,omitempty"` MimeType string `json:"mime_type,omitempty"` Title string `json:"title,omitempty"` Description string `json:"description,omitempty"` Caption string `json:"caption,omitempty"` }
InlineQueryResultPhoto is an inline query response photo.
type InlineQueryResultVenue ¶
type InlineQueryResultVenue struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb Venue }
InlineQueryResultVenue represents a venue. By default, the venue will be sent by the user. Alternatively, you can use input_message_content to send a message with the specified content instead of the venue.
type InlineQueryResultVideo ¶
type InlineQueryResultVideo struct { MarkInlineQueryResult BaseInlineQueryResult InlineThumb VideoURL string `json:"video_url"` // required MimeType string `json:"mime_type"` // required Title string `json:"title,omitempty"` Caption string `json:"caption,omitempty"` VideoWidth int `json:"video_width,omitempty"` VideoHeight int `json:"video_height,omitempty"` VideoDuration int `json:"video_duration,omitempty"` Description string `json:"description,omitempty"` }
InlineQueryResultVideo is an inline query response video.
type InlineQueryResultVoice ¶
type InlineQueryResultVoice struct { MarkInlineQueryResult BaseInlineQueryResult VoiceURL string `json:"voice_url"` // required Title string `json:"title"` // required Duration int `json:"voice_duration,omitempty"` }
InlineQueryResultVoice is an inline query response voice.
type InlineThumb ¶
type InlineThumb struct { ThumbURL string `json:"thumb_url,omitempty"` ThumbWidth int `json:"thumb_width,omitempty"` ThumbHeight int `json:"thumb_height,omitempty"` }
InlineThumb struct helps to describe thumbnail.
type InputContactMessageContent ¶
type InputContactMessageContent struct { MarkInputMessageContent Contact }
InputContactMessageContent contains a contact for displaying as an inline query result. Implements InputMessageContent
type InputFile ¶
InputFile describes interface for input files.
func NewBytesFile ¶
NewBytesFile takes byte slice and returns InputFile.
type InputLocationMessageContent ¶
type InputLocationMessageContent struct { MarkInputMessageContent Location }
InputLocationMessageContent contains a location for displaying as an inline query result. Implements InputMessageContent
type InputMessageContent ¶
type InputMessageContent interface {
// MessageContent is a fake method that helps to identify implementations
InputMessageContent()
}
InputMessageContent interface represents the content of a message to be sent as a result of an inline query. Telegram clients currently support the following 4 types:
- InputTextMessageContent
- InputLocationMessageContent
- InputVenueMessageContent
- InputContactMessageContent
type InputTextMessageContent ¶
type InputTextMessageContent struct { MarkInputMessageContent // Text of the message to be sent, 1‐4096 characters MessageText string `json:"message_text"` // Send Markdown or HTML, if you want Telegram apps to show // bold, italic, fixed‐width text or inline URLs in your bot's message. // Use Mode constants. Optional. ParseMode string `json:"parse_mode,omitempty"` // Disables link previews for links in this message. DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"` }
InputTextMessageContent represents the content of a text message to be sent as the result of an inline query.
type InputVenueMessageContent ¶
type InputVenueMessageContent struct { MarkInputMessageContent Venue }
InputVenueMessageContent contains a venue for displaying as an inline query result. Implements InputMessageContent
type KeyboardButton ¶
type KeyboardButton struct { // Text of the button. If none of the optional fields are used, // it will be sent to the bot as a message when the button is pressed Text string `json:"text"` // If true, the user's phone number will be sent as a contact // when the button is pressed. Available in private chats only. // Optional. RequestContact bool `json:"request_contact,omitempty"` // If true, the user's current location will be sent // when the button is pressed. Available in private chats only. // Optional. RequestLocation bool `json:"request_location,omitempty"` }
KeyboardButton object represents one button of the reply keyboard. Optional fields are mutually exclusive.
Note: request_contact and request_location options will only work in Telegram versions released after 9 April, 2016. Older clients will ignore them.
type KickChatMemberCfg ¶
KickChatMemberCfg contains information about a kickChatMember request.
type LeaveChatCfg ¶
type LeaveChatCfg struct {
BaseChat
}
LeaveChatCfg contains information about a leaveChat request.
type Location ¶
type Location struct { // Longitude as defined by sender Longitude float64 `json:"longitude"` // Latitude as defined by sender Latitude float64 `json:"latitude"` }
Location object represents geographic position.
type LocationCfg ¶
type LocationCfg struct { BaseMessage Location }
LocationCfg contains information about a SendLocation request.
func NewLocation ¶
func NewLocation(chatID int64, lat float64, lon float64) LocationCfg
NewLocation shares your location.
chatID is where to send it, latitude and longitude are coordinates.
func (LocationCfg) Name ¶
func (cfg LocationCfg) Name() string
Name method returns Telegram API method name for sending Location.
type MarkInlineQueryResult ¶
type MarkInlineQueryResult struct{}
A MarkInlineQueryResult implements InlineQueryResult interface. You can mark your structures with this object.
func (MarkInlineQueryResult) InlineQueryResult ¶
func (MarkInlineQueryResult) InlineQueryResult()
InlineQueryResult is a fake method that helps to identify implementations
type MarkInputMessageContent ¶
type MarkInputMessageContent struct{}
A MarkInputMessageContent implements InputMessageContent interface. You can mark your structures with this object.
func (MarkInputMessageContent) InputMessageContent ¶
func (MarkInputMessageContent) InputMessageContent()
InputMessageContent is a fake method that helps to identify implementations
type MarkReplyMarkup ¶
type MarkReplyMarkup struct{}
A MarkReplyMarkup implements ReplyMarkup interface. You can mark your structures with this object.
func (MarkReplyMarkup) ReplyMarkup ¶
func (MarkReplyMarkup) ReplyMarkup()
ReplyMarkup is a fake method that helps to identify implementations
type Message ¶
type Message struct { // MessageID is a unique message identifier. MessageID int64 `json:"message_id"` // From is a sender, can be empty for messages sent to channels. // Optional. From *User `json:"from,omitempty"` // Date the message was sent in Unix time. Date int `json:"date"` // Chat is a conversation the message belongs to. Chat Chat `json:"chat"` // ForwardFrom is a sender of the original message // for forwarded messages. Optional. ForwardFrom *User `json:"forward_from,omitempty"` // For messages forwarded from a channel, // information about the original channel. Optional. ForwardFromChat *Chat `json:"forward_from_chat,omitempty"` // ForwardDate is a unixtime of the original message // for forwarded messages. Optional. ForwardDate int `json:"forward_date"` // ReplyToMessage is an original message for replies. // Note that the Message object in this field will not // contain further ReplyToMessage fields even if it // itself is a reply. Optional. ReplyToMessage *Message `json:"reply_to_message,omitempty"` // Date the message was last edited in Unix time // Zero value means object wasn't edited. // Optional. EditDate int `json:"edit_date,omitempty"` // For text messages, special entities like usernames, // URLs, bot commands, etc. that appear in the text. Optional Entities []MessageEntity `json:"entities"` // Text is an actual UTF-8 text of the message for a text message, // 0-4096 characters. Optional. Text string `json:"text,omitempty"` // Audio has information about the audio file. Optional. Audio *Audio `json:"audio,omitempty"` // Document has information about a general file. Optional. Document *Document `json:"document,omitempty"` // Photo has a slice of available sizes of photo. Optional. Photo []PhotoSize `json:"photo,omitempty"` // Sticker has information about the sticker. Optional. Sticker *Sticker `json:"sticker,omitempty"` // For a video, information about it. Video *Video `json:"video,omitempty"` // Message is a voice message, information about the file Voice *Voice `json:"voice,omitempty"` // Caption for the document, photo or video, 0‐200 characters Caption string `json:"caption,omitempty"` // For a contact, contact information itself. Contact *Contact `json:"contact,omitempty"` // For a location, its longitude and latitude. Location *Location `json:"location,omitempty"` // Message is a venue, information about the venue Venue *Venue `json:"venue,omitempty"` // NewChatMember has an information about a new member // that was added to the group // (this member may be the bot itself). Optional. NewChatMember *User `json:"new_chat_member,omitempty"` // LeftChatMember has an information about a member // that was removed from the group // (this member may be the bot itself). Optional. LeftChatMember *User `json:"left_chat_member,omitempty"` // For a service message, represents a new title // for chat this message came from. // // Sender would lead to a User, capable of change. NewChatTitle string `json:"new_chat_title,omitempty"` // For a service message, represents all available // thumbnails of new chat photo. // // Sender would lead to a User, capable of change. NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"` // For a service message, true if chat photo just // got removed. // // Sender would lead to a User, capable of change. DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"` // For a service message, true if group has been created. // // You would receive such a message if you are one of // initial group chat members. // // Sender would lead to creator of the chat. GroupChatCreated bool `json:"group_chat_created,omitempty"` // For a service message, true if super group has been created. // // You would receive such a message if you are one of // initial group chat members. // // Sender would lead to creator of the chat. SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"` // For a service message, true if channel has been created. // // You would receive such a message if you are one of // initial channel administrators. // // Sender would lead to creator of the chat. ChannelChatCreated bool `json:"channel_chat_created,omitempty"` // For a service message, the destination (super group) you // migrated to. // // You would receive such a message when your chat has migrated // to a super group. // // Sender would lead to creator of the migration. MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // For a service message, the Origin (normal group) you migrated // from. // // You would receive such a message when your chat has migrated // to a super group. // // Sender would lead to creator of the migration. MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"` // Specified message was pinned. // Note that the Message object in this field // will not contain further reply_to_message fields // even if it is itself a reply. PinnedMessage *Message `json:"pinned_message,omitempty"` }
Message object represents a message.
type MessageCfg ¶
type MessageCfg struct { BaseMessage Text string // Send Markdown or HTML, if you want Telegram apps to show // bold, italic, fixed-width text or inline URLs in your bot's message. // Use one of constants: ModeHTML, ModeMarkdown. ParseMode string // Disables link previews for links in this message. DisableWebPagePreview bool }
MessageCfg contains information about a SendMessage request. Use it to send text messages. Implements Messenger interface.
func NewMessage ¶
func NewMessage(chatID int64, text string) MessageCfg
NewMessage creates a new Message.
chatID is where to send it, text is the message text.
func NewMessagef ¶
func NewMessagef(chatID int64, text string, args ...interface{}) MessageCfg
NewMessagef creates a new Message with formatting.
chatID is where to send it, text is the message text
type MessageEntity ¶
type MessageEntity struct { // Type of the entity. One of mention ( @username ), hashtag, // bot_command, url, email, bold (bold text), // italic (italic text), code (monowidth string), // pre (monowidth block), text_link (for clickable text URLs), // text_mention (for users without usernames) // Use constants SomethingEntityType instead of string. Type string `json:"type"` // Offset in UTF‐16 code units to the start of the entity Offset int `json:"offset"` // Length of the entity in UTF‐16 code units Length int `json:"length"` // For “text_link” only, url that will be opened // after user taps on the text. Optional URL string `json:"url,omitempty"` // For “text_mention” only, the mentioned user. Optional. User *User `json:"user,omitempty"` }
MessageEntity object represents one special entity in a text message. For example, hashtags, usernames, URLs, etc.
type Messenger ¶
Messenger is a virtual interface to distinct methods that return Message from others.BaseMessage
func CloneMessage ¶
func CloneMessage(msg *Message, baseMessage *BaseMessage) Messenger
CloneMessage convert message to Messenger type to send it to another chat. It supports only data message: Text, Sticker, Audio, Photo, Location, Contact, Audio, Voice, Document.
type MetaFile ¶
type MetaFile struct { // FileID is a Unique identifier for this file. FileID string `json:"file_id"` // FileSize is a size of file if known. Optional. FileSize int `json:"file_size,omitempty"` }
MetaFile represents meta information about file.
type Method ¶
type Method interface { // method name Name() string // method params Values() (url.Values, error) }
Method describes interface for Telegram API request
Every method is https://api.telegram.org/bot<token>/METHOD_NAME Values are passed as application/x-www-form-urlencoded for usual request and multipart/form-data when files are uploaded.
type PhotoCfg ¶
PhotoCfg contains information about a SendPhoto request. Use it to send information about a venue Implements Filer and Messenger interfaces.
func NewPhotoUpload ¶
NewPhotoUpload creates a new photo uploader.
chatID is where to send it, inputFile is a file representation.
type ReplyKeyboardHide ¶
type ReplyKeyboardHide struct { MarkReplyMarkup HideKeyboard bool `json:"hide_keyboard"` Selective bool `json:"selective"` // optional }
ReplyKeyboardHide tells Telegram clients to hide the current custom keyboard and display the default letter-keyboard. Implements ReplyMarkup interface.
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct { MarkReplyMarkup // Array of button rows, each represented by an Array of Strings Keyboard [][]KeyboardButton `json:"keyboard"` // Requests clients to resize the keyboard vertically // for optimal fit (e.g., make the keyboard smaller // if there are just two rows of buttons). // Defaults to false, in which case the custom keyboard // is always of the same height as the app's standard keyboard. ResizeKeyboard bool `json:"resize_keyboard,omitempty"` // Requests clients to hide the keyboard as soon as it's been used. // The keyboard will still be available, // but clients will automatically display the usual // letter‐keyboard in the chat – the user can press // a special button in the input field to see the custom keyboard again. // Defaults to false. OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"` // Use this parameter if you want to show the keyboard // to specific users only. // Targets: // 1) users that are @mentioned in the text of the Message object; // 2) if the bot's message is a reply (has reply_to_message_id), // sender of the original message. Selective bool `json:"selective,omitempty"` }
ReplyKeyboardMarkup represents a custom keyboard with reply options. Implements ReplyMarkup interface.
type ReplyMarkup ¶
type ReplyMarkup interface {
// ReplyMarkup is a fake method that helps to identify implementations
ReplyMarkup()
}
ReplyMarkup describes interface for reply_markup keyboards.
type RequiredError ¶
type RequiredError struct {
Fields []string
}
RequiredError tells if fields are required but were not filled
func NewRequiredError ¶
func NewRequiredError(fields ...string) *RequiredError
NewRequiredError creates RequireError
func (*RequiredError) Error ¶
func (e *RequiredError) Error() string
Error returns string representation for RequiredError
type Sticker ¶
type Sticker struct { MetaFile Size // Sticker width and height // Sticker thumbnail in .webp or .jpg format. Optional. Thumb *PhotoSize `json:"thumb,omitempty"` // Emoji associated with the sticker. Optional. Emoji string `json:"emoji,omitempty"` }
Sticker object represents a WebP image, so-called sticker.
type StickerCfg ¶
type StickerCfg struct {
BaseFile
}
StickerCfg contains information about a SendSticker request. Implements Filer and Messenger interfaces.
func (StickerCfg) Field ¶
func (cfg StickerCfg) Field() string
Field returns name for sticker file data
func (StickerCfg) Name ¶
func (cfg StickerCfg) Name() string
Name method returns Telegram API method name for sending Sticker.
type UnbanChatMemberCfg ¶
UnbanChatMemberCfg contains information about a unbanChatMember request.
func (UnbanChatMemberCfg) Name ¶
func (cfg UnbanChatMemberCfg) Name() string
Name returns method name
type Update ¶
type Update struct { // UpdateID is the update‘s unique identifier. // Update identifiers start from a certain positive number // and increase sequentially UpdateID int64 `json:"update_id"` // Message is a new incoming message of any kind: // text, photo, sticker, etc. Optional. Message *Message `json:"message,omitempty"` // New version of a message that is known to the bot and was edited. // Optional. EditedMessage *Message `json:"edited_message,omitempty"` // InlineQuery is a new incoming inline query. Optional. InlineQuery *InlineQuery `json:"inline_query,omitempty"` // ChosenInlineResult is a result of an inline query // that was chosen by a user and sent to their chat partner. Optional. ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"` // CallbackQuery is a new incoming callback query. Optional. CallbackQuery *CallbackQuery `json:"callback_query,omitempty"` }
Update object represents an incoming update. Only one of the optional parameters can be present in any given update
func (Update) HasMessage ¶
HasMessage returns true if update object contains Message field
type UpdateCfg ¶
type UpdateCfg struct { // Identifier of the first update to be returned. // Must be greater by one than the highest // among the identifiers of previously received updates. // By default, updates starting with the earliest // unconfirmed update are returned. An update is considered confirmed // as soon as getUpdates is called with an offset // higher than its update_id. The negative offset // can be specified to retrieve updates starting // from -offset update from the end of the updates queue. // All previous updates will forgotten. Offset int64 // Limits the number of updates to be retrieved. // Values between 1—100 are accepted. Defaults to 100. Limit int // Timeout in seconds for long polling. // Defaults to 0, i.e. usual short polling Timeout int }
UpdateCfg contains information about a getUpdates request.
func NewUpdate ¶
NewUpdate gets updates since the last Offset with Timeout 30 seconds
offset is the last Update ID to include. You likely want to set this to the last Update ID plus 1. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
type User ¶
type User struct { // ID is a unique identifier for this user or bot. ID int64 `json:"id"` // FirstName is a user‘s or bot’s first name FirstName string `json:"first_name"` // LastName is a user‘s or bot’s last name. Optional. LastName string `json:"last_name,omitempty"` // Username is a user‘s or bot’s username. Optional. Username string `json:"username,omitempty"` }
User object represents a Telegram user or bot.
object represents a group chat if Title is empty.
type UserProfilePhotos ¶
type UserProfilePhotos struct { // Total number of profile pictures the target user has TotalCount int `json:"total_count"` // Requested profile pictures (in up to 4 sizes each) Photos [][]PhotoSize `json:"photos"` }
UserProfilePhotos contains a set of user profile pictures.
type UserProfilePhotosCfg ¶
type UserProfilePhotosCfg struct { UserID int64 // Sequential number of the first photo to be returned. // By default, all photos are returned. Offset int // Limits the number of photos to be retrieved. // Values between 1—100 are accepted. Defaults to 100. Limit int }
UserProfilePhotosCfg contains information about a GetUserProfilePhotos request.
func NewUserProfilePhotos ¶
func NewUserProfilePhotos(userID int64) UserProfilePhotosCfg
NewUserProfilePhotos gets user profile photos.
userID is the ID of the user you wish to get profile photos from.
func (UserProfilePhotosCfg) Name ¶
func (cfg UserProfilePhotosCfg) Name() string
Name returns method name
type ValidationError ¶
type ValidationError struct { // Field name Field string `json:"field"` Description string `json:"description"` }
ValidationError tells if field has wrong value
func NewValidationError ¶
func NewValidationError(field string, description string) *ValidationError
NewValidationError creates ValidationError
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string
Error returns string representation for ValidationError
type Venue ¶
type Venue struct { // Venue location Location Location `json:"location"` // Name of the venue Title string `json:"title"` // Address of the venue Address string `json:"address"` // Foursquare identifier of the venue. Optional. FoursquareID string `json:"foursquare_id,omitempty"` }
Venue object represents a venue.
type VenueCfg ¶
type VenueCfg struct { BaseMessage Venue }
VenueCfg contains information about a SendVenue request. Use it to send information about a venue Implements Messenger interface.
type Video ¶
type Video struct { MetaFile Size // Duration of the recording in seconds as defined by sender. Duration int `json:"duration"` // MIMEType of the file as defined by sender. Optional. MIMEType string `json:"mime_type,omitempty"` // Video thumbnail. Optional. Thumb *PhotoSize `json:"thumb,omitempty"` }
Video object represents an MP4-encoded video.
type VideoCfg ¶
VideoCfg contains information about a SendVideo request. Use it to send information about a video Implements Filer and Messenger interfaces.
type Voice ¶
type Voice struct { MetaFile // Duration of the recording in seconds as defined by sender. Duration int `json:"duration"` // MIMEType of the file as defined by sender. Optional. MIMEType string `json:"mime_type,omitempty"` }
Voice object represents a voice note.
type VoiceCfg ¶
VoiceCfg contains information about a SendVoice request. Use it to send information about a venue Implements Filer and Messenger interfaces.
type WebhookCfg ¶
WebhookCfg contains information about a SetWebhook request. Implements Method and Filer interface
func NewWebhook ¶
func NewWebhook(link string) WebhookCfg
NewWebhook creates a new webhook.
link is the url parsable link you wish to get the updates.
func NewWebhookWithCert ¶
func NewWebhookWithCert(link string, file InputFile) WebhookCfg
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.
func (WebhookCfg) Exist ¶
func (cfg WebhookCfg) Exist() bool
Exist is true if we don't have a certificate to upload. It's kind of confusing.
func (WebhookCfg) Field ¶
func (cfg WebhookCfg) Field() string
Field returns name for webhook file data
func (*WebhookCfg) GetFileID ¶
func (cfg *WebhookCfg) GetFileID() string
GetFileID for webhook is always empty
func (WebhookCfg) Name ¶
func (cfg WebhookCfg) Name() string
Name method returns Telegram API method name for sending Location.
func (*WebhookCfg) Reset ¶
func (cfg *WebhookCfg) Reset(i InputFile)
Reset method sets new Certificate