Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetPrivateMessageFromContext ¶ added in v0.5.0
func GetPrivateMessageFromContext(ctx context.Context) *twitch.PrivateMessage
Types ¶
type Controller ¶ added in v0.3.1
type Controller struct {
// contains filtered or unexported fields
}
Controller represents a manager to commands.
func NewController ¶
func NewController(prefix string, logger *zap.Logger) *Controller
NewController creates an instance of Controller for managing commands.
func (*Controller) AddCommand ¶ added in v0.3.1
func (c *Controller) AddCommand(commandName string, handler Handler, filters []Filter)
AddCommand adds a command handler to a map in Controller. The handler is being wrapped with filters and middlewares, before it is added to commands. The order of functions in wrapped handler goes like this: Middlewares -> Filters -> Handler.
func (*Controller) CallCommand ¶ added in v0.3.1
func (c *Controller) CallCommand(ctx context.Context, userMessage string, privateMessage twitch.PrivateMessage, chatClient chatClient)
CallCommand searches for a command and execute it, if find one.
func (*Controller) UseWith ¶ added in v0.5.0
func (c *Controller) UseWith(middleware Middleware)
UseWith adds a middleware to a middlewares. The order when a middleware is added matters.
type Filter ¶ added in v0.5.0
Filter represents a function that is called after all middlewares and before a command. It is used for validation.
type Middleware ¶ added in v0.5.0
Middleware represents a function that is called before any filters and a handler. It can be used for logging handler's parameters, error handling or measure how much time a command took to execute.
func ErrorHandler ¶ added in v0.5.0
func ErrorHandler(logger *zap.Logger) Middleware