From 7f6830e3770d260ca28ef4e978d32980909e1d65 Mon Sep 17 00:00:00 2001 From: Felipe M Date: Tue, 2 Feb 2021 12:55:26 +0100 Subject: [PATCH] Slack: Support private channels --- butterrobot/platforms/slack.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/butterrobot/platforms/slack.py b/butterrobot/platforms/slack.py index f8a615e..aa1b133 100644 --- a/butterrobot/platforms/slack.py +++ b/butterrobot/platforms/slack.py @@ -76,11 +76,16 @@ class SlackPlatform(Platform): logger.debug("Discarding message", data=data) return - if data["event"]["type"] != "message": + logger.debug("Parsing message", platform=cls.ID, data=data) + + if data["event"]["type"] not in ("message", "message.groups"): return - logger.debug("Parsing message", platform=cls.ID, data=data) - return Message( + # Surprisingly, this *can* happen. + if "text" not in data["event"]: + return + + message = Message( id=data["event"].get("thread_ts", data["event"]["ts"]), author=data["event"].get("user"), from_bot="bot_id" in data["event"], @@ -90,3 +95,11 @@ class SlackPlatform(Platform): channel=cls.parse_channel_from_message(data), raw=data, ) + + logger.info( + "New message", + platform=message.channel.platform, + channel=cls.parse_channel_name_from_raw(message.channel.channel_raw), + ) + + return message