Created
April 22, 2018 04:53
-
-
Save pybites/61a88eb1eaca7fa689b506696e24287f to your computer and use it in GitHub Desktop.
script to get timezone distribution of our slack community
This file contains 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
from collections import Counter | |
import os | |
import sys | |
from slackclient import SlackClient | |
token = os.environ.get('SLACK_TOKEN') or sys.exit('need slack api token') | |
client = SlackClient(token) | |
users = client.api_call("users.list") | |
timezones = Counter() | |
for u in users['members']: | |
tz = u.get('tz') | |
if tz: | |
timezones[tz] += 1 | |
for location, count in sorted(timezones.items()): | |
print(f'{location:<20} | {"+"*count}') |
and pip install slackclient
and token used is a legacy one: https://api.slack.com/custom-integrations/legacy-tokens
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
seems module / class changed, now do
import slack
andclient = slack.WebClient(token=token)