rule

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FilterBundle

type FilterBundle struct {
	Filters []FilterRule
}

Describes a group of filters, all the filter results are ANDed together.

func (FilterBundle) Filter

func (fb FilterBundle) Filter(msg message.Message) bool

type FilterRule

type FilterRule struct {
	// Return true if the message should be handled by the handler, false otherwise
	Filter func(msg message.Message) bool
}

Describes a filter rule, you can create your own filter by implementing this.

func Command

func Command(prefixList []string) FilterRule

Command creates a filter rule that matches if the raw message is a command and is in the prefixList.

func FullMatch

func FullMatch(strs []string) FilterRule

FullMatch creates a filter rule that matches if the raw message is the same with one of the strings.

func Keyword

func Keyword(keywords []string, forceStart bool) FilterRule

Keyword creates a filter rule that matches if the raw message contains one of the keywords.

If forceStart is true, the keyword must be at the start of the message.

func OfType

func OfType(typeName, adapterName string) FilterRule

OfType filters messages that has the specified type for specified adapter

You must be sure the message has at least one segment

func RegEx

func RegEx(pluginName string, exprs []string) FilterRule

RegEx creates a filter rule that matches if the raw message does match one of the RegEx expressions.

If you wrote a wrong RegEx expression, an error message with plugin name will be printed.

func ToMe

func ToMe() FilterRule

ToMe filters messages that are directed to the bot.(@bot or private message, should be identified by adapters)

If your adapter don't, what can i say?

Jump to

Keyboard shortcuts

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