Skip to content

Commit

Permalink
add limit 1000 to for listing more channels
Browse files Browse the repository at this point in the history
  • Loading branch information
sgratzl committed Jun 25, 2020
1 parent 52fd809 commit 35ea052
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions slack_cleaner/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,28 +328,28 @@ def match_by_key(pattern, items, key, equality_match):


def get_channel_ids_by_pattern(pattern, equality_match):
res = slack.conversations.list(types='public_channel').body
res = slack.conversations.list(types='public_channel', limit=1000).body
if not res['ok'] or not res['channels']:
return []
return match_by_key(pattern, res['channels'], lambda c: c['name'], equality_match)


def get_direct_ids_by_pattern(pattern, equality_match):
res = slack.conversations.list(types='im').body
res = slack.conversations.list(types='im', limit=1000).body
if not res['ok'] or not res['channels']:
return []
return match_by_key(pattern, res['channels'], lambda i: get_user(i['user']), equality_match)


def get_group_ids_by_pattern(pattern, equality_match):
res = slack.conversations.list(types='private_channel').body
res = slack.conversations.list(types='private_channel', limit=1000).body
if not res['ok'] or not res['channels']:
return []
return match_by_key(pattern, res['channels'], lambda c: c['name'], equality_match)


def get_mpdirect_ids_by_pattern(pattern):
res = slack.conversations.list(types='mpim').body
res = slack.conversations.list(types='mpim', limit=1000).body
if not res['ok'] or not res['channels']:
return []
mpims = res['channels']
Expand All @@ -374,7 +374,7 @@ def matches_members(members):


def get_mpdirect_ids_compatbility(name):
res = slack.conversations.list(types='mpim').body
res = slack.conversations.list(types='mpim', limit=1000).body
if not res['ok'] or not res['channels']:
return []
mpims = res['channels']
Expand Down Expand Up @@ -478,28 +478,28 @@ def print_dict(name, d):
users = {}
print_dict('users', users)

res = slack.conversations.list(types='public_channel').body
res = slack.conversations.list(types='public_channel', limit=1000).body
if res['ok'] and res.get('channels'):
channels = {c['id']: c['name'] for c in res['channels']}
else:
channels = {}
print_dict('public channels', channels)

res = slack.conversations.list(types='private_channel').body
res = slack.conversations.list(types='private_channel', limit=1000).body
if res['ok'] and res.get('channels'):
groups = {c['id']: c['name'] for c in res['channels']}
else:
groups = {}
print_dict('private channels', groups)

res = slack.conversations.list(types='im').body
res = slack.conversations.list(types='im', limit=1000).body
if res['ok'] and res.get('channels'):
ims = { c['id']: get_user(c['user']) for c in res['channels']}
else:
ims = {}
print_dict('instant messages', ims)

res = slack.conversations.list(types='mpim').body
res = slack.conversations.list(types='mpim', limit=1000).body
if res['ok'] and res['channels']:
mpin = { c['id']: c['name'] for c in res['channels']}
else:
Expand Down

0 comments on commit 35ea052

Please sign in to comment.