Simp-O-Matic

Dumb Discord bot in TS.
git clone git://git.knutsen.co/Simp-O-Matic
Log | Files | Refs | README | LICENSE

commit b7593535f2b3624b27136f2400a0c4fb38a1eae4
parent 4b5abce2c6dc9da08f303eac1985d9634a45666f
Author: Demonstrandum <moi@knutsen.co>
Date:   Mon, 23 Mar 2020 17:53:37 +0000

Trigger stores regex, and needs special duplicate identification.

Diffstat:
Mlib/main.ts | 2+-
Mlib/utils.ts | 4++--
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/main.ts b/lib/main.ts @@ -521,7 +521,7 @@ pastebin_latest().then(res => { // Precompile all regular-expressions in known places. for(const guild in GLOBAL_CONFIG.guilds) if (GLOBAL_CONFIG.guilds.hasOwnProperty(guild)) - ['respond', 'reject', 'replace'] + ['respond', 'reject', 'replace', 'trigger'] .each(name => GLOBAL_CONFIG.guilds[guild].rules[name] .mut_map(compile_match)); diff --git a/lib/utils.ts b/lib/utils.ts @@ -108,12 +108,12 @@ export const recursive_regex_to_string = o => { export const export_config = (obj: Types.GlobalConfig, { ugly = false }) => { const o: Types.GlobalConfig = recursive_regex_to_string(deep_clone(obj)); + // Make sure all rules are unique, // i.e. eliminate duplicate rules. - for (const guild in obj.guilds) if (obj.guilds.hasOwnProperty(guild)) - ['respond', 'reject', 'replace'] + ['respond', 'reject', 'replace', 'trigger'] .each(name => o.guilds[guild].rules[name] = o.guilds[guild].rules[name] .map(JSON.stringify) .unique()