def is_user_in_group(user_id, group_name):
try:
# Get list of channels
user_groups = slack.channels.list().body.get('channels', [])
except slacker.Error as e:
print(e)
return True
user_list = []
for group in user_groups:
if group['name'] == group_name:
user_list = group['members']
# This returns true if the user_id is in user_list, otherwise false
return user_id in user_list
# Get all the channel names from Slack
评论列表
文章目录