Documentation
¶
Index ¶
- Constants
- Variables
- type Animation
- type Attachment
- type Audio
- type Bot
- func (b *Bot) AnswerCallbackQuery(ctx context.Context, callbackQueryID, text string) error
- func (b *Bot) EditMessage(ctx context.Context, chatID, messageID int64, text string, ...) (*Message, error)
- func (b *Bot) GetFile(ctx context.Context, fileID string) (*File, error)
- func (b *Bot) GetUpdates(ctx context.Context, offset int64) ([]Update, error)
- func (b *Bot) SendMessage(ctx context.Context, chatID int64, text string) (*Message, error)
- func (b *Bot) SendReplyMessage(ctx context.Context, chatID, replyID int64, text string) (*Message, error)
- func (b *Bot) Start(ctx context.Context)
- type CallbackQuery
- type Chat
- type ChatType
- type Document
- type File
- type Handler
- type InlineKeyboardButton
- type Message
- type MessageEntity
- type MessageEntityType
- type PhotoSize
- type Update
- type User
- type Video
- type VideoNote
- type Voice
Constants ¶
const ( Private = "private" Group = "group" SuperGroup = "supergroup" Channel = "channel" )
const ( Mention = "mention" // “mention” (@username) Hashtag = "hashtag" // “hashtag” (#hashtag) CashTag = "cashtag" // “cashtag” ($USD) BotCommand = "bot_command" // “bot_command” (/start@jobs_bot) URL = "url" // “url” (https://telegram.org) Email = "email" // “email” (do-not-reply@telegram.org) PhoneNumber = "phone_number" // “phone_number” (+1-212-555-0123) Bold = "bold" // “bold” (bold text) Italic = "italic" // “italic” (italic text) Underline = "underline" // “underline” (underlined text) Strikethrough = "strikethrough" // “strikethrough” (strikethrough text) Code = "code" // “code” (monowidth string) Pre = "pre" // “pre” (monowidth block) TextLink = "text_link" // “text_link” (for clickable text URLs) TextMention = "text_mention" // “text_mention” (for users without usernames) )
Variables ¶
var ErrInvalidToken = errors.New("token is invalid")
Functions ¶
This section is empty.
Types ¶
type Animation ¶ added in v0.14.0
type Animation struct { FileID string `json:"file_id"` // FileID is the identifier for this file, which can be used to download or reuse the file FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. Width int `json:"width"` // Width video width as defined by sender Height int `json:"height"` // Height video height as defined by sender Duration int `json:"duration"` // Duration of the video in seconds as defined by sender Thumbnail *PhotoSize `json:"thumb"` // Thumbnail animation thumbnail as defined by sender FileName string `json:"file_name"` // FileName original animation filename as defined by sender MimeType string `json:"mime_type"` // MimeType of the file as defined by sender FileSize int `json:"file_size"` }
Animation represents an animation file.
type Attachment ¶ added in v0.14.0
func (Attachment) GetMimeType ¶ added in v0.14.0
func (b Attachment) GetMimeType() string
type Audio ¶ added in v0.14.0
type Audio struct { FileID string `json:"file_id"` // FileID is an identifier for this file, which can be used to download or reuse the file FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. Duration int `json:"duration"` // Duration of the audio in seconds as defined by sender Performer string `json:"performer"` // Performer of the audio as defined by sender or by audio tags Title string `json:"title"` // Title of the audio as defined by sender or by audio tags FileName string `json:"file_name"` // FileName is the original filename as defined by sender MimeType string `json:"mime_type"` // MimeType of the file as defined by sender FileSize int `json:"file_size"` // FileSize file size Thumbnail *PhotoSize `json:"thumb"` // Thumbnail is the album cover to which the music file belongs }
Audio represents an audio file to be treated as music by the Telegram clients.
type Bot ¶ added in v0.13.2
type Bot struct {
// contains filtered or unexported fields
}
func NewBotWithHandler ¶ added in v0.13.2
NewBotWithHandler create a telegram bot with specified handler.
func (*Bot) AnswerCallbackQuery ¶ added in v0.13.2
AnswerCallbackQuery make an answerCallbackQuery api request.
func (*Bot) EditMessage ¶ added in v0.13.2
func (b *Bot) EditMessage(ctx context.Context, chatID, messageID int64, text string, inlineKeyboards [][]InlineKeyboardButton) (*Message, error)
EditMessage make an editMessageText api request.
func (*Bot) GetUpdates ¶ added in v0.13.2
GetUpdates make a getUpdates api request.
func (*Bot) SendMessage ¶ added in v0.15.0
SendMessage make a sendMessage api request.
type CallbackQuery ¶ added in v0.13.2
type CallbackQuery struct { ID string `json:"id"` From User `json:"from"` Message *Message `json:"message"` InlineMessageID string `json:"inline_message_id"` ChatInstance string `json:"chat_instance"` Data string `json:"data"` GameShortName string `json:"game_short_name"` }
CallbackQuery represents an incoming callback query from a callback button in an inline keyboard (PUBLIC, PROTECTED, PRIVATE).
type Chat ¶
type Chat struct { ID int64 `json:"id"` Title string `json:"title"` // Title for supergroups, channels and group chats Type ChatType `json:"type"` // Type of chat, can be either “private”, “group”, “supergroup” or “channel” FirstName string `json:"first_name"` // FirstName of the other party in a private chat LastName string `json:"last_name"` // LastName of the other party in a private chat UserName string `json:"username"` // UserName for private chats, supergroups and channels if available }
type Document ¶ added in v0.14.0
type Document struct { FileID string `json:"file_id"` // FileID is an identifier for this file, which can be used to download or reuse the file FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. Thumbnail *PhotoSize `json:"thumb"` // Thumbnail document thumbnail as defined by sender FileName string `json:"file_name"` // FileName original filename as defined by sender MimeType string `json:"mime_type"` // MimeType of the file as defined by sender FileSize int `json:"file_size"` }
Document represents a general file.
type InlineKeyboardButton ¶ added in v0.13.2
type Message ¶
type Message struct { MessageID int64 `json:"message_id"` // MessageID is a unique message identifier inside this chat From User `json:"from"` // From is a sender, empty for messages sent to channels; Date int `json:"date"` // Date of the message was sent in Unix time Text *string `json:"text"` // Text is for text messages, the actual UTF-8 text of the message, 0-4096 characters; Chat *Chat `json:"chat"` // Chat is the conversation the message belongs to ForwardFromChat *Chat `json:"forward_from_chat"` // ForwardFromChat for messages forwarded from channels, information about the original channel; ForwardFromMessageID int64 `json:"forward_from_message_id"` // ForwardFromMessageID for messages forwarded from channels, identifier of the original message in the channel; MediaGroupID *string `json:"media_group_id"` // MediaGroupID is the unique identifier of a media message group this message belongs to; Photo []PhotoSize `json:"photo"` // Photo message is a photo, available sizes of the photo; Caption *string `json:"caption"` // Caption for the animation, audio, document, photo, video or voice, 0-1024 characters; Entities []MessageEntity `json:"entities"` // Entities are for text messages, special entities like usernames, URLs, bot commands, etc. that appear in the text; CaptionEntities []MessageEntity `json:"caption_entities"` // CaptionEntities are for messages with a caption, special entities like usernames, URLs, bot commands, etc. that appear in the caption; Document *Document `json:"document"` // Document message is a general file, information about the file; Video *Video `json:"video"` // Video message is a video, information about the video; VideoNote *VideoNote `json:"video_note"` // VideoNote message is a video note, information about the video message; Voice *Voice `json:"voice"` // Voice message is a voice message, information about the file; Audio *Audio `json:"audio"` // Audio message is an audio file, information about the file; Animation *Animation `json:"animation"` // Animation message is an animation, information about the animation. For backward compatibility, when this field is set, the document field will also be set; }
func (Message) GetMaxPhotoFileID ¶
func (Message) GetMessageLink ¶ added in v0.14.0
func (Message) IsSupported ¶ added in v0.14.0
type MessageEntity ¶ added in v0.14.0
type MessageEntity struct { Type MessageEntityType `json:"type"` // Type of the entity. Offset int `json:"offset"` // Offset in UTF-16 code units to the start of the entity Length int `json:"length"` URL string `json:"url"` // URL for “text_link” only, url that will be opened after user taps on the text User *User `json:"user"` // User for “text_mention” only, the mentioned user Language string `json:"language"` // Language for “pre” only, the programming language of the entity text }
MessageEntity represents one special entity in a text message.
type MessageEntityType ¶ added in v0.14.0
type MessageEntityType string
type Update ¶
type Update struct { UpdateID int64 `json:"update_id"` Message *Message `json:"message"` CallbackQuery *CallbackQuery `json:"callback_query"` }
type Video ¶ added in v0.14.0
type Video struct { FileID string `json:"file_id"` // FileID identifier for this file, which can be used to download or reuse FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. Width int `json:"width"` // Width video width as defined by sender Height int `json:"height"` // Height video height as defined by sender Duration int `json:"duration"` // Duration of the video in seconds as defined by sender Thumbnail *PhotoSize `json:"thumb"` // Thumbnail video thumbnail FileName string `json:"file_name"` // FileName is the original filename as defined by sender MimeType string `json:"mime_type"` // MimeType of a file as defined by sender FileSize int `json:"file_size"` }
Video represents a video file.
type VideoNote ¶ added in v0.14.0
type VideoNote struct { FileID string `json:"file_id"` // FileID identifier for this file, which can be used to download or reuse the file FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. Length int `json:"length"` // Length video width and height (diameter of the video message) as defined by sender Duration int `json:"duration"` // Duration of the video in seconds as defined by sender Thumbnail *PhotoSize `json:"thumb,omitempty"` // Thumbnail video thumbnail FileSize int `json:"file_size"` }
VideoNote object represents a video message.
type Voice ¶ added in v0.14.0
type Voice struct { FileID string `json:"file_id"` // FileID identifier for this file, which can be used to download or reuse the file FileUniqueID string `json:"file_unique_id"` // FileUniqueID is the unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. Duration int `json:"duration"` // Duration of the audio in seconds as defined by sender MimeType string `json:"mime_type"` // MimeType of the file as defined by sender FileSize int `json:"file_size"` }
Voice represents a voice note.
Source Files
¶
- animation.go
- api_answer_callback_query.go
- api_edit_message.go
- api_get_file.go
- api_get_updates.go
- api_send_message.go
- attachment.go
- audio.go
- bot.go
- callback_query.go
- chat.go
- document.go
- download.go
- file.go
- handle.go
- inline_keyboard_button.go
- message.go
- message_entity.go
- photosize.go
- request.go
- update.go
- user.go
- video.go
- video_note.go
- voice.go