Skip to content

Instantly share code, notes, and snippets.

@brodygov
Forked from alex/download-slack-emoji.py
Last active October 2, 2018 21:25
Show Gist options
  • Select an option

  • Save brodygov/72a6f94aea390e6238ea9d8cd1f1e287 to your computer and use it in GitHub Desktop.

Select an option

Save brodygov/72a6f94aea390e6238ea9d8cd1f1e287 to your computer and use it in GitHub Desktop.

Revisions

  1. brodygov revised this gist Oct 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion download-slack-emoji.py
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    from __future__ import print_function
    #!/usr/bin/env python3

    import os
    import sys
  2. brodygov revised this gist Oct 2, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion download-slack-emoji.py
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@
    def main(argv):
    if len(argv) != 3:
    print("Usage: python download-emoji.py <token> <target-file>", file=sys.stderr)
    os.exit(1)
    sys.exit(1)

    [_, token, path] = argv
    session = requests.session()
  3. @alex alex created this gist Nov 12, 2017.
    33 changes: 33 additions & 0 deletions download-slack-emoji.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    from __future__ import print_function

    import os
    import sys
    import zipfile

    import requests


    def main(argv):
    if len(argv) != 3:
    print("Usage: python download-emoji.py <token> <target-file>", file=sys.stderr)
    os.exit(1)

    [_, token, path] = argv
    session = requests.session()
    metadata = session.get(
    "https://slack.com/api/emoji.list?token={}".format(token)
    ).json()
    assert metadata["ok"]
    print("Downloading {} emoji...".format(len(metadata["emoji"])))
    with zipfile.ZipFile(path, "w") as zf:
    for name, url in metadata["emoji"].items():
    if url.startswith("alias:"):
    continue
    print("Downloading :{}:...".format(name))
    data = session.get(url).content
    zf.writestr(name + ".png", data)
    print("Your emoji are ready! " + path)


    if __name__ == "__main__":
    main(sys.argv)