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

Commit

Permalink
Merge pull request #188 from tristaneuan/message_received
Browse files Browse the repository at this point in the history
Trigger :message_received whenever robot.receive is called
  • Loading branch information
jimmycuadra committed May 31, 2016
2 parents b2a66f1 + a8a581c commit 3a545e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/lita/robot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ def async_dispatch?
# @param message [Message] The incoming message.
# @return [void]
def receive(message)
trigger(:message_received, message: message)

matched = handlers.map do |handler|
next unless handler.respond_to?(:dispatch)

Expand Down
1 change: 1 addition & 0 deletions spec/lita/handler/chat_router_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def trigger_route_hook(response)
end

it "triggers a message_dispatched event" do
expect(robot).to receive(:trigger).with(:message_received, anything)
expect(robot).to receive(:trigger).with(:message_dispatched, anything)
send_message("message")
end
Expand Down

0 comments on commit 3a545e5

Please sign in to comment.