Documentation ¶
Index ¶
- Variables
- type Dispatcher
- type ErrorHandler
- type Handler
- type NativeDispatcher
- func (dp *NativeDispatcher) AddHandler(h Handler)
- func (dp *NativeDispatcher) AddHandlerToGroup(h Handler, group int)
- func (dp *NativeDispatcher) Handle(ctx context.Context, updates tg.UpdatesClass) error
- func (dp *NativeDispatcher) Initialize(ctx context.Context, cancel context.CancelFunc, client *telegram.Client, ...)
- type PanicHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // StopClient cancels the context and stops the client if returned through handler callback function. StopClient = errors.New("disconnect") // EndGroups stops iterating over handlers groups if returned through handler callback function. EndGroups = errors.New("stopped") // ContinueGroups continues iterating over handlers groups if returned through handler callback function. ContinueGroups = errors.New("continued") // SkipCurrentGroup skips current group and continues iterating over handlers groups if returned through handler callback function. SkipCurrentGroup = errors.New("skipped") )
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Handler ¶
type Handler interface { // CheckUpdate checks whether the update should be handled by this handler and processes it. CheckUpdate(*ext.Context, *ext.Update) error }
Handler is the common interface for all the handlers.
type NativeDispatcher ¶
type NativeDispatcher struct { // Panic handles all the panics that occur during handler execution. Panic PanicHandler // Error handles all the unknown errors which are returned by the handler callback functions. Error ErrorHandler // contains filtered or unexported fields }
func NewNativeDispatcher ¶
func NewNativeDispatcher(setReply bool, setEntireReplyChain bool, eHandler ErrorHandler, pHandler PanicHandler, p *storage.PeerStorage) *NativeDispatcher
MakeDispatcher creates new custom dispatcher which process and handles incoming updates.
func (*NativeDispatcher) AddHandler ¶
func (dp *NativeDispatcher) AddHandler(h Handler)
AddHandler adds a new handler to the dispatcher. The dispatcher will call CheckUpdate() to see whether the handler should be executed, and then execute it.
func (*NativeDispatcher) AddHandlerToGroup ¶
func (dp *NativeDispatcher) AddHandlerToGroup(h Handler, group int)
AddHandlerToGroup adds a handler to a specific group; lowest number will be processed first.
func (*NativeDispatcher) Handle ¶
func (dp *NativeDispatcher) Handle(ctx context.Context, updates tg.UpdatesClass) error
Handle function handles all the incoming updates, map entities and dispatches updates for further handling.
func (*NativeDispatcher) Initialize ¶
func (dp *NativeDispatcher) Initialize(ctx context.Context, cancel context.CancelFunc, client *telegram.Client, self *tg.User)
Click to show internal directories.
Click to hide internal directories.