lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-2.5.1 vs lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-2.6.0

- old
+ new

@@ -1,7 +1,8 @@ require 'cgi' require 'time' +require 'json' require 'slack' require 'ruboty/adapters/base' module Ruboty module Adapters @@ -25,15 +26,26 @@ channel = resolve_channel_id(channel[1..-1]) end return unless channel - realtime.send_message( - type: 'message', - channel: channel, - text: message[:code] ? "```\n#{message[:body]}\n```" : resolve_send_mention(message[:body]), - mrkdwn: true - ) + if message[:attachments] && !message[:attachments].empty? + client.chat_postMessage( + channel: channel, + text: message[:code] ? "```\n#{message[:body]}\n```" : message[:body], + parse: 'full', + unfurl_links: true, + as_user: true, + attachments: message[:attachments].to_json + ) + else + realtime.send_message( + type: 'message', + channel: channel, + text: message[:code] ? "```\n#{message[:body]}\n```" : resolve_send_mention(message[:body]), + mrkdwn: true + ) + end end private def init