Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
2,820
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. class StartStandupCommand(Command):
  2.     validator = '^Standup for:'
  3.  
  4.     def do(self):
  5.         groups = re.findall(re.compile('(?P<names>[a-z0-9\.]*@[a-z\.]*)'), self.input)
  6.         members = slack_client.api_call("users.list")['members']
  7.         members = [(m['id'], m['profile'].get('email')) for m in members if m['profile'].get('email') in groups]
  8.  
  9.         for id, email in members:
  10.             channel_id = slack_client.api_call(
  11.                 "conversations.open",
  12.                 users=[id]
  13.             )['channel']['id']
  14.  
  15.             slack_client.api_call(
  16.                 "chat.postMessage",
  17.                 channel=channel_id,
  18.                 text="""
  19.                Hey! It's standup time! Please answer:
  20.                1. What are you workinng on?
  21.                2. Do you encounter any problems?
  22.                3. What are your plans for later?
  23.                """
  24.             )
  25.             STANDUP_CHANNELS[channel_id] = {'origin': self.channel,  'author': email, 'response': []}
  26.  
  27.         slack_client.api_call(
  28.             "chat.postMessage",
  29.             channel=self.channel,
  30.             text=f"Be right back! Gathering feedback from {', '.join([m[1] for m in members])}"
  31.         )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement