Skip to content

Commit 22433c8

Browse files
[1.0.0] Initial Release
1 parent 1969de4 commit 22433c8

21 files changed

+3118
-104
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ If you want to add or remove custom words from the default profanity filter. You
130130

131131
```ini
132132
# This file is a template to show how to add words
133-
# Do NOT anything else other than the words separated by ', '
134-
133+
# Do NOT add anything else other than the words separated by ', '
134+
# Remember to remove these three lines before using this file
135135
word1, word2, word3
136136
```
137137

VPlusChatFilter/FamilyFriendlyfier.cs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace VPlusChatFilter
9+
{
10+
public static class FamilyFriendlyfier
11+
{
12+
public static ProfanityFilter.ProfanityFilter filter;
13+
14+
public static void Initialise()
15+
{
16+
filter = new ProfanityFilter.ProfanityFilter();
17+
}
18+
19+
public static string[] GetWordsFromFile(string filename)
20+
{
21+
string reader = "";
22+
using (StreamReader sr = new StreamReader(Path.Combine(BepInEx.Paths.PluginPath, "Filters", filename)))
23+
{
24+
string line;
25+
// Read and display lines from the file until the end of
26+
// the file is reached.
27+
while ((line = sr.ReadLine()) != null)
28+
{
29+
reader += line;
30+
}
31+
}
32+
string[] words = reader.Split(',');
33+
return words;
34+
}
35+
}
36+
}
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# This file is a template to show how to add words
2+
# Do NOT anything else other than the words separated by the , symbol
3+
4+
word1, word2, word3

VPlusChatFilter/FodyWeavers.xml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
<Costura>
33
<IncludeAssemblies>
44
INIFileParser
5-
YamlDotNet
65
</IncludeAssemblies>
76
</Costura>
87
</Weavers>

VPlusChatFilter/FodyWeavers.xsd

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
4+
<xs:element name="Weavers">
5+
<xs:complexType>
6+
<xs:all>
7+
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
8+
<xs:complexType>
9+
<xs:all>
10+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
11+
<xs:annotation>
12+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
13+
</xs:annotation>
14+
</xs:element>
15+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
16+
<xs:annotation>
17+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
18+
</xs:annotation>
19+
</xs:element>
20+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
21+
<xs:annotation>
22+
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
23+
</xs:annotation>
24+
</xs:element>
25+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
26+
<xs:annotation>
27+
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
28+
</xs:annotation>
29+
</xs:element>
30+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
31+
<xs:annotation>
32+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
33+
</xs:annotation>
34+
</xs:element>
35+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
36+
<xs:annotation>
37+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
38+
</xs:annotation>
39+
</xs:element>
40+
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
41+
<xs:annotation>
42+
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
43+
</xs:annotation>
44+
</xs:element>
45+
</xs:all>
46+
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
47+
<xs:annotation>
48+
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
49+
</xs:annotation>
50+
</xs:attribute>
51+
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
52+
<xs:annotation>
53+
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
54+
</xs:annotation>
55+
</xs:attribute>
56+
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
57+
<xs:annotation>
58+
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
59+
</xs:annotation>
60+
</xs:attribute>
61+
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
62+
<xs:annotation>
63+
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
64+
</xs:annotation>
65+
</xs:attribute>
66+
<xs:attribute name="DisableCompression" type="xs:boolean">
67+
<xs:annotation>
68+
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
69+
</xs:annotation>
70+
</xs:attribute>
71+
<xs:attribute name="DisableCleanup" type="xs:boolean">
72+
<xs:annotation>
73+
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
74+
</xs:annotation>
75+
</xs:attribute>
76+
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
77+
<xs:annotation>
78+
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
79+
</xs:annotation>
80+
</xs:attribute>
81+
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
82+
<xs:annotation>
83+
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
84+
</xs:annotation>
85+
</xs:attribute>
86+
<xs:attribute name="ExcludeAssemblies" type="xs:string">
87+
<xs:annotation>
88+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
89+
</xs:annotation>
90+
</xs:attribute>
91+
<xs:attribute name="IncludeAssemblies" type="xs:string">
92+
<xs:annotation>
93+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
94+
</xs:annotation>
95+
</xs:attribute>
96+
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
97+
<xs:annotation>
98+
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
99+
</xs:annotation>
100+
</xs:attribute>
101+
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
102+
<xs:annotation>
103+
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
104+
</xs:annotation>
105+
</xs:attribute>
106+
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
107+
<xs:annotation>
108+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
109+
</xs:annotation>
110+
</xs:attribute>
111+
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
112+
<xs:annotation>
113+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
114+
</xs:annotation>
115+
</xs:attribute>
116+
<xs:attribute name="PreloadOrder" type="xs:string">
117+
<xs:annotation>
118+
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
119+
</xs:annotation>
120+
</xs:attribute>
121+
</xs:complexType>
122+
</xs:element>
123+
</xs:all>
124+
<xs:attribute name="VerifyAssembly" type="xs:boolean">
125+
<xs:annotation>
126+
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
127+
</xs:annotation>
128+
</xs:attribute>
129+
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
130+
<xs:annotation>
131+
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
132+
</xs:annotation>
133+
</xs:attribute>
134+
<xs:attribute name="GenerateXsd" type="xs:boolean">
135+
<xs:annotation>
136+
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
137+
</xs:annotation>
138+
</xs:attribute>
139+
</xs:complexType>
140+
</xs:element>
141+
</xs:schema>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
MIT License
3+
Copyright (c) 2019
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
SOFTWARE.
19+
*/
20+
using System;
21+
using System.Collections.Generic;
22+
using System.Collections.ObjectModel;
23+
using System.Globalization;
24+
using ProfanityFilter.Interfaces;
25+
26+
namespace ProfanityFilter
27+
{
28+
public class AllowList : IAllowList
29+
{
30+
List<string> _allowList;
31+
32+
public AllowList()
33+
{
34+
_allowList = new List<string>();
35+
}
36+
37+
/// <summary>
38+
/// Return an instance of a read only collection containing allow list
39+
/// </summary>
40+
public ReadOnlyCollection<string> ToList
41+
{
42+
get
43+
{
44+
return new ReadOnlyCollection<string>(_allowList);
45+
}
46+
}
47+
48+
/// <summary>
49+
/// Add a word to the profanity allow list. This means a word that is in the allow list
50+
/// can be ignored. All words are treated as case insensitive.
51+
/// </summary>
52+
/// <param name="wordToAllowlist">The word that you want to allow list.</param>
53+
public void Add(string wordToAllowlist)
54+
{
55+
if (string.IsNullOrEmpty(wordToAllowlist))
56+
{
57+
throw new ArgumentNullException(nameof(wordToAllowlist));
58+
}
59+
60+
if (!_allowList.Contains(wordToAllowlist.ToLower(CultureInfo.InvariantCulture)))
61+
{
62+
_allowList.Add(wordToAllowlist.ToLower(CultureInfo.InvariantCulture));
63+
}
64+
}
65+
66+
/// <summary>
67+
///
68+
/// </summary>
69+
/// <param name="wordToCheck"></param>
70+
/// <returns></returns>
71+
public bool Contains(string wordToCheck)
72+
{
73+
if (string.IsNullOrEmpty(wordToCheck))
74+
{
75+
throw new ArgumentNullException(nameof(wordToCheck));
76+
}
77+
78+
return _allowList.Contains(wordToCheck.ToLower(CultureInfo.InvariantCulture));
79+
}
80+
81+
/// <summary>
82+
/// Return the number of items in the allow list.
83+
/// </summary>
84+
/// <returns>The number of items in the allow list.</returns>
85+
public int Count
86+
{
87+
get
88+
{
89+
return _allowList.Count;
90+
}
91+
}
92+
93+
/// <summary>
94+
/// Remove all words from the allow list.
95+
/// </summary>
96+
public void Clear()
97+
{
98+
_allowList.Clear();
99+
}
100+
101+
/// <summary>
102+
/// Remove a word from the profanity allow list. All words are treated as case insensitive.
103+
/// </summary>
104+
/// <param name="wordToRemove">The word that you want to use</param>
105+
/// <returns>True if the word is successfuly removes, False otherwise.</returns>
106+
public bool Remove(string wordToRemove)
107+
{
108+
if (string.IsNullOrEmpty(wordToRemove))
109+
{
110+
throw new ArgumentNullException(nameof(wordToRemove));
111+
}
112+
113+
return _allowList.Remove(wordToRemove.ToLower(CultureInfo.InvariantCulture));
114+
}
115+
}
116+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
MIT License
3+
Copyright (c) 2019
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
SOFTWARE.
19+
*/
20+
using System;
21+
using System.Collections.ObjectModel;
22+
23+
namespace ProfanityFilter.Interfaces
24+
{
25+
public interface IAllowList
26+
{
27+
void Add(string wordToAllowlist);
28+
bool Contains(string wordToCheck);
29+
bool Remove(string wordToRemove);
30+
void Clear();
31+
int Count { get; }
32+
ReadOnlyCollection<string> ToList { get; }
33+
}
34+
}

0 commit comments

Comments
 (0)