Documentation
¶
Index ¶
- Constants
- Variables
- type BaseMessage
- type Client
- func (c *Client) API(ctx context.Context, method string, req, resp any) error
- func (c *Client) DeleteMessage(ctx context.Context, chatID, messageID int64) (bool, error)
- func (c *Client) EditMessage(ctx context.Context, chatID, messageID int64, text string, opts ...EditOption) (*Message, error)
- func (c *Client) GetMe(ctx context.Context) (*User, error)
- func (c *Client) SendMessage(ctx context.Context, chatID int64, text string, opts ...SendOption) (*Message, error)
- type DeleteMessage
- type EditMessage
- type EditOption
- type HTTPClient
- type Message
- type Option
- type ParseMode
- type Response
- type ResponseError
- type SendMessage
- type SendOption
- type TG
- type User
Constants ¶
View Source
const ( MarkdownV2ParseMode = "MarkdownV2" MarkdownParseMode = "Markdown" HTMLParseMode = "HTML" )
View Source
const MaxTextSize int = 4096
Variables ¶
View Source
var ( ErrEmptyChatID = errors.New("empty chat_id") ErrEmptyText = errors.New("empty text") ErrTextTooLong = errors.New("text too long") )
View Source
var ( ErrIncorrectScheme = errors.New("incorrect scheme") ErrEmptyHost = errors.New("empty host") )
View Source
var ( ErrValueNil = errors.New("value is nil") ErrValueNotPtr = errors.New("value not ptr") ErrValueNotStructOrBool = errors.New("value not struct or bool") )
View Source
var ErrHTTPClientNil = errors.New("httpclient is nil")
View Source
var ErrIncorrectMessageID = errors.New("incorrect message_id")
View Source
var ErrIncorrectMessageThreadID = errors.New("incorrect message_thread_id")
View Source
var ErrIncorrentToken = errors.New("incorrect token")
View Source
var ErrUnknownParseMode = errors.New("unknown parse_mode")
Functions ¶
This section is empty.
Types ¶
type BaseMessage ¶ added in v0.10.0
type BaseMessage struct {
ChatID int64 `json:"chat_id"`
Text string `json:"text"`
ParseMode ParseMode `json:"parse_mode,omitempty"`
}
func (*BaseMessage) Validate ¶ added in v0.10.0
func (bm *BaseMessage) Validate() error
type Client ¶ added in v0.10.0
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DeleteMessage ¶ added in v0.10.0
func (*Client) EditMessage ¶ added in v0.10.0
func (*Client) SendMessage ¶ added in v0.10.0
type DeleteMessage ¶ added in v0.10.0
func NewDeleteMessage ¶ added in v0.10.0
func NewDeleteMessage(chatID int64, messageID int64) (*DeleteMessage, error)
func (*DeleteMessage) Validate ¶ added in v0.10.0
func (dm *DeleteMessage) Validate() error
type EditMessage ¶ added in v0.10.0
type EditMessage struct {
MessageID int64 `json:"message_id"`
BaseMessage
}
func NewEditMessage ¶ added in v0.10.0
func NewEditMessage(chatID int64, messageID int64, text string, opts ...EditOption) (*EditMessage, error)
func (*EditMessage) Validate ¶ added in v0.10.0
func (em *EditMessage) Validate() error
type EditOption ¶ added in v0.10.0
type EditOption func(*EditMessage)
func ParseModeEditOption ¶ added in v0.10.0
func ParseModeEditOption(mode ParseMode) EditOption
type HTTPClient ¶ added in v0.5.0
type Option ¶ added in v0.6.0
func WithAPIServer ¶ added in v0.10.0
func WithHTTPClient ¶ added in v0.10.0
func WithHTTPClient(client HTTPClient) Option
type Response ¶ added in v0.10.0
type Response struct {
Result interface{} `json:"result,omitempty"`
ResponseError
}
type ResponseError ¶ added in v0.10.0
type ResponseError struct {
Ok bool `json:"ok"`
ErrorCode int `json:"error_code,omitempty"`
Description string `json:"description,omitempty"`
Parameters struct {
RetryAfter int `json:"retry_after,omitempty"`
} `json:"parameters,omitempty"`
}
func (ResponseError) Error ¶ added in v0.10.0
func (r ResponseError) Error() string
type SendMessage ¶ added in v0.10.0
type SendMessage struct {
BaseMessage
MessageThreadID int64 `json:"message_thread_id,omitempty"`
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
DisableNotification bool `json:"disable_notification,omitempty"`
ProtectContent bool `json:"protect_content,omitempty"`
}
func NewSendMessage ¶ added in v0.10.0
func NewSendMessage(chatID int64, text string, opts ...SendOption) (*SendMessage, error)
func (*SendMessage) Validate ¶ added in v0.10.0
func (sm *SendMessage) Validate() error
type SendOption ¶ added in v0.10.0
type SendOption func(*SendMessage)
func DisableNotificationSendOption ¶ added in v0.10.0
func DisableNotificationSendOption(disable bool) SendOption
func DisableWebPagePreviewSendOption ¶ added in v0.10.0
func DisableWebPagePreviewSendOption(disable bool) SendOption
func MessageThreadIDSendOption ¶ added in v0.10.0
func MessageThreadIDSendOption(threadID int64) SendOption
func ParseModeSendOption ¶ added in v0.10.0
func ParseModeSendOption(mode ParseMode) SendOption
func ProtectContentSendOption ¶ added in v0.10.0
func ProtectContentSendOption(protect bool) SendOption
type TG ¶
type TG interface {
GetMe(ctx context.Context) (*User, error)
SendMessage(ctx context.Context, chatID int64, text string, opts ...SendOption) (*Message, error)
EditMessage(ctx context.Context, chatID, messageID int64, text string, opts ...EditOption) (*Message, error)
DeleteMessage(ctx context.Context, chatID, messageID int64) (bool, error)
}
Click to show internal directories.
Click to hide internal directories.