Skip to content

Instantly share code, notes, and snippets.

@danielktaylor
Last active April 4, 2017 17:21
Show Gist options
  • Save danielktaylor/a911c318f9b0ec11dc40a0029e9ce8df to your computer and use it in GitHub Desktop.
Save danielktaylor/a911c318f9b0ec11dc40a0029e9ce8df to your computer and use it in GitHub Desktop.
**** Script will take about an hour to upload a few thousand emoji ****
1) Go to the emoji list webpage for your Slack team and save the HTML as emoji.html
2) Download all of the emoji with a Python script:
import re
import urllib
f = open('./emoji.html')
line = f.read().replace('\n', ' ')
matches = re.findall( r'(emoji\.slack\-edge\.com\/.+?\/(.+?)\/.+?(\..+?))\"', line, re.M)
print str(len(matches)) + " icons found."
for m in matches:
filename = m[1] + m[2]
url = "https://" + m[0]
urllib.urlretrieve(url, filename)
3) Clone this repo: https://github.com/CodeBuffet/Slekkel
4) Follow the installation instructions, but don't run it yet
5) Add your emoji to the "emoji_to_upload" folder
6) Add support for JPEG files in Main.coffee:
modify:
if stat.name.endsWith(".png") or stat.name.endsWith(".gif")
to:
if stat.name.endsWith(".png") or stat.name.endsWith(".gif") or stat.name.endsWith(".jpeg") or stat.name.endsWith(".jpg")
7) The program doesn't work with more than ~250 files because the command gets too long for Bash. Change everything after "prompt.start()" in Main.coffee to: (this runs all batches concurrently)
prompt.start()
prompt.get properties, (err, result) ->
if err
console.log err
return null
listEmoji (files) ->
batch = []
filesLength = files.length
i = 0
while i < filesLength
batch.push files[i]
if i % 250 == 0 or i + 1 == filesLength
binPath = './node_modules/casperjs/bin/casperjs'
childArgs = [
'--ssl-protocol=any'
'--engine=slimerjs'
path.join(__dirname, 'Scrape.coffee')
result.domain
result.email
result.password
batch.join('...')
]
childProcess.execFile binPath, childArgs, (err, stdout, stderr) ->
console.log 'Result:\n' + stdout + '\nerror: ' + err + ' ' + stderr
batch = []
i++
return null
7) Quit Slack - it tries to pull the emoji list every time you add an emoji and melts your computer
8) Run the script ("make run")
When it asks for the team name, that's the short name: e.g. http://myteam.slack.com is "myteam"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment