Created
November 9, 2017 00:32
-
-
Save tanookiben/a27ae143b763645bde4173523c35be35 to your computer and use it in GitHub Desktop.
Slack Emojis
This file contains hidden or 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 'net/http' | |
require 'json' | |
token = ENV['SLACK_API_TOKEN'] | |
srcdir = ENV['SOURCE_DIR'] | |
base = 'https://slack.com/api/emoji.list' | |
url = "#{base}?token=#{token}" | |
res = Net::HTTP.get(URI(url)) | |
body = JSON.parse(res) | |
emoji = body['emoji'] | |
emoji.each do |name, src| | |
src.match(/(\.\w{3}\z)/) | |
ext = $1 | |
if !ext.nil? | |
filename = "#{name}#{ext}" | |
filepath = "#{srcdir}/#{filename}" | |
if !File.exists?(filepath) | |
puts "Saving #{filename}" | |
system("wget --quiet -O \"#{filepath}\" #{src} >/dev/null") | |
else | |
puts "Skipping #{filename}" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment