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

Pass all events to handlers vs noop #111

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
"slack_??? event received from Slack."
)

subject.handle
Expand Down