From 7af9344a002b0e59b98f398c88d6d1fd6f0c127a Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 14 Mar 2020 18:25:32 +0000 Subject: [PATCH] Fix StopIteration exception thrown when `chat_filter_words` is empty --- houdini/handlers/play/message.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/houdini/handlers/play/message.py b/houdini/handlers/play/message.py index 8e7f737..a51f6a7 100644 --- a/houdini/handlers/play/message.py +++ b/houdini/handlers/play/message.py @@ -25,16 +25,17 @@ async def handle_send_message(p, penguin_id: int, message: str): await penguin.send_xt("mm", message, penguin_id) return - tokens = message.lower().split() + if p.server.chat_filter_words: + tokens = message.lower().split() - word, consequence = next(((w, c) for w, c in p.server.chat_filter_words.items() if w in tokens)) + word, consequence = next(((w, c) for w, c in p.server.chat_filter_words.items() if w in tokens)) - if consequence.ban: - return await moderator_ban(p, p.id, comment='Inappropriate language', message=message) - elif consequence.warn: - return - elif consequence.filter: - return + if consequence.ban: + return await moderator_ban(p, p.id, comment='Inappropriate language', message=message) + elif consequence.warn: + return + elif consequence.filter: + return if has_command_prefix(p.server.config.command_prefix, message): await invoke_command_string(p.server.commands, p, message)