Versions in this module Expand all Collapse all v3 v3.0.0 Aug 15, 2020 Changes in this version + var ErrAlreadySubscribing = xerrors.New("already subscribing") + var ErrCommandInsufficientArgument = xerrors.New(...) + var ErrRunnerAlreadyRunning = xerrors.New("go-sarah's process is already running") + var ErrTaskInsufficientArgument = xerrors.New("one or more of required fields -- BotType, Identifier or Func -- are empty") + var ErrTaskScheduleNotGiven = xerrors.New("task schedule is not set or given from config struct") + var ErrWatcherNotRunning = xerrors.New("context is already canceled") + func NewBlockedInputError(i int) error + func NewBotNonContinuableError(errorContent string) error + func RegisterAlerter(alerter Alerter) + func RegisterBot(bot Bot) + func RegisterBotErrorSupervisor(fnc func(BotType, error) *SupervisionDirective) + func RegisterCommand(botType BotType, command Command) + func RegisterCommandProps(props *CommandProps) + func RegisterConfigWatcher(watcher ConfigWatcher) + func RegisterScheduledTask(botType BotType, task ScheduledTask) + func RegisterScheduledTaskProps(props *ScheduledTaskProps) + func RegisterWorker(worker workers.Worker) + func Run(ctx context.Context, config *Config) error + func StripMessage(pattern *regexp.Regexp, input string) string + type AbortInput struct + OriginalInput Input + func NewAbortInput(input Input) *AbortInput + func (ai *AbortInput) Message() string + func (ai *AbortInput) ReplyTo() OutputDestination + func (ai *AbortInput) SenderKey() string + func (ai *AbortInput) SentAt() time.Time + type Adapter interface + BotType func() BotType + Run func(context.Context, func(Input) error, func(error)) + SendMessage func(context.Context, Output) + type Alerter interface + Alert func(context.Context, BotType, error) error + type BlockedInputError struct + ContinuationCount int + func (e BlockedInputError) Error() string + type Bot interface + AppendCommand func(Command) + BotType func() BotType + Respond func(context.Context, Input) error + Run func(ctx context.Context, inputReceiver func(Input) error, notifyErr func(error)) + SendMessage func(context.Context, Output) + func NewBot(adapter Adapter, options ...DefaultBotOption) (Bot, error) + type BotNonContinuableError struct + func (e BotNonContinuableError) Error() string + type BotStatus struct + Running bool + Type BotType + type BotType string + func (botType BotType) String() string + type CacheConfig struct + CleanupInterval time.Duration + ExpiresIn time.Duration + func NewCacheConfig() *CacheConfig + type Command interface + Execute func(context.Context, Input) (*CommandResponse, error) + Identifier func() string + Instruction func(input *HelpInput) string + Match func(Input) bool + type CommandConfig interface + type CommandHelp struct + Identifier string + Instruction string + type CommandHelps []*CommandHelp + type CommandProps struct + type CommandPropsBuilder struct + func NewCommandPropsBuilder() *CommandPropsBuilder + func (builder *CommandPropsBuilder) BotType(botType BotType) *CommandPropsBuilder + func (builder *CommandPropsBuilder) Build() (*CommandProps, error) + func (builder *CommandPropsBuilder) ConfigurableFunc(config CommandConfig, ...) *CommandPropsBuilder + func (builder *CommandPropsBuilder) Func(fn func(context.Context, Input) (*CommandResponse, error)) *CommandPropsBuilder + func (builder *CommandPropsBuilder) Identifier(id string) *CommandPropsBuilder + func (builder *CommandPropsBuilder) Instruction(instruction string) *CommandPropsBuilder + func (builder *CommandPropsBuilder) InstructionFunc(fnc func(input *HelpInput) string) *CommandPropsBuilder + func (builder *CommandPropsBuilder) MatchFunc(matchFunc func(Input) bool) *CommandPropsBuilder + func (builder *CommandPropsBuilder) MatchPattern(pattern *regexp.Regexp) *CommandPropsBuilder + func (builder *CommandPropsBuilder) MustBuild() *CommandProps + type CommandResponse struct + Content interface{} + UserContext *UserContext + func NewSuppressedResponseWithNext(next ContextualFunc) *CommandResponse + type Commands struct + func NewCommands() *Commands + func (commands *Commands) Append(command Command) + func (commands *Commands) ExecuteFirstMatched(ctx context.Context, input Input) (*CommandResponse, error) + func (commands *Commands) FindFirstMatched(input Input) Command + func (commands *Commands) Helps(input *HelpInput) *CommandHelps + type Config struct + TimeZone string + func NewConfig() *Config + type ConfigNotFoundError struct + BotType BotType + ID string + func (err *ConfigNotFoundError) Error() string + type ConfigWatcher interface + Read func(botCtx context.Context, botType BotType, id string, configPtr interface{}) error + Unwatch func(botType BotType) error + Watch func(botCtx context.Context, botType BotType, id string, callback func()) error + type ContextualFunc func(context.Context, Input) (*CommandResponse, error) + type DefaultBotOption func(bot *defaultBot) + func BotWithStorage(storage UserContextStorage) DefaultBotOption + type DestinatedConfig interface + DefaultDestination func() OutputDestination + type HelpInput struct + OriginalInput Input + func NewHelpInput(input Input) *HelpInput + func (hi *HelpInput) Message() string + func (hi *HelpInput) ReplyTo() OutputDestination + func (hi *HelpInput) SenderKey() string + func (hi *HelpInput) SentAt() time.Time + type Input interface + Message func() string + ReplyTo func() OutputDestination + SenderKey func() string + SentAt func() time.Time + type Output interface + Content func() interface{} + Destination func() OutputDestination + func NewOutputMessage(destination OutputDestination, content interface{}) Output + type OutputDestination interface + type OutputMessage struct + func (output *OutputMessage) Content() interface{} + func (output *OutputMessage) Destination() OutputDestination + type ScheduledConfig interface + Schedule func() string + type ScheduledTask interface + DefaultDestination func() OutputDestination + Execute func(context.Context) ([]*ScheduledTaskResult, error) + Identifier func() string + Schedule func() string + type ScheduledTaskProps struct + type ScheduledTaskPropsBuilder struct + func NewScheduledTaskPropsBuilder() *ScheduledTaskPropsBuilder + func (builder *ScheduledTaskPropsBuilder) BotType(botType BotType) *ScheduledTaskPropsBuilder + func (builder *ScheduledTaskPropsBuilder) Build() (*ScheduledTaskProps, error) + func (builder *ScheduledTaskPropsBuilder) ConfigurableFunc(config TaskConfig, ...) *ScheduledTaskPropsBuilder + func (builder *ScheduledTaskPropsBuilder) DefaultDestination(dest OutputDestination) *ScheduledTaskPropsBuilder + func (builder *ScheduledTaskPropsBuilder) Func(fn func(context.Context) ([]*ScheduledTaskResult, error)) *ScheduledTaskPropsBuilder + func (builder *ScheduledTaskPropsBuilder) Identifier(id string) *ScheduledTaskPropsBuilder + func (builder *ScheduledTaskPropsBuilder) MustBuild() *ScheduledTaskProps + func (builder *ScheduledTaskPropsBuilder) Schedule(schedule string) *ScheduledTaskPropsBuilder + type ScheduledTaskResult struct + Content interface{} + Destination OutputDestination + type SerializableArgument struct + Argument interface{} + FuncIdentifier string + type Status struct + Bots []BotStatus + Running bool + func CurrentStatus() Status + type SupervisionDirective struct + AlertingErr error + StopBot bool + type TaskConfig interface + type UserContext struct + Next ContextualFunc + Serializable *SerializableArgument + func NewUserContext(next ContextualFunc) *UserContext + type UserContextStorage interface + Delete func(string) error + Flush func() error + Get func(string) (ContextualFunc, error) + Set func(string, *UserContext) error + func NewUserContextStorage(config *CacheConfig) UserContextStorage Other modules containing this package github.com/oklahomer/go-sarah github.com/oklahomer/go-sarah/v2 github.com/oklahomer/go-sarah/v4