From 77c5b5754e6fd21d1cc032dab81aea4e0d44904a Mon Sep 17 00:00:00 2001 From: Russell Osborne Date: Sat, 19 Nov 2016 20:25:08 -0500 Subject: [PATCH] Pass all events to handlers vs noop --- README.md | 1 + lib/lita/adapters/slack/message_handler.rb | 8 +++++--- spec/lita/adapters/slack/message_handler_spec.rb | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cc94cd9..e80242f 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,7 @@ Lita will join your default channel after initial setup. To have it join additio * `:slack_reaction_added` - When a reaction has been added to a previous message. The payload includes `:user` (a `Lita::User` for the sender of the message in question), `:name` (the string name of the reaction added), `:item_user` (a `Lita::User` for the user that created the original item that has been reacted to), `:item` (a hash of raw data from Slack about the message), and `:event_ts` (a string timestamp used to identify the message). * `:slack_reaction_removed` - When a reaction has been removed from a previous message. The payload is the same as the `:slack_reaction_added` message. * `:slack_user_created` - When the robot creates/updates a user's info - name, mention name, etc., as directed by Slack. The payload has a single object, a `Lita::Slack::Adapters::SlackUser` object, under the `:slack_user` key. +* `:slack_<>` - All other event types, such as presence_change are called with the entire body of the event from slack. ## Chat service API diff --git a/lib/lita/adapters/slack/message_handler.rb b/lib/lita/adapters/slack/message_handler.rb index ab7ed22..7d0697e 100644 --- a/lib/lita/adapters/slack/message_handler.rb +++ b/lib/lita/adapters/slack/message_handler.rb @@ -179,9 +179,11 @@ def handle_reaction end def handle_unknown - unless data["reply_to"] - log.debug("#{type} event received from Slack and will be ignored.") - end + return if data["reply_to"] + + log.info("slack_#{type} event received from Slack.") + + robot.trigger("slack_#{type}".to_sym, data) end def handle_user_change diff --git a/spec/lita/adapters/slack/message_handler_spec.rb b/spec/lita/adapters/slack/message_handler_spec.rb index e42f176..4fd6f2f 100644 --- a/spec/lita/adapters/slack/message_handler_spec.rb +++ b/spec/lita/adapters/slack/message_handler_spec.rb @@ -649,8 +649,8 @@ let(:data) { { "type" => "???" } } it "logs the type" do - expect(Lita.logger).to receive(:debug).with( - "??? event received from Slack and will be ignored." + expect(Lita.logger).to receive(:info).with( + "??? event received from Slack." ) subject.handle