brrrrrrrrrrrrrrrrrrr

This commit is contained in:
Erik 2021-06-09 14:33:46 +03:00
parent 98692a8d62
commit 3b55561b89
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
3 changed files with 4 additions and 4 deletions

View File

@ -41,7 +41,7 @@ class Manager extends EventEmitter {
await this.shardManager.spawn();
// G:\Documents\My programs\GBot\New GBot\api\index.cjs
this.info('Shards done, booting up API...');
const API = await import('./api/index.js').catch((err) => this.error(`Import of API Manager failed.\n${err.stack}`));
const API = await import('./api/index.js').catch(() => this.warn(`Import of API Manager failed. Skipping API.`));
if (API) {
const { default: APIManager } = API;
this.apiManager = new APIManager(this);

View File

@ -78,7 +78,7 @@ module.exports = class WordFilter extends FilterSetting {
} else if (['explicit', 'fuzzy', 'regex', 'whitelist'].includes(method)) {
const [first, ...rest] = args; // First arg should skip sanitisation
if (method === 'regex') args = rest.map((arg) => Util.sanitiseRegex(arg));
if (method === 'regex') args = rest.map((arg) => Util.sanitiseRegex(arg, ['?', '\\', '(', ')', '|', '\\[', '\\]', '.', '-']));
const resolved = await resolver.resolveMethod([first, ...args], {
existing: setting[method],
allowedMethods: ['add', 'remove', 'set', 'reset']

View File

@ -124,11 +124,11 @@ class Util {
*
* @static
* @param {string} input
* @param {string} [allowed=['?', '\\', '(', ')', '|']]
* @param {string[]} [allowed=['?', '\\', '(', ')', '|']]
* @return {string} The sanitised expression
* @memberof Util
*/
static sanitiseRegex(input, allowed = ['?', '\\', '(', ')', '|', '\\[', '\\]', '.']) {
static sanitiseRegex(input, allowed = ['?', '\\', '(', ')', '|']) {
if (!input) throw new Error('Missing input');
const reg = new RegExp(`[${this.regChars.filter((char) => !allowed.includes(char)).join('')}]`, 'gu');
return input.replace(reg, '\\$&');