Exemplo n.º 1
0
    def send(self):
        completed, current, blocker = self._get_tasks(self.user)

        individual_report = self._create_report(self.user, completed, current,
                                                blocker, self.channel)

        client.chat_postMessage(
            channel=individual_report['channel'],
            blocks=individual_report['blocks'],
            text=individual_report['blocks'][0]['text']['text'])
Exemplo n.º 2
0
    def send(self):
        responded, blocker, awaiting, result = self._get_tasks()

        individual_report = self._create_report(responded, blocker, awaiting,
                                                result)

        client.chat_postMessage(
            channel=individual_report['channel'],
            blocks=individual_report['blocks'],
            text=individual_report['blocks'][0]['text']['text'])
Exemplo n.º 3
0
    def send(self):
        from utils.time import date, calendar

        today_day = date.today()

        day = calendar.day_name[today_day.weekday()]

        if day == SATURDAY or day == SUNDAY:
            user_id = self.user['id']

            client.chat_postMessage(channel=f"@{user_id}", text=self.text)
Exemplo n.º 4
0
    def send_message(self):
        message = self._create_message(None, self.user)

        response = client.chat_postMessage(channel=message['channel'],
                                           blocks=message['blocks'],
                                           text=message['blocks'][0]['text'])

        return response
Exemplo n.º 5
0
    def send(self, response):
        text = ''
        user_id = self.user['id']
        username = self.user['username'].capitalize()

        if response.lower() == COMPLETED:
            text = f"Sure thing *{username}*, let's begin with the CT Daily Report. :sunglasses:\n\n" \
                   "What tasks did you complete yesterday?"

        elif response.lower() == SKIP:
            text = f"Ok *{username}* :sneezing_face:, " \
                   f"you can fill out the CT Daily report later by typing `daily`!"

        elif response.lower() == SNOOZE:
            text = f"Sure thing *{username}*, I will remind you in `15 minutes`! :wink:"

        client.chat_postMessage(channel=f'@{user_id}', text=text)
Exemplo n.º 6
0
    def send(self, response):
        """
        This method is responsible for the follow-up message, depending on the chosen option from the user

        :param response: the option which the user has chosen
        """
        text = ''
        user_id = self.user['id']
        username = self.user['username'].capitalize()

        if response.lower() == COMPLETED:
            text = f"Sure thing *{username}*, let's begin with the CT Daily Report. :sunglasses:\n\n" \
                   "What tasks did you complete yesterday?"

        elif response.lower() == SKIP:
            text = f"Ok *{username}* :sneezing_face:, " \
                   f"you can fill out the CT Daily report later by typing `daily`!"

        elif response.lower() == SNOOZE:
            text = f"Sure thing *{username}*, I will remind you in `15 minutes`! :wink:"

        elif response.lower() == RESPONDED_COMPLETED:
            text = 'What are you planning to work on today?'

        elif response.lower() == RESPONDED_CURRENT:
            text = 'Great. Do you have any blockers? If so, just tell me. Otherwise please say: no.'

        elif response.lower() == BLOCKERS:
            text = 'Well done! Your update for CT Daily Report was completed.'

        elif response.lower() == FOLLOW_UP:
            text = "There's no more pending follow-ups."

        elif response.lower() == NOT_UNDERSTOOD:
            text = "The command is not understood!"

        elif response.lower() == WEEKDAY:
            text = "You don't have any active check-ins to complete today!"

        client.chat_postMessage(channel=f'@{user_id}', text=text)
def event_message(payload):
    event = payload['event']

    user_id = event.get('user', None)

    user = users.get_user_by_id(user_id)

    if user is not None and user['id'] != BOT_ID:
        print(user)

        text = event['text']

        if text.lower() == DAILY and not user['replied']:
            default_message = DefaultMessage(user)
            default_message.send_message()

        if text.lower() != DAILY and not user['replied']:
            if user['completed_tasks'] and not user['current_tasks']:
                print("COMPLETED_TASKS")
                # printer.pprint(event)
                result = process_task.delay(user, event)

                # users.update_response(user_id, REPLIED)

                print(result)
                print(f'TASK_ID -> {result}')

                text = 'What are you planning to work on today?'

                client.chat_postMessage(channel=f'@{user_id}', text=text)

                users.update_response(user_id, CURRENT)

            elif user['completed_tasks'] and user['current_tasks']:
                print("CURRENTS_TASKS")
                # printer.pprint(event)

    return '', 200