From eb39a4f3afe50759586c855c18f21ab3d0b3530f Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 28 Jan 2019 23:14:07 +0100 Subject: [PATCH] When the message uses a language with no configured blacklist, use default --- mod_pottymouth/src/mod_pottymouth.erl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mod_pottymouth/src/mod_pottymouth.erl b/mod_pottymouth/src/mod_pottymouth.erl index 008371d..0dab4d2 100644 --- a/mod_pottymouth/src/mod_pottymouth.erl +++ b/mod_pottymouth/src/mod_pottymouth.erl @@ -44,6 +44,15 @@ filterWords(L) -> lists:map(fun censorWord/1, L). filterMessageText(Lang, MessageText) -> + try filterMessageText2(Lang, MessageText) of + R -> + R + catch exit:{noproc,{gen_server,call,[_,_]}} -> + ?DEBUG("Blacklist of language '~p' not found, using 'default' list.", [Lang]), + filterMessageText2(default, MessageText) + end. + +filterMessageText2(Lang, MessageText) -> % we want to token-ize utf8 'words' MessageWords = string:tokens(unicode:characters_to_list(MessageText, utf8), " "), MessageTerms = [{Lang, Word} || Word <- MessageWords],