Fixed style bypass.

This commit is contained in:
Niels Simenon
2022-11-01 05:26:04 +01:00
parent 89dc51e3e9
commit 007773f38c
4 changed files with 15 additions and 16 deletions

View File

@@ -39,29 +39,19 @@ function shieldMethods(methods) {
const styleMethods = (() => {
if (config.platform === 'irc') {
return shieldMethods({
return {
...styles,
code: bypass,
});
};
}
if (config.platform === 'schat') {
const methods = {
return {
bold: schatBold,
italic: schatItalic,
code: schatCode,
...Object.fromEntries(Object.entries(config.schatColorAliases).map(([color, value]) => [color, (text) => schatColor(text, value)])),
};
const handler = {
get(target, prop) {
return target[prop] || bypass;
},
};
const shieldedMethods = shieldMethods(methods);
return new Proxy(shieldedMethods, handler);
}
return null;
@@ -74,4 +64,12 @@ const expandedMethods = {
answer: (value) => styleMethods.bold(styleMethods.yellow(value)),
};
module.exports = expandedMethods;
const handler = {
get(target, prop) {
return target[prop] || bypass;
},
};
const shieldedMethods = shieldMethods(expandedMethods);
module.exports = new Proxy(shieldedMethods, handler);