Back to godoc.org
github.com/JoshuaDoes/gofuckyourself

package swearfilter

v0.0.0 (9fac380)
Latest Go to latest
Published: Nov 18, 2018 | License: MIT | Module: github.com/JoshuaDoes/gofuckyourself

Index

type SwearFilter

type SwearFilter struct {
	//Options to tell the swear filter how to operate
	DisableNormalize                bool //Disables normalization of alphabetic characters if set to true (ex: à -> a)
	DisableSpacedTab                bool //Disables converting tabs to singular spaces (ex: [tab][tab] -> [space][space])
	DisableMultiWhitespaceStripping bool //Disables stripping down multiple whitespaces (ex: hello[space][space]world -> hello[space]world)
	DisableZeroWidthStripping       bool //Disables stripping zero-width spaces
	DisableSpacedBypass             bool //Disables testing for spaced bypasses (if hell is in filter, look for occurrences of h and detect only alphabetic characters that follow; ex: h[space]e[space]l[space]l[space] -> hell)

	BlacklistedWords []string //A list of words to blacklist
}

SwearFilter contains settings for the swear filter

func New

func New(disableNormalize, disableSpacedTab, disableMutliWhitespaceStripping, disableZeroWidthStripping, disableSpacedBypass bool, words ...string) (filter *SwearFilter)

New returns an initialized SwearFilter struct to check messages against

func (*SwearFilter) Check

func (filter *SwearFilter) Check(message string) (bool, []string, error)

Check checks if a message contains blacklisted words and returns whether or not it does, a list of blacklisted words if so, and any errors returned by external packages

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier