Last active
April 20, 2021 16:13
-
-
Save hkurokawa/0a96997644368e4151fb6cfcf1fe7200 to your computer and use it in GitHub Desktop.
Bash scripts to export custom emojis in a slack team
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
#! /bin/bash | |
TOKEN=xxxxx | |
curl -s -XPOST "https://slack.com/api/emoji.list?token=${TOKEN}" | jq -r '.emoji | to_entries[] | select(.value | test("^alias:") | not) | [.key, .value] | @tsv' | while IFS=$'\t' read -r emoji url; do | |
file="${emoji}.${url##*.}" | |
if [ ! -f ${file} ]; then | |
echo "The file does not exist: ${file}" | |
continue | |
fi | |
expected_size=$(curl -sI ${url} | awk '/Content-Length/{print $2}' | tr -d "\r\n") | |
actual_size=$(stat -f%z ${file}) | |
if [ $actual_size -ne $expected_size ]; then | |
echo "The file size does not match, ${file} for ${url}: actual=${actual_size}, expected=${expected_size}" | |
fi | |
done |
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
#! /bin/bash | |
TOKEN=xxxxx | |
# Only download non-alias emojis | |
curl -s -XPOST "https://slack.com/api/emoji.list?token=${TOKEN}" | jq -r '.emoji | to_entries[] | select(.value | test("^alias:") | not) | [.key, .value] | @tsv' | while IFS=$'\t' read -r emoji url; do | |
file="${emoji}.${url##*.}" | |
curl -s ${url} --output ${file} | |
done |
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
#! /bin/bash | |
TOKEN=xxxxx | |
# Print each emoji in a line like 'my_emoji\thttps://emoji.slack-edge.com/XXXXXXXXX/my_emoji/xxxxxxxx.png' | |
curl -s -XPOST "https://slack.com/api/emoji.list?token=${TOKEN}" | jq -r '.emoji | to_entries[] | [.key, .value] | @tsv' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment