Documentation
¶
Overview ¶
Package maxbot implements MAX Bot API. Official documentation: https://dev.max.ru/
Index ¶
- Constants
- Variables
- func Btn(text, payload string, intent ...schemes.Intent) schemes.ButtonInterface
- func BtnApp(text, app, payload string, contactId int64) schemes.ButtonInterface
- func BtnClipboard(text, payload string) schemes.ButtonInterface
- func BtnContact(text string) schemes.ButtonInterface
- func BtnGeo(text string, quick bool) schemes.ButtonInterface
- func BtnLink(text, url string) schemes.ButtonInterface
- func BtnMsg(text string) schemes.ButtonInterface
- func Row(buttons ...schemes.ButtonInterface) []schemes.ButtonInterface
- type APIError
- type Api
- func (a *Api) GetErrors() <-chan error
- func (a *Api) GetHandler(updates chan<- schemes.UpdateInterface) http.HandlerFunc
- func (a *Api) GetUpdateHandler(updates chan<- schemes.UpdateInterface, secret string) http.HandlerFunc
- func (a *Api) GetUpdateHandlerFunc(h UpdateHandler, secret string) http.HandlerFunc
- func (a *Api) GetUpdates(ctx context.Context) <-chan schemes.UpdateInterface
- type HttpClient
- type Keyboard
- type KeyboardRow
- func (k *KeyboardRow) AddButton(b schemes.ButtonInterface) *KeyboardRow
- func (k *KeyboardRow) AddCallback(text string, intent schemes.Intent, payload string) *KeyboardRow
- func (k *KeyboardRow) AddClipboard(text, payload string) *KeyboardRow
- func (k *KeyboardRow) AddContact(text string) *KeyboardRow
- func (k *KeyboardRow) AddGeolocation(text string, quick bool) *KeyboardRow
- func (k *KeyboardRow) AddLink(text string, _ schemes.Intent, url string) *KeyboardRow
- func (k *KeyboardRow) AddMessage(text string) *KeyboardRow
- func (k *KeyboardRow) AddOpenApp(text string, app, payload string, contactId int64) *KeyboardRow
- func (k *KeyboardRow) Build() []schemes.ButtonInterface
- type Message
- func (m *Message) AddAudio(audio *schemes.UploadedInfo) *Message
- func (m *Message) AddContact(name string, contactID int64, vcfInfo string, vcfPhone string) *Message
- func (m *Message) AddFile(file *schemes.UploadedInfo) *Message
- func (m *Message) AddKeyboard(keyboard *Keyboard) *Message
- func (m *Message) AddLocation(lat float64, lon float64) *Message
- func (m *Message) AddMarkUp(user int64, from int, len int) *Message
- func (m *Message) AddPhoto(photo *schemes.PhotoTokens) *Message
- func (m *Message) AddPhotoByToken(token string) *Message
- func (m *Message) AddSticker(code string) *Message
- func (m *Message) AddVideo(video *schemes.UploadedInfo) *Message
- func (m *Message) Reply(text string, reply schemes.Message) *Message
- func (m *Message) SetChat(chatID int64) *Message
- func (m *Message) SetDisableLinkPreview(disableLinkPreview bool) *Message
- func (m *Message) SetFormat(format schemes.Format) *Message
- func (m *Message) SetNotify(notify bool) *Message
- func (m *Message) SetPhoneNumbers(phoneNumbers []string) *Message
- func (m *Message) SetReply(text, id string) *Message
- func (m *Message) SetReset(reset bool) *Message
- func (m *Message) SetText(text string) *Message
- func (m *Message) SetUser(userID int64) *Message
- type MessageResponse
- type NetworkError
- type Option
- func WithApiTimeout(timeout time.Duration) Option
- func WithBaseURL(baseURL string) Option
- func WithDebugChat(chat int64) Option
- func WithDebugMode() Option
- func WithErrorBufferSize(size int) Option
- func WithHTTPClient(httpClient HttpClient) Option
- func WithPauseTimeout(timeout time.Duration) Option
- func WithUpdateHandler(f UpdateHandler) Option
- func WithVersion(version string) Option
- type SerializationError
- type TimeoutError
- type UpdateHandler
- type UpdatesParams
Constants ¶
const ( Version = "1.2.5" SecretHeader = "X-Max-Bot-Api-Secret" )
Variables ¶
var ( ErrEmptyToken = errors.New("bot token is empty") ErrInvalidURL = errors.New("invalid API URL") )
Functions ¶
func Btn ¶ added in v1.6.15
func Btn(text, payload string, intent ...schemes.Intent) schemes.ButtonInterface
Btn creates a standard Callback button. Optionally, you can pass schemes.Intent (default is schemes.DEFAULT).
func BtnApp ¶ added in v1.6.15
func BtnApp(text, app, payload string, contactId int64) schemes.ButtonInterface
BtnApp creates a button to open the Web App.
func BtnClipboard ¶ added in v1.6.15
func BtnClipboard(text, payload string) schemes.ButtonInterface
BtnClipboard creates a button to copy to the clipboard.
func BtnContact ¶ added in v1.6.15
func BtnContact(text string) schemes.ButtonInterface
BtnContact creates a contact request button.
func BtnGeo ¶ added in v1.6.15
func BtnGeo(text string, quick bool) schemes.ButtonInterface
BtnGeo creates a location request button.
func BtnLink ¶ added in v1.6.15
func BtnLink(text, url string) schemes.ButtonInterface
BtnLink creates a link button.
func BtnMsg ¶ added in v1.6.15
func BtnMsg(text string) schemes.ButtonInterface
BtnMsg creates a button to send text on behalf of the user.
func Row ¶ added in v1.6.15
func Row(buttons ...schemes.ButtonInterface) []schemes.ButtonInterface
Row creates one line of buttons.
Types ¶
type APIError ¶
type APIError struct {
Code int `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
}
func (*APIError) IsAttachmentNotReady ¶
type Api ¶
type Api struct {
Bots *bots
Chats *chats
Debugs *debugs
Messages *messages
Subscriptions *subscriptions
Uploads *uploads
// contains filtered or unexported fields
}
Api represents the MAX Bot API client.
func (*Api) GetHandler ¶
func (a *Api) GetHandler(updates chan<- schemes.UpdateInterface) http.HandlerFunc
GetHandler returns an http.HandlerFunc for webhook handling. Deprecated: use GetUpdateHandler for channel. Or if you want use updateHandler directly use GetUpdateHandlerFunc.
func (*Api) GetUpdateHandler ¶ added in v1.6.9
func (a *Api) GetUpdateHandler(updates chan<- schemes.UpdateInterface, secret string) http.HandlerFunc
func (*Api) GetUpdateHandlerFunc ¶ added in v1.6.9
func (a *Api) GetUpdateHandlerFunc(h UpdateHandler, secret string) http.HandlerFunc
func (*Api) GetUpdates ¶
func (a *Api) GetUpdates(ctx context.Context) <-chan schemes.UpdateInterface
GetUpdates returns a channel that delivers updates from the API.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard implements a builder for the inline keyboard.
func InlineKeyboard ¶ added in v1.6.15
func InlineKeyboard(rows ...[]schemes.ButtonInterface) *Keyboard
InlineKeyboard create inline keyboard
func (*Keyboard) AddRow ¶
func (k *Keyboard) AddRow() *KeyboardRow
AddRow adds a row to the inline keyboard.
type KeyboardRow ¶
type KeyboardRow struct {
// contains filtered or unexported fields
}
KeyboardRow represents a button row.
func (*KeyboardRow) AddButton ¶
func (k *KeyboardRow) AddButton(b schemes.ButtonInterface) *KeyboardRow
func (*KeyboardRow) AddCallback ¶
func (k *KeyboardRow) AddCallback(text string, intent schemes.Intent, payload string) *KeyboardRow
AddCallback button.
func (*KeyboardRow) AddClipboard ¶ added in v1.6.11
func (k *KeyboardRow) AddClipboard(text, payload string) *KeyboardRow
func (*KeyboardRow) AddContact ¶
func (k *KeyboardRow) AddContact(text string) *KeyboardRow
AddContact button.
func (*KeyboardRow) AddGeolocation ¶
func (k *KeyboardRow) AddGeolocation(text string, quick bool) *KeyboardRow
AddGeolocation button.
func (*KeyboardRow) AddLink ¶
func (k *KeyboardRow) AddLink(text string, _ schemes.Intent, url string) *KeyboardRow
AddLink button.
func (*KeyboardRow) AddMessage ¶
func (k *KeyboardRow) AddMessage(text string) *KeyboardRow
AddMessage button.
func (*KeyboardRow) AddOpenApp ¶
func (k *KeyboardRow) AddOpenApp(text string, app, payload string, contactId int64) *KeyboardRow
AddOpenApp button.
func (*KeyboardRow) Build ¶
func (k *KeyboardRow) Build() []schemes.ButtonInterface
Build returns keyboard rows.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
func NewMessage ¶
func NewMessage() *Message
func (*Message) AddContact ¶
func (*Message) AddKeyboard ¶
func (*Message) AddPhotoByToken ¶
func (*Message) AddSticker ¶
func (*Message) SetDisableLinkPreview ¶ added in v1.6.10
func (*Message) SetPhoneNumbers ¶
type MessageResponse ¶
MessageResponse represents the response wrapper when a message is sent
type NetworkError ¶
func (*NetworkError) Error ¶
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶
func (e *NetworkError) Unwrap() error
type Option ¶
type Option func(api *Api)
func WithApiTimeout ¶
func WithBaseURL ¶
func WithDebugChat ¶
func WithDebugMode ¶
func WithDebugMode() Option
func WithErrorBufferSize ¶ added in v1.6.21
WithErrorBufferSize задаёт ёмкость канала ошибок, возвращаемого GetErrors(). Больший буфер снижает риск потери ошибок при всплесках (повторные сбои long polling и т.п.). Значения меньше 1 игнорируются.
func WithHTTPClient ¶
func WithHTTPClient(httpClient HttpClient) Option
func WithPauseTimeout ¶
func WithUpdateHandler ¶
func WithUpdateHandler(f UpdateHandler) Option
func WithVersion ¶
type SerializationError ¶
func (*SerializationError) Error ¶
func (e *SerializationError) Error() string
func (*SerializationError) Unwrap ¶
func (e *SerializationError) Unwrap() error
type TimeoutError ¶
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
func (*TimeoutError) Timeout ¶
func (e *TimeoutError) Timeout() bool
type UpdateHandler ¶
type UpdateHandler func(schemes.UpdateInterface)