Class WordFilter
Model for Word Filters. Input strings are matched against RegularExpressions to replace any blacklisted words with the ReplaceWith text. If IgnoreCase is provided then the regular expression can be more simple and match more aggressively to catch words where people may try to avoid the filter by writing "pOOp" instead of "poop". regex must be generated and applied outside of this class. See the System.Text.RegularExpressions.Regex documentation for how to build it correctly, or just use RebuildWordFilterDictionary().
Example setup: RegularExpression = "cats" ReplaceWith = "*" IgnoreCase = true User inputs: "I love CATS!" Message sent over network: "I love *!" All users receive "I love *!"
Inheritance
Inherited Members
Namespace: LlamaSoftware.Chat.UI
Assembly: LlamaSoftware.Chat.dll
Syntax
[Serializable]
public class WordFilter
Fields
IgnoreCase
Recommended to be true. This allows more simple RegularExpressions to block more simple ways people tend to try to get around word filters. For example, if true a "poop" RegularExpression will block "PooP". If false, this string would not be matched and would not be blocked.
If you change this value at runtime you must regenerate the regex.
Declaration
public bool IgnoreCase
Field Value
Type | Description |
---|---|
System.Boolean |
regex
The actual System.Text.RegularExpressions.Regex that will be used to System.Text.RegularExpressions.Regex.IsMatch(System.String)ed against.
Declaration
public Regex regex
Field Value
Type | Description |
---|---|
System.Text.RegularExpressions.Regex |
RegularExpression
The regular expression that will be tested against. Does not have to be in the format "/regularExpressionHere/g". It can be just "regularexpression" See System.Text.RegularExpressions.Regex documentation for more details.
If you change this value at runtime you must regenerate the regex.
Declaration
public string RegularExpression
Field Value
Type | Description |
---|---|
System.String |
ReplaceWith
Text to replace the matched text with. For example if you block "cats", and this is set to "*" we will put "*" in place of "cats".
Declaration
public string ReplaceWith
Field Value
Type | Description |
---|---|
System.String |