+
+def slack_channel_members(slack_client, channel_id):
+ members = []
+
+ cursor = None
+ while True:
+ if cursor:
+ response = slack_client.conversations_members(channel=channel_id,
+ cursor=cursor)
+ else:
+ response = slack_client.conversations_members(channel=channel_id)
+
+ if response['ok']:
+ members += response['members']
+ else:
+ print("Error querying members of channel {}: {}"
+ .format(channel_id, response['error']))
+ return members
+
+ cursor = None
+ if 'next_cursor' in response['response_metadata']:
+ cursor = response['response_metadata']['next_cursor']
+
+ if not cursor or cursor == '':
+ break
+
+ return members
+
+def slack_send_message(slack_client, channel_id, text, blocks=None):
+ if blocks:
+ slack_client.chat_postMessage(channel=channel_id,
+ text=text, blocks=blocks)
+ else:
+ slack_client.chat_postMessage(channel=channel_id, text=text)