1
0
Fork 0
slack-emojinator/README.md

55 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2015-02-25 04:12:41 +00:00
# Slack Emojinator
*Bulk upload emoji into Slack*
Want to create a custom Slack emoji for every pokemon? Slack doesn't currently expose an API endpoint for creating emoji, probably to prevent users from doing exactly what I'm doing, but here's a way to do it anyway.
## Creating Emoji
2017-10-21 00:53:50 +00:00
You'll need Python and `pip` to get started. I recommend using [pipenv](https://docs.pipenv.org/).
2015-02-25 04:12:41 +00:00
Prepare a directory that contains an image for each emoji you want to create. Remember to respect Slack's specifications for valid emoji images: no greater than 128px in width or height, no greater than 64K in image size. The base filename of each image file should be the name of the emoji (the bit you'll type inside `:` to display it).
2017-10-21 00:53:50 +00:00
Clone the project and install its prereqs:
2015-02-25 04:12:41 +00:00
`libxml` is required on your system, if you'd like to use the bulk export script.
2015-02-25 04:12:41 +00:00
```bash
git clone https://github.com/smashwilson/slack-emojinator.git
cd slack-emojinator
2017-10-21 00:53:50 +00:00
pipenv install
2015-02-25 04:12:41 +00:00
```
2015-02-25 04:16:19 +00:00
You'll need to provide your team name (the bit before ".slack.com" in your admin URL) and your session cookie (grab it from your browser). Copy `.env.example`, fill them in, and source it.
To grab your Slack session cookie:
2017-10-21 00:53:50 +00:00
* [Open your browser's dev tools](http://webmasters.stackexchange.com/a/77337) and copy the value of `document.cookie`.
* Go to the Network tab.
* Re-load your workspace's `https://{teamname}.slack.com/customize/emoji` page.
* Find the call to `emoji` (it is most likely the very top request).
* Scroll to `Request-Headers`, copy the value of "Cookie," and add to your `.env` file.
2016-07-31 17:38:39 +00:00
2015-02-25 04:16:19 +00:00
```bash
cp .env.example .env
${EDITOR} .env
source .env
```
2015-02-25 04:12:41 +00:00
Now you're ready to go. Use a shell glob to invoke `upload.py` with the emoji files as ARGV:
```bash
2017-10-21 01:11:03 +00:00
pipenv run python upload.py ${EMOJI_DIR}/*.png
2015-02-25 04:12:41 +00:00
```
:sparkles:
## Exporting Emoji
2017-10-21 01:04:55 +00:00
To export emoji, use `export.py` and specify an emoji directory:
```bash
source .env
2017-10-21 01:11:03 +00:00
pipenv run python export.py path-to-destination/
```