def list_channels():
"""
helper method for listing all slack channels
:return: None
"""
bot_token = ENV_DICT.get('SLACKBOT_TOKEN')
if not bot_token:
return []
sc = SlackClient(bot_token)
channels = sc.api_call('channels.list')
# this is to make this function backwards-compatible with older version of SlackClient which returns a string
if isinstance(channels, basestring):
channels = json.loads(channels)
return channels
# construct a map from slack channel name to slack channel id (the format that the API expects)
评论列表
文章目录