Documentation
¶
Index ¶
- type BotMessage
- type Handler
- type MessageSender
- type Middleware
- type NewTracerFn
- type NoopTracer
- type Option
- func WithLivenessProbe(probe Probe) Option
- func WithNewTracerFn(tracerFn NewTracerFn) Option
- func WithReadTimeout(timeout time.Duration) Option
- func WithReadinessProbe(probe Probe) Option
- func WithShutdownTimeout(timeout time.Duration) Option
- func WithWebHookToken(token string) Option
- func WithWriteTimeout(timeout time.Duration) Option
- type Payment
- type Probe
- type TGBot
- func (t *TGBot) AddDefaultCallbackQueryHandler(h Handler)
- func (t *TGBot) AddDefaultHandler(h Handler)
- func (t *TGBot) AddDefaultTextHandler(h Handler)
- func (t *TGBot) AddMenuCommand(command string, description string, handler Handler)
- func (t *TGBot) AddMiddleware(m Middleware)
- func (t *TGBot) AddTextCommand(command string, handler Handler)
- func (t *TGBot) DeleteMessage(ctx context.Context, chatID int64, messageID int)
- func (t *TGBot) SendMessage(ctx context.Context, chatID int64, msg string)
- func (t *TGBot) Start(ctx context.Context) error
- type Tracer
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotMessage ¶
type Handler ¶
type Handler func(ctx context.Context, msg BotMessage, sender MessageSender) error
type MessageSender ¶
type Middleware ¶
type NewTracerFn ¶
type NewTracerFn func() Tracer
type NoopTracer ¶
type NoopTracer struct {
}
func NewNoopTracer ¶
func NewNoopTracer() NoopTracer
NewNoopTracer returns a no-op Tracer implementation that performs no tracing actions.
func (NoopTracer) After ¶
func (n NoopTracer) After(ctx context.Context)
func (NoopTracer) Before ¶
func (n NoopTracer) Before(ctx context.Context, pattern string, msg BotMessage) context.Context
func (NoopTracer) OnSuccess ¶
func (n NoopTracer) OnSuccess(ctx context.Context)
type Option ¶
type Option func(o *options)
func WithLivenessProbe ¶
WithLivenessProbe sets the probe function used for the liveness HTTP health check endpoint.
func WithNewTracerFn ¶
func WithNewTracerFn(tracerFn NewTracerFn) Option
WithNewTracerFn sets the factory function used to create a new Tracer for each handler invocation.
func WithReadTimeout ¶
WithReadTimeout sets the read timeout for the HTTP server used in webhook mode.
func WithReadinessProbe ¶
WithReadinessProbe sets the probe function used for the readiness HTTP health check endpoint.
func WithShutdownTimeout ¶
WithShutdownTimeout sets the maximum duration to wait for the HTTP server to shut down gracefully.
func WithWebHookToken ¶
WithWebHookToken sets the webhook secret token used to validate incoming webhook requests.
func WithWriteTimeout ¶
WithWriteTimeout sets the write timeout for the HTTP server used in webhook mode.
type TGBot ¶
type TGBot struct {
// contains filtered or unexported fields
}
func New ¶
New creates a new TGBot instance with the given Telegram bot token and options. It initializes the bot API and applies all provided options. Returns an error if the bot API creation fails.
func (*TGBot) AddDefaultCallbackQueryHandler ¶
AddDefaultCallbackQueryHandler registers a handler for all callback query updates.
func (*TGBot) AddDefaultHandler ¶
AddDefaultHandler sets the handler that is called when no other command handler matches an incoming message.
func (*TGBot) AddDefaultTextHandler ¶
AddDefaultTextHandler registers a handler for all text messages that do not match any registered command. The handler is called with the full message text as the pattern.
func (*TGBot) AddMenuCommand ¶
AddMenuCommand registers a bot command with a description in the bot's menu. The command is also registered as a handler for incoming messages matching the command.
func (*TGBot) AddMiddleware ¶
func (t *TGBot) AddMiddleware(m Middleware)
AddMiddleware adds a middleware function to the bot's middleware chain. Middlewares are applied in the order they were added.
func (*TGBot) AddTextCommand ¶
AddTextCommand registers a command handler without a menu description. The handler is triggered when a message starts with the given command.
func (*TGBot) DeleteMessage ¶
DeleteMessage deletes a message from a chat by its ID. Errors are logged but not returned to the caller.
func (*TGBot) SendMessage ¶
SendMessage sends a text message to the specified chat. Errors are logged but not returned to the caller.