matchers

package
v0.2.5-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NumberMatchedString                = "number"
	PositiveNumberMatchedString        = "positive_number"
	AnyMatchedString                   = "any"
	FirstWordMatchedString             = "first_word"
	PositiveNumberInWordsMatchedString = "positive_number_in_words"
)
View Source
const (
	AgreeMatchedString = "Точно!"
)

Variables

View Source
var (
	NumberMatcher         = NewRegexMather(`[\-]{0,1}[0-9]+[\.][0-9]+|[\-]{0,1}[0-9]+`, NumberMatchedString)
	PositiveNumberMatcher = NewRegexMather(
		`^\+?(0*[1-9]\d*(?:[\., ]\d+)*) *(?:\p{Sc}|°[FC])?$`,
		PositiveNumberMatchedString,
	)
	AnyMatcher       = NewRegexMather(`.*`, AnyMatchedString)
	FirstWordMatcher = NewRegexMather(`[^\s]+`, FirstWordMatchedString)
)
View Source
var (
	PositiveNumberError = scene.BaseTextError{
		Message: positiveNumberErrorString,
	}
	NumberError = scene.BaseTextError{
		Message: numberErrorString,
	}
)
View Source
var Agree = NewSelectorMatcher(
	[]string{
		"Точно",
		"Согласен",
		"Да",
		"Ага",
	},
	AgreeMatchedString,
)
View Source
var PositiveNumberInWordsMatcher = NumberMatchers{}

Functions

This section is empty.

Types

type NumberMatchers

type NumberMatchers struct{}

func (NumberMatchers) GetMatchedName

func (nm NumberMatchers) GetMatchedName() string

func (NumberMatchers) Match

func (nm NumberMatchers) Match(message string) (bool, string)

type RegexMatcher

type RegexMatcher struct {
	// contains filtered or unexported fields
}

func NewRegexMather

func NewRegexMather(pattern, nameMatched string) *RegexMatcher

func (*RegexMatcher) GetMatchedName

func (rm *RegexMatcher) GetMatchedName() string

func (*RegexMatcher) Match

func (rm *RegexMatcher) Match(message string) (bool, string)

type SelectorMatcher

type SelectorMatcher struct {
	// contains filtered or unexported fields
}

func NewSelectorMatcher

func NewSelectorMatcher(variants []string, replaceMessage string) *SelectorMatcher

func (*SelectorMatcher) GetMatchedName

func (sm *SelectorMatcher) GetMatchedName() string

func (*SelectorMatcher) Match

func (sm *SelectorMatcher) Match(message string) (bool, string)

Jump to

Keyboard shortcuts

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