Documentation ¶
Index ¶
- type Bot
- func (b *Bot) OnBotCallbackQuery(ctx context.Context, e tg.Entities, u *tg.UpdateBotCallbackQuery) error
- func (b *Bot) OnBotInlineQuery(ctx context.Context, e tg.Entities, u *tg.UpdateBotInlineQuery) error
- func (b *Bot) OnButton(handler ButtonHandler) *Bot
- func (b *Bot) OnInline(handler InlineHandler) *Bot
- func (b *Bot) OnMessage(handler MessageHandler) *Bot
- func (b *Bot) OnNewChannelMessage(ctx context.Context, e tg.Entities, u *tg.UpdateNewChannelMessage) (rerr error)
- func (b *Bot) OnNewMessage(ctx context.Context, e tg.Entities, u *tg.UpdateNewMessage) (rerr error)
- func (b *Bot) Register(dispatcher tg.UpdateDispatcher) *Bot
- func (b *Bot) WithGitHub(client *github.Client) *Bot
- func (b *Bot) WithSender(sender *message.Sender) *Bot
- func (b *Bot) WithTracerProvider(provider trace.TracerProvider) *Bot
- type Button
- type ButtonHandler
- type ButtonHandlerFunc
- type InlineHandler
- type InlineHandlerFunc
- type InlineQuery
- type LoggedDispatcher
- type MessageEvent
- func (e MessageEvent) Channel() (*tg.Channel, bool)
- func (e MessageEvent) Chat() (*tg.Chat, bool)
- func (e MessageEvent) Logger() *zap.Logger
- func (e MessageEvent) MessageFrom() (u *tg.User, _ bool)
- func (e MessageEvent) RPC() *tg.Client
- func (e MessageEvent) Reply() *message.Builder
- func (e MessageEvent) Sender() *message.Sender
- func (e MessageEvent) TypingAction() *message.TypingActionBuilder
- func (e MessageEvent) User() (*tg.User, bool)
- func (e MessageEvent) WithReply(ctx context.Context, cb func(reply *tg.Message) error) error
- type MessageHandler
- type MessageHandlerFunc
- type MessageMux
- func (m *MessageMux) Handle(prefix, description string, handler MessageHandler)
- func (m *MessageMux) HandleFunc(prefix, description string, ...)
- func (m *MessageMux) OnMessage(ctx context.Context, e MessageEvent) error
- func (m *MessageMux) RegisterCommands(ctx context.Context, raw *tg.Client) error
- func (m *MessageMux) SetFallback(h MessageHandler)
- func (m *MessageMux) SetFallbackFunc(h func(ctx context.Context, e MessageEvent) error)
- func (m *MessageMux) WithTracerProvider(provider trace.TracerProvider) *MessageMux
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot represents generic Telegram bot state and event dispatcher.
func (*Bot) OnBotCallbackQuery ¶
func (*Bot) OnBotInlineQuery ¶
func (*Bot) OnButton ¶
func (b *Bot) OnButton(handler ButtonHandler) *Bot
OnButton sets button handler.
func (*Bot) OnInline ¶
func (b *Bot) OnInline(handler InlineHandler) *Bot
OnInline sets inline query handler.
func (*Bot) OnMessage ¶
func (b *Bot) OnMessage(handler MessageHandler) *Bot
OnMessage sets message handler.
func (*Bot) OnNewChannelMessage ¶
func (*Bot) OnNewMessage ¶
func (*Bot) Register ¶
func (b *Bot) Register(dispatcher tg.UpdateDispatcher) *Bot
Register sets handlers using given dispatcher.
func (*Bot) WithSender ¶
WithSender sets message sender to use.
func (*Bot) WithTracerProvider ¶
func (b *Bot) WithTracerProvider(provider trace.TracerProvider) *Bot
type Button ¶
type ButtonHandlerFunc ¶
ButtonHandlerFunc is a functional adapter for Handler.
type InlineHandler ¶
type InlineHandler interface {
OnInline(ctx context.Context, e InlineQuery) error
}
InlineHandler is a simple inline query event handler.
type InlineHandlerFunc ¶
type InlineHandlerFunc func(ctx context.Context, e InlineQuery) error
InlineHandlerFunc is a functional adapter for Handler.
func (InlineHandlerFunc) OnInline ¶
func (h InlineHandlerFunc) OnInline(ctx context.Context, e InlineQuery) error
OnInline implements InlineHandler.
type InlineQuery ¶
type InlineQuery struct { QueryID int64 Query string Offset string Enquirer *tg.InputUser // contains filtered or unexported fields }
InlineQuery represents inline query event.
func (InlineQuery) Geo ¶
func (e InlineQuery) Geo() (*tg.GeoPoint, bool)
Geo returns GeoPoint object and true if query has attached geo point. False and nil otherwise.
func (InlineQuery) Reply ¶
func (e InlineQuery) Reply() *inline.ResultBuilder
Reply returns result builder.
type LoggedDispatcher ¶
type LoggedDispatcher struct {
// contains filtered or unexported fields
}
LoggedDispatcher is update logging middleware.
func NewLoggedDispatcher ¶
func NewLoggedDispatcher(next telegram.UpdateHandler, log *zap.Logger, traceProvider trace.TracerProvider) LoggedDispatcher
NewLoggedDispatcher creates new update logging middleware.
func (LoggedDispatcher) Handle ¶
func (d LoggedDispatcher) Handle(ctx context.Context, u tg.UpdatesClass) error
Handle implements telegram.UpdateHandler.
type MessageEvent ¶
type MessageEvent struct { Peer tg.InputPeerClass Message *tg.Message // contains filtered or unexported fields }
MessageEvent represents message event.
func (MessageEvent) Channel ¶
func (e MessageEvent) Channel() (*tg.Channel, bool)
Channel returns Channel object and true if message got from channel. False and nil otherwise.
func (MessageEvent) Chat ¶
func (e MessageEvent) Chat() (*tg.Chat, bool)
Chat returns Chat object and true if message got from chat. False and nil otherwise.
func (MessageEvent) MessageFrom ¶
func (e MessageEvent) MessageFrom() (u *tg.User, _ bool)
MessageFrom returns user whom send the messag and true, if `from` field was present in event.
func (MessageEvent) Reply ¶
func (e MessageEvent) Reply() *message.Builder
Reply creates new message builder to reply.
func (MessageEvent) TypingAction ¶
func (e MessageEvent) TypingAction() *message.TypingActionBuilder
type MessageHandler ¶
type MessageHandler interface {
OnMessage(ctx context.Context, e MessageEvent) error
}
MessageHandler is a simple message event handler.
type MessageHandlerFunc ¶
type MessageHandlerFunc func(ctx context.Context, e MessageEvent) error
MessageHandlerFunc is a functional adapter for Handler.
func (MessageHandlerFunc) OnMessage ¶
func (h MessageHandlerFunc) OnMessage(ctx context.Context, e MessageEvent) error
OnMessage implements MessageHandler.
type MessageMux ¶
type MessageMux struct {
// contains filtered or unexported fields
}
MessageMux is message event router.
func (*MessageMux) Handle ¶
func (m *MessageMux) Handle(prefix, description string, handler MessageHandler)
Handle adds given prefix and handler to the mux.
func (*MessageMux) HandleFunc ¶
func (m *MessageMux) HandleFunc(prefix, description string, handler func(ctx context.Context, e MessageEvent) error)
HandleFunc adds given prefix and handler to the mux.
func (*MessageMux) OnMessage ¶
func (m *MessageMux) OnMessage(ctx context.Context, e MessageEvent) error
OnMessage implements MessageHandler.
func (*MessageMux) RegisterCommands ¶
RegisterCommands registers all mux commands using https://core.telegram.org/method/bots.setBotCommands.
func (*MessageMux) SetFallback ¶
func (m *MessageMux) SetFallback(h MessageHandler)
SetFallback sets fallback handler, if mux is unable to find a command handler.
func (*MessageMux) SetFallbackFunc ¶
func (m *MessageMux) SetFallbackFunc(h func(ctx context.Context, e MessageEvent) error)
SetFallbackFunc sets fallback handler, if mux is unable to find a command handler.
func (*MessageMux) WithTracerProvider ¶
func (m *MessageMux) WithTracerProvider(provider trace.TracerProvider) *MessageMux