Documentation ¶
Index ¶
- Variables
- func DeriveChannel(m *irc.Message, evtData *FieldCollection) string
- func DeriveUser(m *irc.Message, evtData *FieldCollection) string
- type ActionDocumentation
- type ActionDocumentationField
- type ActionDocumentationFieldType
- type Actor
- type ActorCreationFunc
- type ActorDocumentationRegistrationFunc
- type ActorKit
- func (ActorKit) ValidateRequireNonEmpty(attrs *FieldCollection, fields ...string) error
- func (ActorKit) ValidateRequireValidTemplate(tplValidator TemplateValidatorFunc, attrs *FieldCollection, fields ...string) error
- func (ActorKit) ValidateRequireValidTemplateIfSet(tplValidator TemplateValidatorFunc, attrs *FieldCollection, fields ...string) error
- type ActorRegistrationFunc
- type ChannelAnyPermissionCheckFunc
- type ChannelPermissionCheckFunc
- type CronRegistrationFunc
- type EventHandlerFunc
- type EventHandlerRegisterFunc
- type FieldCollection
- func (f *FieldCollection) Any(name string) (any, error)
- func (f *FieldCollection) Bool(name string) (bool, error)
- func (f *FieldCollection) CanBool(name string) bool
- func (f *FieldCollection) CanDuration(name string) bool
- func (f *FieldCollection) CanInt64(name string) bool
- func (f *FieldCollection) CanString(name string) bool
- func (f *FieldCollection) Clone() *FieldCollection
- func (f *FieldCollection) Data() map[string]any
- func (f *FieldCollection) Duration(name string) (time.Duration, error)
- func (f *FieldCollection) Expect(keys ...string) error
- func (f *FieldCollection) HasAll(keys ...string) bool
- func (f *FieldCollection) Int64(name string) (int64, error)
- func (f *FieldCollection) MarshalJSON() ([]byte, error)
- func (f *FieldCollection) MarshalYAML() (any, error)
- func (f *FieldCollection) MustBool(name string, defVal *bool) bool
- func (f *FieldCollection) MustDuration(name string, defVal *time.Duration) time.Duration
- func (f *FieldCollection) MustInt64(name string, defVal *int64) int64
- func (f *FieldCollection) MustString(name string, defVal *string) string
- func (f *FieldCollection) MustStringSlice(name string) []string
- func (f *FieldCollection) Set(key string, value any)
- func (f *FieldCollection) SetFromData(data map[string]any)
- func (f *FieldCollection) String(name string) (string, error)
- func (f *FieldCollection) StringSlice(name string) ([]string, error)
- func (f *FieldCollection) UnmarshalJSON(raw []byte) error
- func (f *FieldCollection) UnmarshalYAML(unmarshal func(any) error) error
- type HTTPRouteParamDocumentation
- type HTTPRouteRegistrationArgs
- type HTTPRouteRegistrationFunc
- type HTTPRouteResponseType
- type LoggerCreationFunc
- type MsgFormatter
- type MsgModificationFunc
- type MsgModificationRegistrationFunc
- type RawMessageHandlerFunc
- type RawMessageHandlerRegisterFunc
- type RegisterFunc
- type RegistrationArguments
- type Rule
- func (r *Rule) GetMatchMessage() *regexp.Regexp
- func (r Rule) MatcherID() string
- func (r *Rule) Matches(m *irc.Message, event *string, timerStore TimerStore, ...) bool
- func (r *Rule) SetCooldown(timerStore TimerStore, m *irc.Message, evtData *FieldCollection)
- func (r *Rule) UpdateFromSubscription() (bool, error)
- func (r Rule) Validate(tplValidate TemplateValidatorFunc) error
- type RuleAction
- type SendMessageFunc
- type StorageManager
- type StorageMarshaller
- type StorageUnmarshaller
- type TemplateFuncDocumentation
- type TemplateFuncDocumentationExample
- type TemplateFuncGetter
- type TemplateFuncRegister
- type TemplateValidatorFunc
- type TimerEntry
- type TimerStore
- type TimerType
- type ValidateTokenFunc
Constants ¶
This section is empty.
Variables ¶
var ( ErrValueNotSet = errors.New("specified value not found") ErrValueMismatch = errors.New("specified value has different format") )
var ErrSkipSendingMessage = errors.New("skip sending message")
var ErrStopRuleExecution = errors.New("stop rule execution now")
ErrStopRuleExecution is a way for actions to terminate execution of the current rule gracefully. No actions after this has been returned will be executed and no error state will be set
Functions ¶
func DeriveChannel ¶
func DeriveChannel(m *irc.Message, evtData *FieldCollection) string
func DeriveUser ¶
func DeriveUser(m *irc.Message, evtData *FieldCollection) string
Types ¶
type ActionDocumentation ¶
type ActionDocumentation struct { Description string `json:"description"` Name string `json:"name"` Type string `json:"type"` Fields []ActionDocumentationField `json:"fields"` }
type ActionDocumentationField ¶
type ActionDocumentationField struct { Default string `json:"default"` DefaultComment string `json:"default_comment"` Description string `json:"description"` Key string `json:"key"` Long bool `json:"long"` Name string `json:"name"` Optional bool `json:"optional"` SupportTemplate bool `json:"support_template"` Type ActionDocumentationFieldType `json:"type"` }
type ActionDocumentationFieldType ¶
type ActionDocumentationFieldType string
const ( ActionDocumentationFieldTypeBool ActionDocumentationFieldType = "bool" ActionDocumentationFieldTypeDuration ActionDocumentationFieldType = "duration" ActionDocumentationFieldTypeInt64 ActionDocumentationFieldType = "int64" ActionDocumentationFieldTypeString ActionDocumentationFieldType = "string" ActionDocumentationFieldTypeStringSlice ActionDocumentationFieldType = "stringslice" )
type Actor ¶
type Actor interface { // Execute will be called after the config was read into the Actor Execute(c *irc.Client, m *irc.Message, r *Rule, evtData *FieldCollection, attrs *FieldCollection) (preventCooldown bool, err error) // IsAsync may return true if the Execute function is to be executed // in a Go routine as of long runtime. Normally it should return false // except in very specific cases IsAsync() bool // Name must return an unique name for the actor in order to identify // it in the logs for debugging purposes Name() string // Validate will be called to validate the loaded configuration. It should // return an error if required keys are missing from the AttributeStore // or if keys contain broken configs Validate(TemplateValidatorFunc, *FieldCollection) error }
type ActorCreationFunc ¶
type ActorCreationFunc func() Actor
type ActorDocumentationRegistrationFunc ¶
type ActorDocumentationRegistrationFunc func(ActionDocumentation)
type ActorKit ¶ added in v3.16.0
type ActorKit struct{}
ActorKit contains some common validation functions to be used when implementing actors
func (ActorKit) ValidateRequireNonEmpty ¶ added in v3.16.0
func (ActorKit) ValidateRequireNonEmpty(attrs *FieldCollection, fields ...string) error
ValidateRequireNonEmpty checks whether the fields are gettable (not returning ErrValueNotSet) and does not contain zero value recognized by reflect (to just check whether the field is set but allow zero values use HasAll on the FieldCollection)
func (ActorKit) ValidateRequireValidTemplate ¶ added in v3.16.0
func (ActorKit) ValidateRequireValidTemplate(tplValidator TemplateValidatorFunc, attrs *FieldCollection, fields ...string) error
ValidateRequireValidTemplate checks whether fields are gettable as strings and do have a template which validates (this does not check for empty strings as an empty template is indeed valid)
func (ActorKit) ValidateRequireValidTemplateIfSet ¶ added in v3.16.0
func (ActorKit) ValidateRequireValidTemplateIfSet(tplValidator TemplateValidatorFunc, attrs *FieldCollection, fields ...string) error
ValidateRequireValidTemplateIfSet checks whether the field is either not set or a valid template (this does not check for empty strings as an empty template is indeed valid)
type ActorRegistrationFunc ¶
type ActorRegistrationFunc func(name string, acf ActorCreationFunc)
type ChannelAnyPermissionCheckFunc ¶ added in v3.2.0
type ChannelPermissionCheckFunc ¶ added in v3.2.0
type CronRegistrationFunc ¶
type EventHandlerFunc ¶
type EventHandlerFunc func(evt string, eventData *FieldCollection) error
type EventHandlerRegisterFunc ¶
type EventHandlerRegisterFunc func(EventHandlerFunc) error
type FieldCollection ¶
type FieldCollection struct {
// contains filtered or unexported fields
}
func FieldCollectionFromData ¶
func FieldCollectionFromData(data map[string]any) *FieldCollection
FieldCollectionFromData is a wrapper around NewFieldCollection and SetFromData
func NewFieldCollection ¶
func NewFieldCollection() *FieldCollection
NewFieldCollection creates a new FieldCollection with empty data store
func (*FieldCollection) Any ¶ added in v3.8.0
func (f *FieldCollection) Any(name string) (any, error)
Any tries to read key name as any-type (interface)
func (*FieldCollection) Bool ¶
func (f *FieldCollection) Bool(name string) (bool, error)
Bool tries to read key name as bool
func (*FieldCollection) CanBool ¶
func (f *FieldCollection) CanBool(name string) bool
CanBool tries to read key name as bool and checks whether error is nil
func (*FieldCollection) CanDuration ¶
func (f *FieldCollection) CanDuration(name string) bool
CanDuration tries to read key name as time.Duration and checks whether error is nil
func (*FieldCollection) CanInt64 ¶
func (f *FieldCollection) CanInt64(name string) bool
CanInt64 tries to read key name as int64 and checks whether error is nil
func (*FieldCollection) CanString ¶
func (f *FieldCollection) CanString(name string) bool
CanString tries to read key name as string and checks whether error is nil
func (*FieldCollection) Clone ¶
func (f *FieldCollection) Clone() *FieldCollection
Clone is a wrapper around n.SetFromData(o.Data())
func (*FieldCollection) Data ¶
func (f *FieldCollection) Data() map[string]any
Data creates a map-copy of the data stored inside the FieldCollection
func (*FieldCollection) Duration ¶
func (f *FieldCollection) Duration(name string) (time.Duration, error)
Duration tries to read key name as time.Duration
func (*FieldCollection) Expect ¶
func (f *FieldCollection) Expect(keys ...string) error
Expect takes a list of keys and returns an error with all non-found names
func (*FieldCollection) HasAll ¶
func (f *FieldCollection) HasAll(keys ...string) bool
HasAll takes a list of keys and returns whether all of them exist inside the FieldCollection
func (*FieldCollection) Int64 ¶
func (f *FieldCollection) Int64(name string) (int64, error)
Int64 tries to read key name as int64
func (*FieldCollection) MarshalJSON ¶
func (f *FieldCollection) MarshalJSON() ([]byte, error)
func (*FieldCollection) MarshalYAML ¶
func (f *FieldCollection) MarshalYAML() (any, error)
func (*FieldCollection) MustBool ¶
func (f *FieldCollection) MustBool(name string, defVal *bool) bool
MustBool is a wrapper around Bool and panics if an error was returned
func (*FieldCollection) MustDuration ¶
MustDuration is a wrapper around Duration and panics if an error was returned
func (*FieldCollection) MustInt64 ¶
func (f *FieldCollection) MustInt64(name string, defVal *int64) int64
MustInt64 is a wrapper around Int64 and panics if an error was returned
func (*FieldCollection) MustString ¶
func (f *FieldCollection) MustString(name string, defVal *string) string
MustString is a wrapper around String and panics if an error was returned
func (*FieldCollection) MustStringSlice ¶ added in v3.8.0
func (f *FieldCollection) MustStringSlice(name string) []string
MustStringSlice is a wrapper around StringSlice and returns nil in case name is not set
func (*FieldCollection) Set ¶
func (f *FieldCollection) Set(key string, value any)
Set sets a single key to specified value
func (*FieldCollection) SetFromData ¶
func (f *FieldCollection) SetFromData(data map[string]any)
SetFromData takes a map of data and copies all data into the FieldCollection
func (*FieldCollection) String ¶
func (f *FieldCollection) String(name string) (string, error)
String tries to read key name as string
func (*FieldCollection) StringSlice ¶
func (f *FieldCollection) StringSlice(name string) ([]string, error)
StringSlice tries to read key name as []string
func (*FieldCollection) UnmarshalJSON ¶
func (f *FieldCollection) UnmarshalJSON(raw []byte) error
func (*FieldCollection) UnmarshalYAML ¶
func (f *FieldCollection) UnmarshalYAML(unmarshal func(any) error) error
type HTTPRouteRegistrationArgs ¶
type HTTPRouteRegistrationArgs struct { Accept []string Description string HandlerFunc http.HandlerFunc IsPrefix bool Method string Module string Name string Path string QueryParams []HTTPRouteParamDocumentation RequiresEditorsAuth bool RequiresWriteAuth bool ResponseType HTTPRouteResponseType RouteParams []HTTPRouteParamDocumentation SkipDocumentation bool }
type HTTPRouteRegistrationFunc ¶
type HTTPRouteRegistrationFunc func(HTTPRouteRegistrationArgs) error
type HTTPRouteResponseType ¶
type HTTPRouteResponseType uint64
const ( HTTPRouteResponseTypeNo200 HTTPRouteResponseType = iota HTTPRouteResponseTypeTextPlain HTTPRouteResponseTypeJSON HTTPRouteResponseTypeMultiple )
type LoggerCreationFunc ¶
type MsgFormatter ¶
type MsgModificationFunc ¶
type MsgModificationRegistrationFunc ¶
type MsgModificationRegistrationFunc func(linePrefix string, modFn MsgModificationFunc)
type RawMessageHandlerFunc ¶
type RawMessageHandlerRegisterFunc ¶
type RawMessageHandlerRegisterFunc func(RawMessageHandlerFunc) error
type RegisterFunc ¶
type RegisterFunc func(RegistrationArguments) error
RegisterFunc is the type of function your plugin must expose with the name Register
type RegistrationArguments ¶
type RegistrationArguments struct { // CreateEvent allows to create an event handed out to all modules to handle CreateEvent EventHandlerFunc // FormatMessage is a method to convert templates into strings using internally known variables / configs FormatMessage MsgFormatter // FrontendNotify is a way to send a notification to the frontend FrontendNotify func(string) // GetDatabaseConnector returns an active database.Connector to access the backend storage database GetDatabaseConnector func() database.Connector // GetLogger returns a sirupsen log.Entry pre-configured with the module name GetLogger LoggerCreationFunc // GetTwitchClient retrieves a fully configured Twitch client with initialized cache GetTwitchClient func() *twitch.Client // GetTwitchClientForChannel retrieves a fully configured Twitch client with initialized cache for extended permission channels GetTwitchClientForChannel func(string) (*twitch.Client, error) // HasAnyPermissionForChannel checks whether ANY of the given permissions were granted for the given channel HasAnyPermissionForChannel ChannelAnyPermissionCheckFunc // HasPermissionForChannel checks whether ALL of the given permissions were granted for the given channel HasPermissionForChannel ChannelPermissionCheckFunc // RegisterActor is used to register a new IRC rule-actor implementing the Actor interface RegisterActor ActorRegistrationFunc // RegisterActorDocumentation is used to register an ActorDocumentation for the config editor RegisterActorDocumentation ActorDocumentationRegistrationFunc // RegisterAPIRoute registers a new HTTP handler function including documentation RegisterAPIRoute HTTPRouteRegistrationFunc // RegisterCron is a method to register cron functions in the global cron instance RegisterCron CronRegistrationFunc // RegisterEventHandler is a method to register a handler function receiving ALL events RegisterEventHandler EventHandlerRegisterFunc // RegisterMessageModFunc is a method to register a handler to modify / react on messages RegisterMessageModFunc MsgModificationRegistrationFunc // RegisterRawMessageHandler is a method to register an handler to receive ALL messages received RegisterRawMessageHandler RawMessageHandlerRegisterFunc // RegisterTemplateFunction can be used to register a new template functions RegisterTemplateFunction TemplateFuncRegister // SendMessage can be used to send a message not triggered by an event SendMessage SendMessageFunc // ValidateToken offers a way to validate a token and determine whether it has permissions on a given module ValidateToken ValidateTokenFunc }
type Rule ¶
type Rule struct { UUID string `hash:"-" json:"uuid,omitempty" yaml:"uuid,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` SubscribeFrom *string `json:"subscribe_from,omitempty" yaml:"subscribe_from,omitempty"` Actions []*RuleAction `json:"actions,omitempty" yaml:"actions,omitempty"` Cooldown *time.Duration `json:"cooldown,omitempty" yaml:"cooldown,omitempty"` ChannelCooldown *time.Duration `json:"channel_cooldown,omitempty" yaml:"channel_cooldown,omitempty"` UserCooldown *time.Duration `json:"user_cooldown,omitempty" yaml:"user_cooldown,omitempty"` SkipCooldownFor []string `json:"skip_cooldown_for,omitempty" yaml:"skip_cooldown_for,omitempty"` MatchChannels []string `json:"match_channels,omitempty" yaml:"match_channels,omitempty"` MatchEvent *string `json:"match_event,omitempty" yaml:"match_event,omitempty"` MatchMessage *string `json:"match_message,omitempty" yaml:"match_message,omitempty"` MatchUsers []string `json:"match_users,omitempty" yaml:"match_users,omitempty" ` DisableOnMatchMessages []string `json:"disable_on_match_messages,omitempty" yaml:"disable_on_match_messages,omitempty"` Disable *bool `json:"disable,omitempty" yaml:"disable,omitempty"` DisableOnOffline *bool `json:"disable_on_offline,omitempty" yaml:"disable_on_offline,omitempty"` DisableOnPermit *bool `json:"disable_on_permit,omitempty" yaml:"disable_on_permit,omitempty"` DisableOnTemplate *string `json:"disable_on_template,omitempty" yaml:"disable_on_template,omitempty"` DisableOn []string `json:"disable_on,omitempty" yaml:"disable_on,omitempty"` EnableOn []string `json:"enable_on,omitempty" yaml:"enable_on,omitempty"` // contains filtered or unexported fields }
func (*Rule) GetMatchMessage ¶
func (*Rule) Matches ¶
func (r *Rule) Matches(m *irc.Message, event *string, timerStore TimerStore, msgFormatter MsgFormatter, twitchClient *twitch.Client, eventData *FieldCollection) bool
func (*Rule) SetCooldown ¶
func (r *Rule) SetCooldown(timerStore TimerStore, m *irc.Message, evtData *FieldCollection)
func (*Rule) UpdateFromSubscription ¶
func (Rule) Validate ¶
func (r Rule) Validate(tplValidate TemplateValidatorFunc) error
type RuleAction ¶
type RuleAction struct { Type string `json:"type" yaml:"type,omitempty"` Attributes *FieldCollection `json:"attributes" yaml:"attributes,omitempty"` }
type SendMessageFunc ¶
type StorageManager ¶
type StorageManager interface { DeleteModuleStore(moduleUUID string) error GetModuleStore(moduleUUID string, storedObject StorageUnmarshaller) error SetModuleStore(moduleUUID string, storedObject StorageMarshaller) error }
type StorageMarshaller ¶
type StorageUnmarshaller ¶
type TemplateFuncDocumentation ¶ added in v3.17.0
type TemplateFuncDocumentation struct { Name string Description string Syntax string Example *TemplateFuncDocumentationExample Remarks string }
type TemplateFuncDocumentationExample ¶ added in v3.17.0
type TemplateFuncGetter ¶
type TemplateFuncGetter func(*irc.Message, *Rule, *FieldCollection) interface{}
func GenericTemplateFunctionGetter ¶
func GenericTemplateFunctionGetter(f interface{}) TemplateFuncGetter
type TemplateFuncRegister ¶
type TemplateFuncRegister func(name string, fg TemplateFuncGetter, doc ...TemplateFuncDocumentation)