lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-3.1.1 vs lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-3.2.0
- old
+ new
@@ -34,28 +34,31 @@
channel: channel,
text: message[:code] ? "```\n#{message[:body]}\n```" : message[:body],
parse: message[:parse] || 'full',
unfurl_links: true,
as_user: true,
- attachments: message[:attachments].to_json
+ attachments: message[:attachments].to_json,
+ thread_ts: message[:thread_ts] || message[:original][:thread_ts]
)
elsif message[:file]
path = message[:file][:path]
client.files_upload(
channels: channel,
as_user: true,
file: Faraday::UploadIO.new(path, message[:file][:content_type]),
title: message[:file][:title] || path,
filename: File.basename(path),
- initial_comment: message[:body] || ''
+ initial_comment: message[:body] || '',
+ thread_ts: message[:thread_ts] || message[:original][:thread_ts]
)
else
client.chat_postMessage(
channel: channel,
text: message[:code] ? "```\n#{message[:body]}\n```" : resolve_send_mention(message[:body]),
as_user: true,
- mrkdwn: true
+ mrkdwn: true,
+ thread_ts: message[:thread_ts] || message[:original][:thread_ts]
)
end
end
def add_reaction(reaction, channel_id, timestamp)
@@ -154,10 +157,12 @@
from: data['channel'],
from_name: user['name'],
to: channel_to,
channel: channel,
user: user,
+ ts: data['ts'],
+ thread_ts: data['thread_ts'],
time: Time.at(data['ts'].to_f)
}
text, mention_to = extract_mention(data['text'])
robot.receive(message_info.merge(body: text, mention_to: mention_to))
@@ -235,10 +240,10 @@
[CGI.unescapeHTML(text), mention_to]
end
def resolve_send_mention(text)
- text = text.to_s
+ text = text.dup.to_s
text.gsub!(/@(?<mention>[0-9a-z._-]+)/) do |_|
mention = Regexp.last_match[:mention]
msg = "@#{mention}"
@user_info_caches.each_pair do |id, user|