From 052742b478a66dff4352e61a8c6e18214558e40b Mon Sep 17 00:00:00 2001 From: Ben Date: Wed, 22 Apr 2020 21:41:27 +0100 Subject: [PATCH] Fix StopIteration error when chat filter active but not triggered --- houdini/handlers/play/message.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/houdini/handlers/play/message.py b/houdini/handlers/play/message.py index cbd64ec..6b336e3 100644 --- a/houdini/handlers/play/message.py +++ b/houdini/handlers/play/message.py @@ -26,14 +26,14 @@ async def handle_send_message(p, penguin_id: int, message: str): 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)) + consequence = next((c for w, c in p.server.chat_filter_words.items() if w in tokens), None) - 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 is not None: + if consequence.ban: + await moderator_ban(p, p.id, comment='Inappropriate language', message=message) + return + if consequence.filter: + return if has_command_prefix(p.server.config.command_prefix, message): await invoke_command_string(p.server.commands, p, message)