rules

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RuleAction

type RuleAction struct {
	Type actions.ActionType `yaml:"type"`

	// Optional fields depending on the action
	ChannelID string `yaml:"channelId,omitempty"`
	Message   string `yaml:"message,omitempty"`
	Duration  string `yaml:"duration,omitempty"`
	Reason    string `yaml:"reason,omitempty"`
}

type RuleMeta

type RuleMeta struct {
	Event      event.EventType `yaml:"event"`
	IgnoreBots bool            `yaml:"ignoreBots"`
}

type RuleString

type RuleString struct {
	Name  string `yaml:"name"`
	Value string `yaml:"value"`
}

type SimplifiedRule

type SimplifiedRule struct {
	Name       string
	Disabled   bool
	Event      event.EventType
	IgnoreBots bool

	Strings map[string]RuleString
	Program cel.Program

	Actions []RuleAction

	RawExpression string
}

func Load

func Load(dir string) ([]*SimplifiedRule, map[string]*SimplifiedRule, error)

func Parse

func Parse(filePath string) ([]*SimplifiedRule, error)

func (*SimplifiedRule) Evaluate

func (r *SimplifiedRule) Evaluate(ctx *event.Context) (bool, error)

type YAMLRule

type YAMLRule struct {
	Rule struct {
		Name       string       `yaml:"name"`
		Disabled   bool         `yaml:"disabled"`
		Meta       RuleMeta     `yaml:"meta"`
		Strings    []RuleString `yaml:"strings"`
		Expression string       `yaml:"expression"`
		Actions    []RuleAction `yaml:"actions"`
	} `yaml:"rule"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL