gofuckyourself: github.com/JoshuaDoes/gofuckyourself Index | Files

package swearfilter

import "github.com/JoshuaDoes/gofuckyourself"


Package Files


type SwearFilter Uses

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 Uses

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 Uses

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

Package swearfilter imports 5 packages (graph). Updated 2018-11-18. Refresh now. Tools for package owners.