From 4c618df245d179d97da440520b94ae4d11a1e681 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 10 Aug 2016 13:48:43 -0600 Subject: fix bug getting memebers of channels --- warmachine/connections/slack.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/warmachine/connections/slack.py b/warmachine/connections/slack.py index e4823df..613b15c 100644 --- a/warmachine/connections/slack.py +++ b/warmachine/connections/slack.py @@ -242,22 +242,28 @@ class SlackWS(Connection): def get_users_by_channel(self, channel): - url = 'https://slack.com/api/groups.info?{}'.format(urlencode( + if channel.startswith('G'): + key = 'group' + elif channel.startswith('C'): + key = 'channel' + else: + return + + url = 'https://slack.com/api/{}s.info?{}'.format( + key, urlencode( { 'token': self.token, 'channel': channel, })) + self.log.debug(url) req = urllib.request.Request(url) r = json.loads(urllib.request.urlopen(req).read().decode('utf-8')) self.log.debug(r) - if channel.startswith('G'): - key = 'group' - elif channel.startswith('C'): - key = 'channel' + self.log.debug(pformat(r[key]['members'])) - return r['group']['members'] + return r[key]['members'] async def on_group_join(self, channel): """ -- cgit v1.2.1