code: def list_slack():
      
      try:
          token = os.environ['SLACK_TOKEN']
          slack = Slacker(token)
  
          # Get channel list
          response = slack.channels.list()
          channels = response.body['channels']
          for channel in channels:
              print(channel['id'], channel['name'])
              # if not channel['is_archived']:
              # slack.channels.join(channel['name'])
          print()
  
          # Get users list
          response = slack.users.list()
          users = response.body['members']
          for user in users:
              if not user['deleted']:
                  print(user['id'], user['name'], user['is_admin'], user[
                      'is_owner'])
          print()
      except KeyError as ex:
          print('Environment variable %s not set.' % str(ex))
docs: List channels & users in slack.