-
Notifications
You must be signed in to change notification settings - Fork 4
1k user mesage for sirbot #36
Conversation
ovv
left a comment
There was a problem hiding this 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 👍
sirbot/pythondev/slack.py
Outdated
|
|
||
| await slack.send(response) | ||
|
|
||
| async def members_joined(self, event, slack, _): |
There was a problem hiding this comment.
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
sirbot/pythondev/slack.py
Outdated
| 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() |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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!
sirbot/pythondev/slack.py
Outdated
| 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 |
There was a problem hiding this comment.
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, 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 ...