Update ChatFilter.plugin.js
This commit is contained in:
parent
399b368203
commit
923e6339c2
|
@ -14,13 +14,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ChatFilter",
|
||||
"author": "DevilBro",
|
||||
"version": "3.4.6",
|
||||
"version": "3.4.7",
|
||||
"description": "Allow the user to censor words or block complete messages based on words in the chatwindow"
|
||||
},
|
||||
"changeLog": {
|
||||
"fixed": {
|
||||
"Embeds": "Now also checks the description of embeds for blocked/censored words",
|
||||
"Reply Previews": "Now also works for replied message previews"
|
||||
"added": {
|
||||
"Segment Option": "You can now enable the Segment option for censored Words to only replace Segments of Words"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -71,17 +70,18 @@ module.exports = (_ => {
|
|||
onLoad () {
|
||||
this.defaults = {
|
||||
configs: {
|
||||
empty: {value: false, description: "Allow the replacevalue to be empty (ignoring the default)"},
|
||||
case: {value: false, description: "Handle the wordvalue case sensitive"},
|
||||
exact: {value: true, description: "Handle the wordvalue as an exact word and not as part of a word"},
|
||||
regex: {value: false, description: "Handle the wordvalue as a RegExp string"}
|
||||
empty: {value: false, noBlocked: false, description: "Allow the Replacement Value to be empty (ignoring the default)"},
|
||||
case: {value: false, noBlocked: false, description: "Handle the Word Value case sensitive"},
|
||||
exact: {value: true, noBlocked: false, description: "Handle the Word Value as an exact Word and not as part of a Word"},
|
||||
segment: {value: false, noBlocked: true, description: "Only replace the caught Segment of the Word with the Replacement"},
|
||||
regex: {value: false, noBlocked: false, description: "Handle the Word Value as a RegExp String"}
|
||||
},
|
||||
replaces: {
|
||||
blocked: {value: "~~BLOCKED~~", description: "Default replaceword for blocked messages: "},
|
||||
censored: {value: "$!%&%!&", description: "Default replaceword for censored messages: "}
|
||||
blocked: {value: "~~BLOCKED~~", description: "Default Replacement Word for blocked Messages: "},
|
||||
censored: {value: "$!%&%!&", description: "Default Replacement Word for censored Messages: "}
|
||||
},
|
||||
settings: {
|
||||
addContextMenu: {value: true, description: "Add a contextmenu entry to faster add new blocked/censored words: "}
|
||||
addContextMenu: {value: true, description: "Add a Context Menu Entry to faster add new blocked/censored Words: "}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -147,7 +147,7 @@ module.exports = (_ => {
|
|||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Button",
|
||||
label: "Pick a wordvalue and replacevalue:",
|
||||
label: "Pick a Word Value and Replacement Value:",
|
||||
key: "ADDBUTTON",
|
||||
disabled: !Object.keys(values).every(valuename => values[valuename]),
|
||||
children: BDFDB.LanguageUtils.LanguageStrings.ADD,
|
||||
|
@ -160,10 +160,10 @@ module.exports = (_ => {
|
|||
].flat(10).filter(n => n)
|
||||
}));
|
||||
for (let rType in replaces) if (!BDFDB.ObjectUtils.isEmpty(words[rType])) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.CollapseContainer, {
|
||||
title: `Added ${rType} words`,
|
||||
title: `Added ${rType} Words`,
|
||||
collapseStates: collapseStates,
|
||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsList, {
|
||||
settings: Object.keys(this.defaults.configs),
|
||||
settings: Object.keys(this.defaults.configs).filter(n => !this.defaults.configs[n]["no" + BDFDB.LibraryModules.StringUtils.upperCaseFirstChar(rType)]),
|
||||
data: Object.keys(words[rType]).map(wordvalue => Object.assign({}, words[rType][wordvalue], {
|
||||
key: wordvalue,
|
||||
label: wordvalue
|
||||
|
@ -212,9 +212,9 @@ module.exports = (_ => {
|
|||
children: Object.keys(replaces).map(rType => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsItem, {
|
||||
type: "Button",
|
||||
color: BDFDB.LibraryComponents.Button.Colors.RED,
|
||||
label: `Remove all ${rType} words`,
|
||||
label: `Remove all ${rType} Words`,
|
||||
onClick: _ => {
|
||||
BDFDB.ModalUtils.confirm(this, `Are you sure you want to remove all ${rType} words?`, _ => {
|
||||
BDFDB.ModalUtils.confirm(this, `Are you sure you want to remove all ${rType} Words?`, _ => {
|
||||
words[rType] = {};
|
||||
BDFDB.DataUtils.remove(this, "words", rType);
|
||||
BDFDB.PluginUtils.refreshSettingsPanel(this, settingsPanel, collapseStates);
|
||||
|
@ -227,11 +227,13 @@ module.exports = (_ => {
|
|||
title: "Config Guide",
|
||||
collapseStates: collapseStates,
|
||||
children: [
|
||||
"Case: Will block/censor words while comparing lowercase/uppercase. apple => apple, not APPLE or AppLe",
|
||||
"Not Case: Will block/censor words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe",
|
||||
"Exact: Will block/censor words that are exactly the selected word. apple => apple, not applepie or pineapple",
|
||||
"Not Exact: Will block/censor all words containing the selected word. apple => apple, applepie and pineapple",
|
||||
"Empty: Ignores the default and set replace word and removes the word/message instead.",
|
||||
"Case: Will block/censor Words while comparing lowercase/uppercase. apple => apple, not APPLE or AppLe",
|
||||
"Not Case: Will block/censor Words while ignoring lowercase/uppercase. apple => apple, APPLE and AppLe",
|
||||
"Exact: Will block/censor Words that are exactly the selected Word. apple => apple, not applepie or pineapple",
|
||||
"Not Exact: Will block/censor all Words containing the selected Word. apple => apple, applepie and pineapple",
|
||||
"Segment: Will only replace the caught segment in the censored Word. apple with peach => applepie => peachpie",
|
||||
"Not Segment: Will replae the whole censored Word. apple with peach => applepie => peach",
|
||||
"Empty: Ignores the default/choosen Replacement Word and removes the Word/Message instead.",
|
||||
[
|
||||
"Regex: Will treat the entered wordvalue as a regular expression. ",
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Anchor, {href: "https://regexr.com/", children: BDFDB.LanguageUtils.LanguageStrings.HELP + "?"})
|
||||
|
@ -395,7 +397,7 @@ module.exports = (_ => {
|
|||
let censoredReplace = words.censored[cWord].empty ? "" : (words.censored[cWord].replace || replaces.censored);
|
||||
let reg = this.createReg(cWord, words.censored[cWord]);
|
||||
let newString = [];
|
||||
if (words.censored[cWord].regex || cWord.indexOf(" ") > -1) {
|
||||
if (words.censored[cWord].segment || words.censored[cWord].regex || cWord.indexOf(" ") > -1) {
|
||||
if (this.testWord(string, reg)) {
|
||||
singleCensored = true;
|
||||
censored = true;
|
||||
|
@ -491,11 +493,11 @@ module.exports = (_ => {
|
|||
key: "WORDVALUE",
|
||||
value: values.wordvalue,
|
||||
placeholder: values.wordvalue,
|
||||
errorMessage: !values.wordvalue && "Choose a wordvalue" || words[values.choice][values.wordvalue] && `Wordvalue already used, saving will overwrite old ${values.choice} word`,
|
||||
errorMessage: !values.wordvalue && "Choose a Word Value" || words[values.choice][values.wordvalue] && `Word Value already used, saving will overwrite old ${values.choice} Word`,
|
||||
onChange: (value, instance) => {
|
||||
values.wordvalue = value.trim();
|
||||
if (!values.wordvalue) instance.props.errorMessage = "Choose a wordvalue";
|
||||
else if (words[values.choice][values.wordvalue]) instance.props.errorMessage = `Wordvalue already used, saving will overwrite old ${values.choice} word`;
|
||||
if (!values.wordvalue) instance.props.errorMessage = "Choose a Word Value";
|
||||
else if (words[values.choice][values.wordvalue]) instance.props.errorMessage = `Word Value already used, saving will overwrite old ${values.choice} word`;
|
||||
else delete instance.props.errorMessage;
|
||||
let addButtonIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "ADDBUTTON"});
|
||||
if (addButtonIns) {
|
||||
|
@ -525,8 +527,8 @@ module.exports = (_ => {
|
|||
values.choice = value.value;
|
||||
let wordvalueInputIns = BDFDB.ReactUtils.findOwner(BDFDB.ReactUtils.findOwner(instance, {name: ["BDFDB_Modal", "BDFDB_SettingsPanel"], up: true}), {key: "WORDVALUE"});
|
||||
if (wordvalueInputIns) {
|
||||
if (!values.wordvalue) wordvalueInputIns.props.errorMessage = "Choose a wordvalue";
|
||||
else if (words[values.choice][values.wordvalue]) wordvalueInputIns.props.errorMessage = `Wordvalue already used, saving will overwrite old ${values.choice} word`;
|
||||
if (!values.wordvalue) wordvalueInputIns.props.errorMessage = "Choose a Word Value";
|
||||
else if (words[values.choice][values.wordvalue]) wordvalueInputIns.props.errorMessage = `Word Value already used, saving will overwrite old ${values.choice} Word`;
|
||||
else delete wordvalueInputIns.props.errorMessage;
|
||||
BDFDB.ReactUtils.forceUpdate(wordvalueInputIns);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue