-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathears.rb
More file actions
31 lines (25 loc) · 772 Bytes
/
ears.rb
File metadata and controls
31 lines (25 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'colorize'
require 'pry-rails'
load 'util/db.rb'
load 'util/slack_cache.rb'
messages = Slack.get_messages["messages"]
users = SlackCache.fetch(:users)
messages.reverse!.each do |message|
time = Time.at(message["ts"].split(".").first.to_i).strftime("%F %T")
user = users.find { |u| u["id"] == message["user"] }
text = message["text"]
text.dup.scan(/<@(\w{9})>/) do |matches|
matches.each do |match|
user = users.find { |u| u["id"] == match }
text.gsub!("@#{match}", "@#{user["name"]}".cyan)
end
end
text.gsub!("!here", "@here".cyan)
text.gsub!("!channel", "@channel".cyan)
# thread = Slack.get_replies(reply: message["ts"])
begin
puts [time.yellow, user["name"].red, text].join(" ")
rescue
puts "..."
end
end