Skip to content

Instantly share code, notes, and snippets.

@pybites
Created April 22, 2018 04:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pybites/61a88eb1eaca7fa689b506696e24287f to your computer and use it in GitHub Desktop.
Save pybites/61a88eb1eaca7fa689b506696e24287f to your computer and use it in GitHub Desktop.
script to get timezone distribution of our slack community
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}')
@pybites
Copy link
Author

pybites commented Aug 20, 2019

seems module / class changed, now do import slack and client = slack.WebClient(token=token)

@bbelderbos
Copy link

bbelderbos commented Sep 26, 2019

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