Skip to content

Instantly share code, notes, and snippets.

@hkurokawa
Last active April 20, 2021 16:13
Show Gist options
  • Save hkurokawa/0a96997644368e4151fb6cfcf1fe7200 to your computer and use it in GitHub Desktop.
Save hkurokawa/0a96997644368e4151fb6cfcf1fe7200 to your computer and use it in GitHub Desktop.
Bash scripts to export custom emojis in a slack team
#! /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
#! /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
#! /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