-
-
Save threetreeslight/8dbfa59eb56403353673a1f0f056d5dd to your computer and use it in GitHub Desktop.
slack teamのactiveなアカウントの画像をDLしてくれる君
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "slack" | |
require 'open-uri' | |
YOUR_SLACK_APP_OAUTH_TOKEN = ENV['YOUR_SLACK_APP_OAUTH_TOKEN'] | |
Slack.configure do |config| | |
config.token = YOUR_SLACK_APP_OAUTH_TOKEN | |
end | |
members = Slack.users_list["members"].select { |m| !m["deleted"] } | |
members.each.with_index do |member, idx| | |
puts "=================== #{idx} =======================" if idx % 10 == 0 | |
profile = member["profile"] | |
url = profile["image_original"] | |
if url.nil? || url.empty? | |
url = profile["image_512"] | |
end | |
puts url | |
filename = "#{profile["real_name"]}___#{profile["display_name"]}.png".gsub(" ", "_") | |
puts filename | |
begin | |
file = open(url) | |
IO.copy_stream(file, "./images/#{filename}") | |
rescue e | |
puts "FAILED!!!" | |
puts "filename: #{filename}" | |
puts "url: #{url}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment