Skip to content
This repository was archived by the owner on Dec 29, 2017. It is now read-only.

Conversation

@nik849
Copy link
Contributor

@nik849 nik849 commented Jul 1, 2017

@ovv, I have been trying to test this with ngrok - I haven't got as far as I would like - hopefully you can see what I am trying to do here - put a listener for the event and a function to get the members in general and % 1000 etc ...

Copy link
Member

@ovv ovv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small changes but otherwise 👍


await slack.send(response)

async def members_joined(self, event, slack, _):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to await slack.channels multiple time. It returns a channel object.

The most efficient would be to request it one time to check if the event is for #general and then a second time with the update argument to be sure we update the total members count. You can then use the object for the to and counting the number of members

if (len(members) % 1000) == 0:
to = await slack.channels.get(name='general').members
message = SlackMessage(to=to)
message.text = 'We have just reached {} members!'.format()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you forgot to put something in the format. I guess it should be the len(members)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes... whoops! I was hoping I could print our what sort of thing the slack.channels.get returned, but I couldn't test it - I think .members returns a list of members. I didn't know I could just sent to the channel directly. Ok, thanks for this - I'll make a few changes and update it, thanks @ovv!

await slack.channels.get('general', update=True)
members = await slack.channels.get(name='general').members
if (len(members) % 1000) == 0:
to = await slack.channels.get(name='general').members
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to should be the channel not the members of the channel

@ovv ovv merged commit f47b966 into pyslackers:master Jul 1, 2017
@nik849 nik849 deleted the feature/1000_users_event branch July 1, 2017 21:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants