Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompileHandlers ¶
func CompileHandlers( modules []interfaces.Module, builder RegexBuilder, ) ([]interfaces.HandlerTuple, []interfaces.HandlerTuple)
CompileHandlers is a utility function for Connector implementations to process all the modules/commands provided into a mapping of HandlerTuples. The first list returned is expressions to be matched on regular chats, and the second list has expressions to be matched on private/direct conversations with a bot.
Types ¶
type HandlerTuple ¶
type HandlerTuple struct { Pattern *regexp.Regexp Handler interfaces.Handler }
HandlerTuple is a simple pairing of a regular expressions and a handler function to be called if it is matched with the input message.
func (HandlerTuple) GetHandler ¶
func (t HandlerTuple) GetHandler() interfaces.Handler
GetHandler returns the Handler in this tuple.
func (HandlerTuple) GetPattern ¶
func (t HandlerTuple) GetPattern() *regexp.Regexp
GetPattern returns the regular expression pattern in this tuple.
type MatcherType ¶
type MatcherType int
MatcherType is the type of a matcher.
const ( // RegularMatcherType is used for all regular messages (on channels // usually) that do not mention the bot. RegularMatcherType MatcherType = iota // IMMatcherType is used for all messages sent directly to the bot // (private messages). IMMatcherType // MentionMatcherType is used for messages in channels but that directly // mention the bot's username. MentionMatcherType )
type ModuleFactory ¶
type ModuleFactory struct {
// contains filtered or unexported fields
}
ModuleFactory provides facilities for building sets of modules to be used in the chat server.
func NewModuleFactory ¶
func NewModuleFactory( config *confer.Config, logger *logrus.Logger, ) *ModuleFactory
NewModuleFactory constructs a new instance of a ModuleFactory.
func (*ModuleFactory) Make ¶
func (f *ModuleFactory) Make() []interfaces.Module
Make loads module configuration and initializes them.
type RegexBuilder ¶
type RegexBuilder func(matcherType MatcherType, pattern string) *regexp.Regexp
RegexBuilder is a function to be provided by Connector implementations while using CompileHeaders. It allows the Connector to modify any regular expressions before they are added to the matcher lists.