Documentation ¶
Index ¶
- Constants
- Variables
- type Audio
- type AudioMessage
- type Bot
- type BotOption
- type CallbackQuery
- type CallbackQueryAnswer
- type Chat
- type ChatID
- type ChatMember
- type ChatPhoto
- type Command
- type CommandFunc
- type Commands
- type Contact
- type DeletedMessage
- type Document
- type DocumentMessage
- type Error
- type File
- type ForceReply
- type ForwardedMessage
- type InlineKeyboardButton
- type InlineKeyboardMarkup
- type InputFile
- type KeyboardButton
- type Location
- type Markup
- type MaskPosition
- type Message
- type MessageCaption
- type MessageEntity
- type MessageReplyMarkup
- type MessageText
- type Multipart
- type Multiparter
- type ParseMode
- type PhotoMessage
- type PhotoSize
- type ReplyKeyboardMarkup
- type ReplyKeyboardRemove
- type ResponseParameters
- type SOCKS5
- type Sticker
- type StickerMessage
- type StickerSet
- type TextMessage
- type Update
- type UpdatesOption
- type User
- type UserProfilePhotos
- type Venue
- type Video
- type VideoNote
- type Voice
- type WebhookInfo
Constants ¶
const ( ModeDefault ParseMode = 0 ModeMarkdown = 1 ModeHTML = 2 )
Parse modes.
Variables ¶
var ( ErrNotDeleted = errors.New("telegram: message not deleted") ErrNotEdited = errors.New("telegram: message not edited") ErrNotAnswered = errors.New("telegram: query not answered") )
var ErrEmptyToken = errors.New("telegram: empty token")
Functions ¶
This section is empty.
Types ¶
type Audio ¶
type AudioMessage ¶
type AudioMessage struct { ChatID int64 `json:"chat_id"` Audio InputFile `json:"-"` AudioID string `json:"audio"` Caption string `json:"caption,omitempty"` Duration int `json:"duration,omitempty"` Performer string `json:"performer,omitempty"` Title string `json:"title,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ReplyToMessageID int `json:"reply_to_message_id,omitempty"` ReplyMarkup Markup `json:"reply_markup,omitempty"` }
https://core.telegram.org/bots/api#sendaudio
func (*AudioMessage) Multipart ¶
func (m *AudioMessage) Multipart() *Multipart
Multipart implements Multiparter interface.
type Bot ¶
type Bot interface { Username() string Updates() <-chan *Update Errors() <-chan error GetMe(context.Context) (*User, error) GetUpdates(context.Context, ...UpdatesOption) ([]*Update, error) SendMessage(context.Context, *TextMessage) (*Message, error) ForwardMessage(context.Context, *ForwardedMessage) (*Message, error) EditMessageText(context.Context, *MessageText) (*Message, error) EditMessageCaption(context.Context, *MessageCaption) (*Message, error) EditMessageReplyMarkup(context.Context, *MessageReplyMarkup) (*Message, error) DeleteMessage(context.Context, *DeletedMessage) error }
type BotOption ¶
type BotOption func(*botOptions)
func WithErrTimeout ¶
func WithPollTimeout ¶
func WithSOCKS5 ¶ added in v0.2.0
func WithUsername ¶
func WithoutUpdates ¶
func WithoutUpdates() BotOption
type CallbackQuery ¶
type CallbackQueryAnswer ¶
type Chat ¶
type Chat struct { ID int64 `json:"id"` Type string `json:"type"` Title *string `json:"title"` Username *string `json:"username"` FirstName *string `json:"first_name"` LastName *string `json:"last_name"` AllMembersAreAdministrators *bool `json:"all_members_are_administrators"` ChatPhoto *ChatPhoto `json:"chat_photo"` Description *string `json:"description"` InviteLink *string `json:"invite_link"` }
https://core.telegram.org/bots/api#chat
func (*Chat) IsSupergroup ¶
type ChatMember ¶
type ChatMember struct { User User `json:"user"` Status string `json:"status"` UntilDate *int `json:"until_date"` // Administrators only. CanBeEdited *bool `json:"can_be_edited"` CanChangeInfo *bool `json:"can_change_info"` CanPostMessages *bool `json:"can_post_messages"` CanEditMessages *bool `json:"can_edit_messages"` CanDeleteMessages *bool `json:"can_delete_messages"` CanInviteUsers *bool `json:"can_invite_users"` CanRestrictMembers *bool `json:"can_restrict_members"` CanPinMessages *bool `json:"can_pin_messages"` CanPromoteMembers *bool `json:"can_promote_members"` CanSendMessages *bool `json:"can_send_messages"` CanSendMediaMessages *bool `json:"can_send_media_messages"` CanSendOtherMessages *bool `json:"can_send_other_messages"` CanAddWebPagePreviews *bool `json:"can_add_web_page_previews"` }
type ChatPhoto ¶
type Command ¶
Command represents a command parsed from update's message. Args is a list of words right after the command in the message.
type CommandFunc ¶
CommandFunc represents a function ran on every command. The function is ran in a separate goroutine.
type Commands ¶
type Commands interface { Add(name string, fn CommandFunc) Run(*Update) (error, bool) }
Commands is the interface of a generic commands register/runner.
func NewCommands ¶
type DeletedMessage ¶
type Document ¶
type DocumentMessage ¶
type DocumentMessage struct { ChatID int64 `json:"chat_id"` Document InputFile `json:"document"` Caption string `json:"caption,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ReplyToMessageID int `json:"reply_to_message_id,omitempty"` ReplyMarkup Markup `json:"reply_markup,omitempty"` }
https://core.telegram.org/bots/api#senddocument
func (*DocumentMessage) Multipart ¶
func (m *DocumentMessage) Multipart() *Multipart
Multipart implements Multiparter interface.
type Error ¶
type Error struct { ErrorCode int Description string Parameters *ResponseParameters }
Error represents an error returned by API. It satisfies error interface.
type File ¶
type ForceReply ¶
https://core.telegram.org/bots/api#forcereply
func (*ForceReply) MarshalJSON ¶
func (m *ForceReply) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*ForceReply) UnmarshalJSON ¶
func (m *ForceReply) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type ForwardedMessage ¶
type InlineKeyboardButton ¶
type InlineKeyboardButton struct { Text string `json:"text"` URL string `json:"url,omitempty"` CallbackData string `json:"callback_data,omitempty"` SwitchInlineQuery string `json:"switch_inline_query,omitempty"` SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"` }
type InlineKeyboardMarkup ¶
type InlineKeyboardMarkup struct {
InlineKeyboard [][]*InlineKeyboardButton `json:"inline_keyboard"`
}
https://core.telegram.org/bots/api#inlinekeyboardmarkup
func (*InlineKeyboardMarkup) MarshalJSON ¶
func (m *InlineKeyboardMarkup) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*InlineKeyboardMarkup) UnmarshalJSON ¶
func (m *InlineKeyboardMarkup) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type KeyboardButton ¶
type MaskPosition ¶
type Message ¶
type Message struct { MessageID int `json:"message_id"` From *User `json:"from"` Date int `json:"date"` Chat Chat `json:"chat"` ForwardFrom *User `json:"forward_from"` ForwardFromChat *Chat `json:"forward_from_chat"` ForwardDate *int `json:"forward_date"` ReplyToMessage *Message `json:"reply_to_message"` EditDate *int `json:"edit_date"` Text *string `json:"text"` Entities []*MessageEntity `json:"entities"` Audio *Audio `json:"audio"` Document *Document `json:"document"` // Game Photo []*PhotoSize `json:"photo"` Sticker *Sticker `json:"sticker"` Video *Video `json:"video"` Voice *Voice `json:"voice"` VideoNote *VideoNote `json:"video_note"` NewChatMembers []*User `json:"new_chat_members"` Caption *string `json:"caption"` Contact *Contact `json:"contact"` Location *Location `json:"location"` Venue *Venue `json:"venue"` NewChatMember *User `json:"new_chat_member"` LeftChatMember *User `json:"left_chat_member"` NewChatTitle *string `json:"new_chat_title"` NewChatPhoto []*PhotoSize `json:"new_chat_photo"` DeleteChatPhoto *bool `json:"delete_chat_photo"` GroupChatCreated *bool `json:"group_chat_created"` SupergroupChatCreated *bool `json:"supergroup_chat_created"` ChannelChatCreated *bool `json:"channel_chat_created"` MigrateToChatID *int64 `json:"migrate_to_chat_id"` MigrateFromChatID *int64 `json:"migrate_from_chat_id"` PinnedMessage *Message `json:"pinned_message"` }
type MessageCaption ¶
type MessageCaption struct { ChatID int64 `json:"chat_id,omitempty"` MessageID int `json:"message_id,omitempty"` InlineMessageID int `json:"inline_message_id,omitempty"` Caption string `json:"caption,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` }
type MessageEntity ¶
type MessageEntity struct { Type string `json:"type"` Offset int `json:"offset"` Length int `json:"length"` URL *string `json:"url"` User *User `json:"user"` }
https://core.telegram.org/bots/api#messageentity
func (*MessageEntity) IsBotCommand ¶
func (e *MessageEntity) IsBotCommand() bool
func (*MessageEntity) IsEmail ¶
func (e *MessageEntity) IsEmail() bool
func (*MessageEntity) IsHashtag ¶
func (e *MessageEntity) IsHashtag() bool
func (*MessageEntity) IsMention ¶
func (e *MessageEntity) IsMention() bool
func (*MessageEntity) IsURL ¶
func (e *MessageEntity) IsURL() bool
type MessageReplyMarkup ¶
type MessageReplyMarkup struct { ChatID int64 `json:"chat_id,omitempty"` MessageID int `json:"message_id,omitempty"` InlineMessageID int `json:"inline_message_id,omitempty"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` }
type MessageText ¶
type MessageText struct { ChatID int64 `json:"chat_id,omitempty"` MessageID int `json:"message_id,omitempty"` InlineMessageID int `json:"inline_message_id,omitempty"` Text string `json:"text"` ParseMode ParseMode `json:"parse_mode"` DisableWebPagePreview bool `json:"disable_web_page_preview"` ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"` }
type Multiparter ¶
type Multiparter interface {
Multipart() *Multipart
}
Multiparter is an interface for messages that may be converted to a multipart form (e.g. photo, document, video). *Multipart may be nil meaning unavailable conversion.
type ParseMode ¶
type ParseMode int
func (ParseMode) MarshalJSON ¶
MarshalJSON implements json.Marshaler interface.
type PhotoMessage ¶
type PhotoMessage struct { ChatID int64 `json:"chat_id"` Photo InputFile `json:"-"` PhotoID string `json:"photo,omitempty"` Caption string `json:"caption,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ReplyToMessageID int `json:"reply_to_message_id,omitempty"` }
https://core.telegram.org/bots/api#sendphoto
func (*PhotoMessage) Multipart ¶
func (m *PhotoMessage) Multipart() *Multipart
Multipart implements Multiparter interface.
type PhotoSize ¶
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct { Keyboard [][]*KeyboardButton `json:"keyboard"` ResizeKeyboard bool `json:"resize_keyboard,omitempty"` OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"` Selective bool `json:"selective,omitempty"` }
https://core.telegram.org/bots/api#replykeyboardmarkup
func (*ReplyKeyboardMarkup) MarshalJSON ¶
func (m *ReplyKeyboardMarkup) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*ReplyKeyboardMarkup) UnmarshalJSON ¶
func (m *ReplyKeyboardMarkup) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type ReplyKeyboardRemove ¶
type ReplyKeyboardRemove struct { RemoveKeyboard bool `json:"remove_keyboard,omitempty"` Selective bool `json:"selective,omitempty"` }
https://core.telegram.org/bots/api#replykeyboardremove
func (*ReplyKeyboardRemove) MarshalJSON ¶
func (m *ReplyKeyboardRemove) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler interface.
func (*ReplyKeyboardRemove) UnmarshalJSON ¶
func (m *ReplyKeyboardRemove) UnmarshalJSON(b []byte) error
UnmarshalJSON implements json.Unmarshaler interface.
type ResponseParameters ¶
type Sticker ¶
type StickerMessage ¶
type StickerSet ¶
type TextMessage ¶
type TextMessage struct { ChatID int64 `json:"chat_id"` Text string `json:"text"` ParseMode ParseMode `json:"parse_mode,omitempty"` DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"` DisableNotification bool `json:"disable_notification,omitempty"` ReplyToMessageID int `json:"reply_to_message_id,omitempty"` ReplyMarkup Markup `json:"reply_markup,omitempty"` }
type Update ¶
type Update struct { UpdateID int `json:"update_id"` Message *Message `json:"message"` EditedMessage *Message `json:"edited_message"` ChannelPost *Message `json:"channel_post"` EditedChannelPost *Message `json:"edited_channel_post"` // InlineQuery // ChosenInlineResult CallbackQuery *CallbackQuery `json:"callback_query"` }
type UpdatesOption ¶
type UpdatesOption func(*updatesOptions)
func WithLimit ¶
func WithLimit(limit int) UpdatesOption
WithLimit modifies updates request to limit the number of updates in response.
func WithOffset ¶
func WithOffset(offset int) UpdatesOption
WithOffset sets id of the first expected update in response. Usually offset should equal last update's id + 1.
func WithTimeout ¶
func WithTimeout(t time.Duration) UpdatesOption
WithTimeout modifies timeout of updates request. 0 duration means short polling (for testing only).
type User ¶
type UserProfilePhotos ¶
type Venue ¶
type Video ¶
type VideoNote ¶
type Voice ¶
type WebhookInfo ¶
type WebhookInfo struct { URL string `json:"url"` HasCustomCertificate bool `json:"has_custom_certificate"` PendingUpdateCount int `json:"pending_update_count"` LastErrorDate int `json:"last_error_date"` LastErrorMessage string `json:"last_error_message"` MaxConnections int `json:"max_connections"` AllowedUpdates []string `json:"allowed_updates"` }