1
0
Fork 0

Initial work.

This commit is contained in:
Ash Wilson 2015-02-22 11:29:55 -05:00
parent 91b553d0bd
commit 91d1f70d38
2 changed files with 32 additions and 0 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
export SLACK_TEAM=
export SLACK_COOKIE=
export SLACK_CRUMB=

29
upload.py Normal file
View File

@ -0,0 +1,29 @@
# Upload files named on ARGV as Slack emoji.
import os
import sys
import requests
team_name = os.getenv('SLACK_TEAM')
cookie = os.getenv('SLACK_COOKIE')
crumb = os.getenv('SLACK_CRUMB')
url = "https://{}.slack.com/customize/emoji".format(team_name)
for filename in sys.argv[1:]:
print("Processing {}.".format(filename))
emoji_name = os.path.basename(filename)
headers = {
'Cookie': cookie,
}
data = {
'add': 1,
'crumb': crumb,
'name': emoji_name,
'mode': 'data',
}
files = {'img': open(filename, 'rb')}
r = requests.post(url, headers=headers, data=data, files=files, allow_redirects=False)
r.raise_for_status()