def handler(user_id: str, project: str) -> Response:
    """ Handler of TEAM_06_ADD_PROJECT intent,
        TEAM_06_ADD_PROJECT intent is activated when user says '[Aa]m (?P<project>.*)'
        returns question for task

    :return:        Response
    """

    # Check project_id
    clockify_api_key = get_clockify_api_key(user_id)
    clockify = get_clockify(clockify_api_key)
    clockify_id = clockify['user_id']
    workspace_id = clockify['active_workspace_id']
    projects = get_projects(clockify_api_key, workspace_id)

    # Help the ASR
    if project == 'Hecker Tom' or project == 'hekatron' or project == 'Hecker Ton' or project == 'Hecker':
        project = 'Hackathon'

    # Create new Project
    try:
        project_id = projects[project]
    except KeyError:
        add_project(clockify_api_key, workspace_id, project_name=project)

    if set_project(user_id, project):
        msg = _('ASK_TASK')
    else:
        msg = _('ASK_PORJECT')
    response = ask(msg)
    return response
def team_24_project_status_handler() -> Response:
    overdue_q = 'project = {project} AND assignee = "{user}" AND duedate < Now() and status in ("In Progress", "To Do")'
    jira_account = get_jira_account()
    users = get_project_users()
    overdue_msg = ""
    for user in users:
        overdue_q_user = overdue_q.format(project=config.get(
            'jira', 'project'),
                                          user=user)
        overdue_tasks = get_jira_tasks_with_due_dates(overdue_q_user,
                                                      jira_account)
        overdue_tasks_count = len(overdue_tasks)
        if overdue_tasks_count > 0:
            overdue_msg += user + _("ASSIGNED") + " "
            for idx, tpl in enumerate(overdue_tasks):
                overdue_msg += _("OVERDUE_TASK",
                                 task=tpl[0],
                                 days=(datetime.now() - parse(tpl[1])).days)
                overdue_msg += ", " if idx != overdue_tasks_count - 1 else "."

    if overdue_msg == "":
        overdue_msg = _("NO_OVERDUE_TASKS")

    response = Response(overdue_msg)
    return response
def team_24_assign_task_handler(username: str, taskname: str) -> Response:
    """ TEAM_24_ASSIGN_TASK handler

    :param username: str
    :param taskname: str
    :return:
    """

    chosen_user = clarify_user(username)

    jira_account = get_jira_account()
    tasks, tasks_count_msg = get_all_jira_tasks_with_keys(jira_account)
    if tasks_count_msg == _("NONE"):
        return Response(_("EMPTY_PROJECT", intent="TEAM_24_NEW_TASK"))

    chosen_task = choose_entity_from_tuples(tasks, taskname)

    if chosen_task is None or chosen_user is None:
        return Response(_("CANNOT_UNDERSTAND", intent="TEAM_24_NEW_TASK"))

    assignable_users = jira_account.get_assignable_users_for_issue(chosen_task[0])
    user_with_account_id = next(filter(lambda user: user['displayName'] == chosen_user, assignable_users), None)

    if user_with_account_id is None:
        return Response(_("CANNOT_UNDERSTAND", intent="TEAM_24_NEW_TASK"))

    account_id_user = user_with_account_id['accountId']
    jira_account.issue_update(chosen_task[0], fields={"assignee": {"accountId": account_id_user}})

    response = Response(_("ASSIGN_TASK", intent="TEAM_24_NEW_TASK", username=chosen_user))
    return response
Exemple #4
0
def handler() -> Response:
    """ A sample handler of AMUSEMENT__JOKE intent,
        AMUSEMENT__JOKE intent is activated when user asks to tell him a joke
        returns a random joke from Chuck Norris jokes database: http://api.icndb.com/jokes/random

    :return:        Response
    """
    try:
        # We request a random joke from icndb with time-out set to 10 seconds
        response = requests.get('http://api.icndb.com/jokes/random',
                                timeout=10)
        # We parse the response json or raise exception if unsuccessful
        response.raise_for_status()
        data = response.json()
        # We get the joke from the response data
        joke = data['value']['joke'] if data.get('type') == 'success' else None
        # We format our response to user or ask for an excuse
        if joke:
            msg = _('HELLOAPP_JOKE', joke=joke)
        else:
            msg = _('HELLOAPP_RESPONSE_ERROR')
    except requests.exceptions.RequestException as err:
        msg = _('HELLOAPP_REQUEST_ERROR', err=err)

    # We create a response with either joke or error message
    return tell(msg)
def team_24_project_status_handler() -> Response:
    urgent_msg = _("NO_URGENT_TASKS")
    tasks = get_urgent_tasks()
    if len(tasks) > 0:
        urgent_msg = _("URGENT_TASKS_INTRO") + format_enumeration(
            [_("URGENT_TASK", task=t[0], user=t[1]) for t in tasks]) + "."
    response = Response(urgent_msg)
    return response
Exemple #6
0
def format_content(content, h, imp, model):
    content += _("FROM") + " " + imp.sender.name + " " + _(
        "WITH_SUBJECT") + " " + imp.subject + ": "
    body = h.handle(imp.body).replace('*', ''). \
        replace('|', '').replace('---', '').replace('[', ''). \
        replace(']', '').replace('#', '')
    body = re.sub(r'\n\s*\n', '\n\n', body)
    body = body.replace("\n", " ")
    summary = model(body)
    content += summary
    return content
def handler(user_id: str) -> Response:
    """ Handler of TEAM_06_OPEN_TIME_TRACKING intent,
        TEAM_06_OPEN_TIME_TRACKING intent is activated when user says 'zeiterfassung stoppen'
        welcomes user

    :return:        Response
    """

    user_info = get_user(user_id)

    if user_info:
        update_user(user_info)
    else:
        create_user(user_id)

    clockify_api_key = get_clockify_api_key(user_id)

    if clockify_api_key is None or clockify_api_key == '':
        user_token = get_user_token(user_id)

        if user_token is None or user_token == '':
            user_token = get_random_string(4)
            set_user_token(user_id, user_token)

        msg = _('WELCOME_NEW_USER')

        response = tell(msg)

        response.card = Card(
            type_="GENERIC_DEFAULT",
            title="Time Tracker: Hinterlege deinen Clockify Account",
            text="User Token: {token}".format(token=user_token),
            action=get_auth_url(token=user_token),
            action_text="Klick hier, um einen Account zu hinterlegen.")
    else:
        clockify = get_clockify(clockify_api_key)
        clockify_id = clockify['user_id']
        workspace_id = clockify['active_workspace_id']
        time_entries = get_time_entries(clockify_api_key=clockify_api_key,
                                        workspace_id=workspace_id,
                                        user_id=clockify_id)
        running_timer = check_running_timer(time_entries)
        # Get time tracking status
        if running_timer:
            msg = _('WELCOME_RETURNING_USER')
            msg = msg + " " + _('WELCOME_STOP_SELECTION')
        else:
            msg = _('WELCOME_SELECTION')

        response = ask(msg)

    return response
Exemple #8
0
def team_24_call_handler() -> Response:
    """ TEAM_24_CALL handler
    :return:
    """

    jira_account = get_jira_account()
    tasks, tasks_count_msg = get_backlog(jira_account)
    if tasks_count_msg == _("NONE"):
        return _("NO_BACKLOG")

    msg = _("BACKLOG_INTRO")
    msg += format_enumeration(tasks) + "."

    response = Response(msg)
    return response
 def test_make_lazy_translation(self):
     from skill_sdk.l10n import _, _n, _a
     with open('de.mo') as f:
         tr = Translations(f)
         tr._catalog['KEY'] = 'VALUE'
         tr._catalog[('KEY', 1)] = 'VALUES'
         tr._catalog['KEY_PLURAL'] = 'VALUES'
         l10n.set_current_locale(None)
         self.assertEqual(_('KEY'), 'KEY')
         self.assertEqual(_n('KEY', 'KEY_PLURAL', 1), 'KEY')
         self.assertEqual(_n('KEY', 'KEY_PLURAL', 2), 'KEY_PLURAL')
         self.assertEqual(_a('KEY'), ['KEY'])
         l10n.set_current_locale(tr)
         self.assertEqual(_('KEY'), 'VALUE')
         self.assertEqual(_n('KEY', 'KEY_PLURAL', 2), 'VALUES')
         self.assertEqual(_a('KEY'), ['KEY'])
Exemple #10
0
def get_done_tasks():
    msg_done_tasks = _("NO_DONE_TASKS")
    today = date.today().strftime("%Y-%m-%d")
    tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d")
    done_q = 'project = {project} AND status changed during ({today}, {tomorrow}) to Done'. \
        format(project=config.get('jira', 'project'), today=today, tomorrow=tomorrow)
    done_tasks, done_tasks_count_msg = get_jira_tasks(done_q)
    return done_tasks, done_tasks_count_msg, msg_done_tasks
Exemple #11
0
def team_24_project_status_handler() -> Response:
    """ TEAM_24_PROJECT_STATUS handler

    :return:
    """

    urgent_q = 'project = {project} AND status IN ("To Do") and priority in (Highest)'.\
        format(project=config.get('jira', 'project'))

    overdue_q = 'project = {project} AND duedate < Now() and status in ("In Progress", "To Do")'.\
        format(project=config.get('jira', 'project'))

    jira_account = get_jira_account()
    todo_tasks, todo_tasks_count_msg = get_jira_tasks(get_board_query("To Do"),
                                                      jira_account)
    inprogress_tasks, inprogress_tasks_count_msg = get_jira_tasks(
        get_board_query("In Progress"), jira_account)
    done_tasks, done_tasks_count_msg = get_jira_tasks(get_board_query("Done"),
                                                      jira_account)
    urgent_tasks, urgent_tasks_count_msg = get_jira_tasks(
        urgent_q, jira_account)
    overdue_tasks, overdue_tasks_count_msg = get_jira_tasks(
        overdue_q, jira_account)
    idle_users = get_idle_users(jira_account)

    msg = _("SPRINT_STATUS",
            project=config.get('jira', 'project'),
            todos=todo_tasks_count_msg,
            inprogress=inprogress_tasks_count_msg,
            done=done_tasks_count_msg)

    msg += " " + _("PROJECT_STATUS_INTRO",
                   project=config.get('jira', 'project'),
                   urgent_tasks=urgent_tasks_count_msg,
                   overdue_tasks=overdue_tasks_count_msg)

    if len(idle_users) > 0:
        verb = _("ARE")
        if len(idle_users) == 1:
            verb = _("IS")
        user_str = format_enumeration(idle_users)
        msg_idle = " " + _("IDLE_USERS", users=user_str, verb=verb)
        msg += msg_idle

    response = Response(msg)
    return response
Exemple #12
0
def handler() -> Response:
    """
    This handler is the first point of contact when your utterance is actually resolved!
    It will make sure to send you funny memes to your phone.

    :return:        Response
    """
    # We get a translated message
    msg = _('RANDOM_MEME_AFFIRMATION')
    # We create a simple response
    response = tell(msg)
    response.card = Card(type_="GENERIC_DEFAULT",
                         title=_("RANDOM_MEME_TITLE"),
                         sub_title=_("RANDOM_MEME_SUB_TITLE"),
                         action=get_random_meme_url(),
                         action_text=_("RANDOM_MEME_ACTION_TEXT"))

    return response
def handler(user_id: str) -> Response:
    """ Handler of TEAM_06_STOP_TIME_TRACKING intent,
        TEAM_06_STOP_TIME_TRACKING intent is activated when user says 'zeiterfassung stoppen'
        stops running timer 

    :return:        Response
    """
    clockify_api_key = get_clockify_api_key(user_id)
    clockify = get_clockify(clockify_api_key)
    clockify_id = clockify['user_id']
    workspace_id = clockify['active_workspace_id']
    time_entries = get_time_entries(clockify_api_key, workspace_id,
                                    clockify_id)
    project_ids = get_project_ids(clockify_api_key, workspace_id)

    # Get time tracking status
    running_timer = check_running_timer(time_entries)

    if running_timer:
        # Stop time tracking
        now = datetime.utcnow()
        now_str = now.isoformat()
        now_str = now_str.split('.')[0] + ".000Z"
        time_entrie = stop_time_entrie(clockify_api_key,
                                       workspace_id,
                                       user_id=clockify_id,
                                       end_datetime=now_str)

        project = project_ids[time_entrie['projectId']]
        duration = parse_duration(time_entrie['timeInterval']['duration'])
        task = time_entrie['description']

        set_project(user_id, '')
        set_task(user_id, '')

        msg = _('STOP_COMFIRMATION',
                project=project,
                task=task,
                duration=duration)
    else:
        msg = _('STOP_ERROR')

    response = tell(msg)
    return response
Exemple #14
0
def team_24_schedule_meeting_handler(usernames: str, time: str) -> Response:
    """ TEAM_24_SCHEDULE_MEETING handler
        
    :param usernames: str
    :param time: str
    :return:
    """
    response = Response(_("NOT_IMPLEMENTED",
                          intent="TEAM_24_SCHEDULE_MEETING"))
    return response
def handler(user_id: str, task: str) -> Response:
    """ Handler of TEAM_06_ADD_TASK intent,
        TEAM_06_ADD_TASK intent is activated when user says '(ich möchte|ich werde) (die|den|das)(?P<task>.*)'
        returns confirmation start timer

    :return:        Response
    """

    set_task(user_id, task)

    # Get project from db
    project = get_project(user_id)
    clockify_api_key = get_clockify_api_key(user_id)
    clockify = get_clockify(clockify_api_key)
    clockify_id = clockify['user_id']
    workspace_id = clockify['active_workspace_id']
    projects = get_projects(clockify_api_key, workspace_id)
    project_id = projects[project]

    if project is None:
        msg = _('ASK_PROJECT')
        response = ask(msg)
    elif task is None:
        msg = _('ASK_TASK')
        response = ask(msg)
    else:
        # Start time tracking
        now = datetime.utcnow()
        now_str = now.isoformat()
        now_str = now_str.split('.')[0] + ".000Z"

        add_time_entrie(clockify_api_key,
                        workspace_id,
                        project_id,
                        task,
                        now_str,
                        end_datetime=None)

        msg = _('START_COMFIRMATION')
        response = tell(msg)

    return response
def mood_handler():
    try:
        number = randrange(10)
        # TODO: add functionality to create personalized preferences, social/close friends group, to trigger a call.
        if number < 3:
            # TODO: Maybe add jokes in a database and source from there
            # Jokes sourced from "https://github.com/derphilipp/Flachwitze"
            response = requests.get(
                'https://raw.githubusercontent.com/derphilipp/Flachwitze/master/README.md',
                timeout=10)
            raw_jokes = response.text.split("##")[1].split("\n")[2:]
            jokes = [j[2:] for j in raw_jokes]

            msg = _('HAPPINESS_JOKE', joke=jokes[randrange(len(jokes))])
            response = tell(msg)
        elif number < 6:
            # TODO: Add more URL's and if possible learn from user history
            video_ids = ["DODLEX4zzLQ", "dQw4w9WgXcQ", "tvMO9TNfdHs"]
            msg = _("HAPPINESS_CHECK_PHONE")
            response = tell(msg)
            response.card = Card(
                title=_("HAPPINESS_TITLE"),
                subtitle=_("HAPPINESS_SUB_TITLE"),
                action=
                f"https://www.youtube.com/watch?v={video_ids[randrange(len(video_ids))]}",
                actiontext=_("HAPPINESS_ACTION_TEXT"))
        else:
            msg = _("HAPPINESS_CHECK_PHONE")
            response = tell(msg)
            response.card = Card(
                title=_("HAPPINESS_TITLE"),
                subtitle=_("HAPPINESS_SUB_TITLE"),
                action=
                f"https://soundcloud.com/mariagrazia84/pharrell-williams-happy",
                actiontext=_("HAPPINESS_ACTION_TEXT"))
    except requests.exceptions.RequestException as err:
        msg = _('HAPPINESS_REQUEST_ERROR', err=err)
        response = tell(msg)

    # We create a response with either joke or error message
    return response
Exemple #17
0
def get_idle_users(jira_account):
    users = get_project_users()
    idle_q = "project = {project} AND assignee = '{user}' AND status IN ('In Progress') ORDER BY issuekey"
    idle_users = []
    for user in users:
        idle_q_user = idle_q.format(project=config.get('jira', 'project'),
                                    user=user)
        in_progress_tasks, in_progress_tasks_count_msg = get_jira_tasks(
            idle_q_user, jira_account)
        if in_progress_tasks_count_msg == _("NONE"):
            idle_users.append(user)
    return idle_users
Exemple #18
0
def get_jira_tasks(q, account=None):
    jira_account = account
    if jira_account is None:
        jira_account = get_jira_account()

    if jira_account is None:
        return [], _("NONE")

    q_res = jira_account.jql(q)
    tasks = [t['fields']['summary'] for t in q_res['issues']]
    tasks_count_msg = many_or_none_message(tasks)
    return tasks, tasks_count_msg
Exemple #19
0
def team_24_my_day_handler() -> Response:
    """ TEAM_24_MY_DAY handler

    :return:
    """
    meetings, meetings_count_msg = get_meetings()

    tasks, tasks_count_msg = get_in_progress_tasks()

    msg = _("MY_DAY",
            nickname=config.get('jira', 'nickname'),
            meetings_count=meetings_count_msg,
            tasks_count=tasks_count_msg)

    if meetings_count_msg != _("NONE"):
        msg += " " + _("MY_MEETINGS_INTRO")
        msg += " ".join(
            [m[1] + " " + _("AT") + " " + m[0] + "." for m in meetings])

    if tasks_count_msg != _("NONE"):
        msg += " " + _("MY_TASKS_INTRO")
        msg += format_enumeration(tasks)
        msg += "."

    response = Response(msg)
    return response
Exemple #20
0
def team_24_recommend_allocation_handler() -> Response:
    """ TEAM_24_RECOMMEND_ALLOCATION handler

    :return:
    """
    allocation_table = list()
    jira_account = get_jira_account()
    users = get_project_users_without_pm()

    q = "project = {project} AND assignee = '{user}' AND status IN ('To Do', 'In Progress') ORDER BY issuekey"
    total = 0
    for user in users:
        q_user = q.format(project=config.get('jira', 'project'), user=user)
        tasks, tasks_count_msg = get_jira_tasks(q_user, jira_account)
        allocation_table.append((user, len(tasks)))
        total += len(tasks)

    tasks, tasks_count_msg = get_backlog(jira_account)
    if tasks_count_msg == _("NONE"):
        return _("NO_BACKLOG")

    summary = allocate_backlog(tasks, allocation_table, total, users)
    msg = _("RECOMMENDER_INTRO")
    for usr, ts in summary.items():
        msg += _("RECOMMENDER_SG",
                 tasks=format_enumeration(ts)) if len(ts) == 1 else _(
                     "RECOMMENDER_PL",
                     tasks=format_enumeration(ts)) + _("TO") + " " + usr + ". "

    response = Response(msg)
    return response
def handler(user_id: str) -> Response:
    """ Handler of TEAM_06_START_TIME_TRACKING intent,
        TEAM_06_START_TIME_TRACKING intent is activated when user says 'zeiterfassung starten'
        returns question for project

    :return:        Response
    """

    user_info = get_user(user_id)

    if user_info:
        update_user(user_info)
    else:
        create_user(user_id)

    clockify_api_key = get_clockify_api_key(user_id)

    if clockify_api_key is None or clockify_api_key == '':
        user_token = get_user_token(user_id)

        if user_token is None or user_token == '':
            user_token = get_random_string(4)
            set_user_token(user_id, user_token)

        msg = _('WELCOME_NEW_USER')

        response = tell(msg)

        response.card = Card(
            type_="GENERIC_DEFAULT",
            title="Time Tracker: Hinterlege deinen Clockify Account",
            text="User Token: {token}".format(token=user_token),
            action=get_auth_url(token=user_token),
            action_text="Klick hier, um einen Account zu hinterlegen.")
    else:
        msg = _('ASK_PROJECT')
        response = ask(msg)

    return response
Exemple #22
0
def handler_memo(text: str):
    print(context)
    user_id = '2'
    if start_round(text):
        topic = text.split("thema ")[-1]
        cursor = connection.cursor()
        if topic == text:
            question_id, quiz, answer, _ = cursor.execute(
                "select questions.id, quiz, answer, max(user_questions.id) as max_id from questions left join user_questions on questions.id = user_questions.questions_id\
                where user_id = ? and step<6 group by questions.id order by max_id limit 1",
                [user_id]).fetchone()
        else:
            question_id, quiz, answer, _ = cursor.execute(
                "select questions.id, quiz, answer, max(user_questions.id) as max_id from questions left join user_questions on questions.id = user_questions.questions_id\
                where user_id = ? and step<6 and topic = ? group by questions.id order by max_id limit 1",
                [user_id, topic]).fetchone()
        if quiz is None:
            msg = _("NO_MORE_QUIESTION")
            return tell(msg)
        cursor.execute("insert into user_questions (questions_id) values (?)",
                       [question_id])
        connection.commit()
        return ask(quiz)

    else:
        cursor = connection.cursor()
        last_question_id, answer, step = cursor.execute(
            "select questions_id, answer, step from user_questions uq\
        JOIN questions q on q.id = uq.questions_id where q.user_id = ? order by uq.id desc limit 1",
            [user_id]).fetchone()
        if similar_answer(answer, text):
            step += 1
        else:
            step = max(1, step - 1)
        cursor.execute("update questions set step = ? where id = ?",
                       [step, last_question_id])
        connection.commit()

        return tell(_('END_QUESTION_REVIEW'))
Exemple #23
0
def handler(number: int) -> Response:
    """ The implementation

    :param number:
    :return:            Response
    """
    try:
        # We check if value is in range of 1 to 10
        assert 1 <= number <= 10
        # We get a random number
        if number == randint(1, 10):
            # ... and congratulate the winner!
            msg = _('HELLOAPP_NUMBER_SUCCESS_MESSAGE')
        else:
            # ... or encourage them to keep trying
            msg = _('HELLOAPP_NUMBER_WRONG_MESSAGE')
        response = tell(msg)
    except (AssertionError, TypeError, ValueError):
        msg = _('HELLOAPP_NO_NUMBER_MESSAGE')
        # We create a response with NO_NUMBER_MESSAGE and ask to repeat the number
        response = ask(msg)
    return response
Exemple #24
0
def handler() -> Response:
    """ A very basic handler of SMALLTALK__GREETINGS intent,
        SMALLTALK__GREETINGS intent is activated when user says 'Hello'
        returns translated 'Hello' greeting

    :return:        Response
    """
    # We get a translated message
    msg = _('HELLOAPP_HELLO')
    # We create a simple response
    response = tell(msg)
    # We return the response
    return response
Exemple #25
0
def handler_card(text: str) -> Response:
    print('*******')
    print(context)
    user_id = '2'
    if not has_open_question(user_id):
        cursor = connection.cursor()
        cursor.execute("insert into questions (user_id) values (?) ",
                       [user_id])
        connection.commit()
        msg = _('ASK_YOUR_QUESTION')
        return ask(msg)
    elif has_open_question_no_quiz(user_id):
        cursor = connection.cursor()
        question = get_last_quiz(user_id)
        cursor.execute("update questions set quiz = ? where id = ?",
                       [text, question[0]])
        connection.commit()
        msg = _('INSERT_YOUR_ANSWER')
        return ask(msg)
    elif has_open_question_no_answer(user_id):
        cursor = connection.cursor()
        question = get_last_quiz(user_id)
        cursor.execute("update questions set answer = ? where id = ?",
                       [text, question[0]])
        connection.commit()
        msg = _('WHAT_IS_THE_TOPIC')
        return ask(msg)
    else:
        cursor = connection.cursor()
        question = get_last_quiz(user_id)
        cursor.execute("update questions set topic = ? where id = ?",
                       [text, question[0]])
        connection.commit()
        msg = _('DONE')
        return tell(msg)

    print("AFTER ALL IFS")
Exemple #26
0
def team_24_new_task_handler(taskname: str) -> Response:
    """ TEAM_24_NEW_TASK handler

    :param taskname: str
    :return:
    """

    jira_account = get_jira_account()
    my_project = get_current_project(jira_account)

    issue_dict = {
        'project': {'key': '{project}'.format(project=my_project['key'])},
        'issuetype': {'name': 'Story'},
        'summary': '{taskname}'.format(taskname=taskname)
    }
    jira_account.issue_create_or_update(fields=issue_dict)

    response = Response(_("NEW_TASK", taskname=taskname))
    return response
Exemple #27
0
def team_24_project_status_handler() -> Response:
    msg_emails = _("NO_EMAILS")
    mailbox = get_mailbox()
    query = mailbox.new_query().on_attribute('ReceivedDateTime').greater_equal(
        datetime(2020, 12, 5, 0, 0))
    titles = format_enumeration([
        message.subject + " " + _("FROM") + " " + message.sender.name
        for message in mailbox.get_messages(query=query)
    ])
    if titles != "":
        msg_emails = _("EMAILS", titles=titles)

    msg_important_emails = ""
    important_messages = list(
        filter(lambda msg: msg.importance.name == 'High',
               mailbox.get_messages(query=query)))
    if len(important_messages) > 0:
        h = HTML2Text()
        h.ignore_links = True

        model = get_summarizer_model()
        content = ""
        for imp in important_messages:
            content = format_content(content, h, imp, model)

        msg_important_emails += _("IMPORTANT_EMAILS", content=content)

    done_tasks, done_tasks_count_msg, msg_done_tasks = get_done_tasks()
    if done_tasks_count_msg != _("NONE"):
        msg_done_tasks = _("DONE_TASKS_INTRO")
        msg_done_tasks += format_enumeration(done_tasks)
        msg_done_tasks += "."

    response = Response(msg_emails + " " + msg_important_emails + " " +
                        msg_done_tasks)
    return response
def dragons(dragon_list: List[str]):
    return _('DRAGONS')
def hello():
    return _('HELLO')
def team_24_call_handler(username: str) -> Response:
    """ TEAM_24_COWORKER_STATUS handler

    :param username: str
    :return:
    """

    user = clarify_user(username)

    jira_account = get_jira_account()
    todo_tasks, todo_tasks_count_msg = get_jira_tasks(
        get_user_board_query("To Do", user), jira_account)
    inprogress_tasks, inprogress_tasks_count_msg = get_jira_tasks(
        get_user_board_query("In Progress", user), jira_account)
    done_tasks, done_tasks_count_msg = get_jira_tasks(
        get_user_board_query("Done", user), jira_account)

    msg = _("COWORKER_STATUS",
            username=username,
            todos=todo_tasks_count_msg,
            inprogress=inprogress_tasks_count_msg,
            done=done_tasks_count_msg)

    if inprogress_tasks_count_msg != _("NONE"):
        msg += " " + _("COWORKER_INPROGRESS",
                       username=user,
                       tasks=format_enumeration(inprogress_tasks))

    urgent_q = 'project = {project} AND assignee = "{username}" AND status IN ("To Do") and priority in (Highest)'. \
        format(project=config.get('jira', 'project'), username=user)

    overdue_q = 'project = {project} AND assignee = "{username}" AND duedate < Now() and status in ("In Progress", ' \
                '"To Do")'. \
        format(project=config.get('jira', 'project'), username=user)

    urgent_tasks, urgent_tasks_count_msg = get_jira_tasks(
        urgent_q, jira_account)
    if urgent_tasks_count_msg != _("NONE"):
        msg += _("COWORKER_URGENT",
                 username=user,
                 tasks=format_enumeration(urgent_tasks)) + "."

    overdue_tasks = get_jira_tasks_with_due_dates(overdue_q, jira_account)
    overdue_tasks_count = len(overdue_tasks)
    if overdue_tasks_count > 0:
        msg += _("COWORKER_OVERDUE", username=user)
        for idx, tpl in enumerate(overdue_tasks):
            msg += _("OVERDUE_TASK",
                     task=tpl[0],
                     days=(datetime.now() - parse(tpl[1])).days)
            msg += ", " if idx != overdue_tasks_count - 1 else "."

    no_tasks_q = "project = {project} AND assignee = '{user}' AND status IN ('In Progress', 'To Do') ORDER BY issuekey".format(
        project=config.get('jira', 'project'), user=user)
    tasks, tasks_count_msg = get_jira_tasks(no_tasks_q, jira_account)
    if len(tasks) == 0:
        msg += " " + _("COWORKER_EMPTY")
    else:
        idle_tasks_q = "project = {project} AND assignee = '{user}' AND status IN ('In Progress') ORDER BY " \
                       "issuekey".format(project=config.get('jira', 'project'), user=user)
        idle_tasks, idle_tasks_count_msg = get_jira_tasks(
            idle_tasks_q, jira_account)
        if len(idle_tasks) == 0:
            msg += " " + _("COWORKER_IDLE")

    response = Response(msg)
    return response