Beispiel #1
0
def execute_bot(slack_client, agilebot, all_users):
    # Always stay active
    while True:
        channel, user, message, ts = get_messages(slack_client.rtm_read(),
                                                  agilebot.address)
        if channel and user and message:
            command, request = validate_message(message)
            if command:
                # Response to the user
                action = ActionBuilder.build(command)
                response, state = action.get_response(user, all_users, request)
                user_name = "<@" + user + "> "
                # response = user_name + response

                # TODO - Use interactive Slack message buttons
                # TODO - Use ephemeral messages depending on the command
                confirm(slack_client, user, channel, response, command, ts,
                        state)
            else:
                response = get_usage()
                slack_client.api_call("chat.postMessage",
                                      channel=channel,
                                      text=response,
                                      as_user=True)
        time.sleep(READ_WEBSOCKET_DELAY)
Beispiel #2
0
 def test_01_backlog(self):
     date = get_odd_date()
     action = ActionBuilder.build(GROOMBACKLOG)
     action_test(
         action, date,
         "Story #1: First Story (Points: 1)\nStory #2: Second Story (Points: 2)\nStory #3: Third Story (Points: 3)"
     )
Beispiel #3
0
 def test_03_sprint(self):
     date = get_odd_date()
     action = ActionBuilder.build(PLANSPRINT)
     action_test(
         action, date,
         "\nStory #1: First Story (Owner: @jsingh8 Points = 10)\nStory #2: Second Story (Owner: @yvlele Points = 20)\nStory #3: Third Story (Owner: @oachary Points = 15)"
     )
Beispiel #4
0
 def test_05_commits(self):
     date = get_odd_date()
     action = ActionBuilder.build(GIVEMYSTATUS)
     action_test(
         action, date,
         "02/21/2017 04:50:06 Added New File\n02/21/2017 04:59:34 Updated Data\n02/21/2017 03:46:19 Initial commit"
     )
Beispiel #5
0
def post_slack():
    payload = parse_request(request)
    print(payload)
    slack_client = get_slackclient()
    channel = payload['channel']['id']
    if payload['actions'][0]['name'] == 'yes':
        info = payload['actions'][0]['value']
        info = info.split(';')
        command = info[0]
        state = int(info[1])
        action = ActionBuilder.build(command)
        response = action.execute(state)
        print(
            slack_client.api_call("chat.postMessage",
                                  channel=channel,
                                  text=response,
                                  as_user=True))
        return "Done!"
    else:
        print((SlackClient(get_env("SLACK_TOKEN")).api_call(
            "chat.delete",
            channel=channel,
            ts=payload['actions'][0]['value'],
        )))
        return "No problem, let me know if you need anything else."
Beispiel #6
0
 def test_04_no_sprint(self):
     date = get_even_date()
     action = ActionBuilder.build(PLANSPRINT)
     action_test(action, date, action.INVALID_RESPONSE)
Beispiel #7
0
 def test_02_no_backlog(self):
     date = get_even_date()
     action = ActionBuilder.build(GROOMBACKLOG)
     action_test(action, date, action.INVALID_RESPONSE)
Beispiel #8
0
 def test_06_no_commits(self):
     date = get_even_date()
     action = ActionBuilder.build(GIVEMYSTATUS)
     action_test(action, date, action.INVALID_RESPONSE)
     time.sleep(10)