Documentation
¶
Index ¶
- type Bot
- func (b *Bot) OnBotInlineQuery(ctx context.Context, e tg.Entities, u *tg.UpdateBotInlineQuery) error
- 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) error
- func (b *Bot) OnNewMessage(ctx context.Context, e tg.Entities, u *tg.UpdateNewMessage) error
- func (b *Bot) Register(dispatcher tg.UpdateDispatcher) *Bot
- func (b *Bot) WithLogger(logger *zap.Logger) *Bot
- func (b *Bot) WithSender(sender *message.Sender) *Bot
- 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) 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
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) OnBotInlineQuery ¶
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 ¶
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(log *zap.Logger) 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) 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.