diff --git a/README.md b/README.md index 88f3f14..a7603d2 100644 --- a/README.md +++ b/README.md @@ -150,11 +150,10 @@ Example (for being reminded one week after the ctf has finished): ## Log command deletion -To enable logging of deleting messages containing specific keywords, set `delete_watch_keywords` in `config/config.json` to a comma separated list of keywords. -Clear or remove the setting to disable deletion logging. +To enable logging of deleting messages containing specific keywords, set `delete_watch_keywords` in `config/config.json` to an array of strings to watch for. Example ``` { - "delete_watch_keywords" : "workon, reload, endctf" + "delete_watch_keywords" : ["workon", "reload", "endctf"] } diff --git a/config/config.json.template b/config/config.json.template index 6959cc1..3ffdffc 100644 --- a/config/config.json.template +++ b/config/config.json.template @@ -8,7 +8,7 @@ "wolfram_app_id" : "", "archive_ctf_reminder_offset" : "168", "archive_everything": true, - "delete_watch_keywords" : "", + "delete_watch_keywords" : [], "intro_message" : "", "private_ctfs": false, "allow_signup": false, diff --git a/server/botserver.py b/server/botserver.py index 5a2a108..5ff923c 100644 --- a/server/botserver.py +++ b/server/botserver.py @@ -96,16 +96,14 @@ def parse_slack_message(self, message_list): self.slack_wrapper.post_message(msg['channel'], warning) # Check for deletion of messages containing keywords elif "subtype" in msg and msg["subtype"] == "message_deleted": - log_deletions = self.get_config_option("delete_watch_keywords") + delete_keywords = self.get_config_option("delete_watch_keywords") - if log_deletions: - previous_msg = msg['previous_message']['text'] - delete_keywords = log_deletions.split(",") + previous_msg = msg['previous_message']['text'] - if any(keyword.strip() in previous_msg for keyword in delete_keywords): - user_name = self.slack_wrapper.get_member(msg['previous_message']['user']) - display_name = get_display_name(user_name) - self.slack_wrapper.post_message(msg['channel'], "*{}* deleted : `{}`".format(display_name, previous_msg)) + if any(keyword in previous_msg for keyword in delete_keywords): + user_name = self.slack_wrapper.get_member(msg["previous_message"]["user"]) + display_name = get_display_name(user_name) + self.slack_wrapper.post_message(msg['channel'], "*{}* deleted : `{}`".format(display_name, previous_msg)) # Greet new users elif msg.get("type") == "im_created": self.slack_wrapper.post_message(msg['user'], self.get_config_option("intro_message"))