scrapinghub / slackbot

A chat bot for Slack (https://slack.com).
MIT License
1.26k stars 396 forks source link

Members of current channel #185

Open Johboh opened 5 years ago

Johboh commented 5 years ago

Hi! How can I get the members of the current channel that the bot is replying/reacting in?

message.channel._client.channels[message.body['channel']] have members field, but that one only contains one member and that is the bot itself, even when there are more users in the channel.

message.channel._client.users returns ALL users in the organization.

The use case is to do an eightball bot, like: @bot Should I go home or stay? I dunno, but maybe <usernname> knows!

But I only want to pick users that are in the channel where the question is asked.

//Johan

kiaka010 commented 5 years ago

Have you tried accessing message._client.webapi.groups.info(channel='GXXXXXXXX') for private channels and message._client.webapi.channels.info(channel='CXXXXXXXX') for public channels you know a channel is Private if it starts with G and public starts with C

Johboh commented 5 years ago

Thanks! I will give it a try.