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

Commit

Permalink
Clean up attachment logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmycuadra committed Apr 9, 2015
1 parent 6f4081e commit 2403957
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/lita/adapters/slack/message_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ def handle
attr_reader :type

def body
full_text = []
message_text = data["text"].to_s.sub(/^\s*<@#{robot_id}>/, "@#{robot.mention_name}")
full_text << message_text unless message_text == ''
data["attachments"].each do |attach|
next if attach["text"] == ( '' || nil )
full_text << attach["text"]
end if data["attachments"]
full_text.join("\n")
normalized_message = if data["text"]
data["text"].sub(/^\s*<@#{robot_id}>/, "@#{robot.mention_name}")
end

attachment_text = Array(data["attachments"]).map do |attachment|
attachment["text"]
end

([normalized_message] + attachment_text).compact.join("\n")
end

def channel
Expand Down

0 comments on commit 2403957

Please sign in to comment.