Created
          April 27, 2015 05:12 
        
      - 
      
 - 
        
Save ymyzk/6edb75862c3a2bd0852e to your computer and use it in GitHub Desktop.  
Revisions
- 
        
ymyzk revised this gist
Apr 27, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def get_emojis(token): response = requests.get("https://slack.com/api/emoji.list", params={"token": token}) return response.json()  - 
        
ymyzk renamed this gist
Apr 27, 2015 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
ymyzk created this gist
Apr 27, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ from __future__ import unicode_literals import os import sys import requests def get_emojis(token): response = requests.get("https://slack.com/api/emoji.list", params={ "token": token }) return response.json() def download_emojis(emojis, path): for name, url in emojis.items(): print(name) if url.startswith("alias:"): continue try: response = requests.get(url) content_type = response.headers["content-type"] if content_type == "image/png": extension = "png" elif content_type == "image/jpeg": extension = "jpg" else: extension = "" image_file = os.path.join(path, name + "." + extension) with open(image_file, "wb") as f: f.write(response.content) except requests.RequestException as e: print(e) if __name__ == "__main__": token = os.environ.get("SLACK_API_TOKEN") if token is None: sys.exit(1) if len(sys.argv) <= 1: sys.exit(1) path = sys.argv[1] result = get_emojis(token) if not result["ok"]: sys.exit(1) download_emojis(result["emoji"], path) sys.exit(0)