Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Pass all events to handlers vs noop
Browse files Browse the repository at this point in the history
  • Loading branch information
rposborne committed Nov 20, 2016
1 parent 862ec72 commit 77c5b57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_slack_event_types>>` - All other event types, such as presence_change are called with the entire body of the event from slack.

## Chat service API

Expand Down
8 changes: 5 additions & 3 deletions lib/lita/adapters/slack/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/lita/adapters/slack/message_handler_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 77c5b57

Please sign in to comment.