diff options
Diffstat (limited to 'warmachine/connections')
| -rw-r--r-- | warmachine/connections/slack.py | 18 |
1 files 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): | |||
| 242 | 242 | ||
| 243 | 243 | ||
| 244 | def get_users_by_channel(self, channel): | 244 | def get_users_by_channel(self, channel): |
| 245 | url = 'https://slack.com/api/groups.info?{}'.format(urlencode( | 245 | if channel.startswith('G'): |
| 246 | key = 'group' | ||
| 247 | elif channel.startswith('C'): | ||
| 248 | key = 'channel' | ||
| 249 | else: | ||
| 250 | return | ||
| 251 | |||
| 252 | url = 'https://slack.com/api/{}s.info?{}'.format( | ||
| 253 | key, urlencode( | ||
| 246 | { | 254 | { |
| 247 | 'token': self.token, | 255 | 'token': self.token, |
| 248 | 'channel': channel, | 256 | 'channel': channel, |
| 249 | })) | 257 | })) |
| 258 | |||
| 250 | self.log.debug(url) | 259 | self.log.debug(url) |
| 251 | req = urllib.request.Request(url) | 260 | req = urllib.request.Request(url) |
| 252 | r = json.loads(urllib.request.urlopen(req).read().decode('utf-8')) | 261 | r = json.loads(urllib.request.urlopen(req).read().decode('utf-8')) |
| 253 | 262 | ||
| 254 | self.log.debug(r) | 263 | self.log.debug(r) |
| 255 | if channel.startswith('G'): | 264 | |
| 256 | key = 'group' | ||
| 257 | elif channel.startswith('C'): | ||
| 258 | key = 'channel' | ||
| 259 | self.log.debug(pformat(r[key]['members'])) | 265 | self.log.debug(pformat(r[key]['members'])) |
| 260 | return r['group']['members'] | 266 | return r[key]['members'] |
| 261 | 267 | ||
| 262 | async def on_group_join(self, channel): | 268 | async def on_group_join(self, channel): |
| 263 | """ | 269 | """ |