예제 #1
0
def enquire_message(account_id, callback, __):
    """
    This function prompts the user for a message.

    :param account_id: user account id.
    :param callback: Callback corresponding to business type.
    """

    status, __, ___, ____ = get_user_status(account_id)
    if status == 'wait_in':
        set_user_status(account_id, status="none")

    fmt = _("You have selected {type}. Please tell me your question.")
    content1 = make_i18n_text(
        "You have selected {type}. "
        "Please tell me your question.".format(type=TYPES[callback]),
        "enquire_message",
        fmt,
        type=callback)

    fmt = _("Only one message can be delivered. "
            "Please write your question at one go.")
    content2 = make_i18n_text(
        "Only one message can be delivered. "
        "Please write your question at one go.", "enquire_message", fmt)

    yield asyncio.sleep(0.5)

    set_replace_user_info(account_id, 'wait_in', 'doing', callback)

    yield push_messages(account_id, [content1, content2])
예제 #2
0
def transfer_message(account_id, callback, __):
    """
    This function prompts the user to go to ask someone.

    :param account_id: user account id.
    :param callback: Business type.
    """
    status, __, ___, ____ = get_user_status(account_id)
    if status is not None:
        set_user_status(account_id, status="none")

    fmt = _("Your question will be directly delivered to the person "
            "in charge of {type} to answer your question directly.")
    content1 = make_i18n_text(
        "Your question will be directly delivered to "
        "the person in charge of {type} "
        "to answer your question directly.".format(type=TYPES[callback]),
        "transfer_message",
        fmt,
        type=callback)

    fmt1 = _(
        "Please tell me your question.\n\nOnly one message can be delivered. "
        "Please write your question at one go.")
    content2 = make_i18n_text(
        "Please tell me your question.\n\n"
        "Only one message can be delivered. "
        "Please write your question at one go.", "transfer_message", fmt1)

    yield asyncio.sleep(0.5)
    set_replace_user_info(account_id, 'wait_in', 'doing', callback)

    yield push_messages(account_id, [content1, content2])
def query_security(account_id, __, ___):
    """
    This function deals with user query security related problems.

    :param account_id: user account id.
    """
    status, __, type, message = get_user_status(account_id)
    if status == "wait_in":
        set_user_status(account_id, status="none")

    fmt = _("Here are FAQs about security.")
    text = make_i18n_text("Here are FAQs about security.", "query_security", fmt)

    fmt = _("Send a question")
    replay = create_quick_replay_item("transfer_security", "query_security",
                                      "Send a question", fmt)

    labels = ["See more", "See more", "See more", "See more"]

    fmt = _("See more")
    i18n_label_fmts = [fmt, fmt, fmt, fmt]

    titles = [
        "I lost my access card.",
        "My access card has been damaged.",
        "Can visitors enter the office?",
        "I can’t remember my computer password."
    ]
    
    i18n_title_fmts = [
        _("I lost my access card."),
        _("My access card has been damaged."),
        _("Can visitors enter the office?"),
        _("I con’t remember my computer password.")
    ]
    texts = [
        "Contact the Security Team to reissue your access card.",
        "Contact the Security Team to reissue your access card.",
        "Contact the Security Team in advance to gain access.",
        "Contact the Security Team to change your computer password."
    ]

    fmt = _("Contact the Security Team to reissue your access card.")
    i18n_text_fmts = [
        fmt,
        fmt,
        _("Contact the Security Team in advance to gain access."),
        _("Contact the Security Team to change your computer password.")
    ]

    carousel = create_carousel("query_security", labels,
                               POST_BACK_URLS["security"], texts, titles,
                               CAROUSEL["security"],
                               fmt_labels=i18n_label_fmts,
                               fmt_texts=i18n_text_fmts,
                               fmt_titles=i18n_title_fmts)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
예제 #4
0
def to_first(account_id, __, ___):
    process_flag = True
    status, __, type, message = get_user_status(account_id)
    if status is not None:
        clean_user_status(account_id)
        process_flag = False

    if process_flag:
        fmt = _(
            "Cannot be selected since you are currently in Initial Menu. \n\n"
            "Select it if you want to find FAQ or go back to Initial Menu "
            "while the person in charge is checking your question.")
        content = make_i18n_text(
            "Cannot be selected since you are currently "
            "in Initial Menu. \n\n"
            "Select it if you want to find FAQ or go back to "
            "Initial Menu while the person in charge is "
            "checking your question.", "to_first", fmt)
    else:
        fmt = _(
            "Moved to FAQ Initial Menu.\n\nPlease select an item from the menu below."
        )
        content = make_i18n_text(
            "Moved to FAQ Initial Menu.\n\nPlease select an item from the menu below.",
            "to_first", fmt)

    yield push_message(account_id, content)
예제 #5
0
def send(account_id, __, ___):
    """
    This function processes the content of the user confirmation message

    :param account_id: user account.
    """
    status, __, type, message = get_user_status(account_id)
    if status != "done" or message is None:
        # todo add error prompt
        raise HTTPError(500, "user status error. status error")

    content = make_text(
        "Your question has been sent to the person in charge. \n\n"
        "The staff will answer your question as soon as possible.")

    content1 = make_text("If you have any additional questions, "
                        "please select the task from below. "
                        "If you want to go back to the initial stage, "
                        "select [Go to Initial Menu] from the menu below.")

    content1["quickReply"] = create_quick_replay()

    title = "{type} inquiry details".format(type=type)
    prompt_message = yield create_articles(title, message, account_id)
    if prompt_message is not None:
        yield push_messages(account_id, [prompt_message])
        return

    clean_user_status(account_id)
    yield push_messages(account_id, [content, content1])
예제 #6
0
def deal_message(account_id, __, message):
    """
    Process messages manually entered by the user.

    :param account_id: user account id.
    :param message: user input message.
    """
    status, _, __, ___  = get_user_status(account_id)
    if status != "wait_in":
        raise HTTPError(403, "Messages not need to be processed")

    content = echo_display(message)
    set_user_status(account_id, status="done", message=message)

    yield push_message(account_id, content)
예제 #7
0
def cancel(account_id, __, ___):
    """
    This function handles user cancellation inquiry.

    :param account_id: user account id.
    """
    status, _, __, ___ = get_user_status(account_id)
    if status != "done":
        # todo add error prompt
        raise HTTPError(500, "user status error. status error")

    content = make_text("You have canceled your question. "
                        "Please re-select the task from the menu below.")
    clean_user_status(account_id)
    yield push_message(account_id, content)
예제 #8
0
def send(account_id, __, ___):
    """
    This function processes the content of the user confirmation message

    :param account_id: user account.
    """
    status, __, type, message = get_user_status(account_id)
    if status != "done" or message is None:
        # todo add error prompt
        raise HTTPError(500, "user status error. status error")

    fmt = _("Your question has been sent to the person in charge. \n\n"
            "The staff will answer your question as soon as possible.")
    content = make_i18n_text(
        "Your question has been sent to the person in charge. \n\n"
        "The staff will answer your question as soon as possible.", "send",
        fmt)

    fmt = _("If you have any additional questions, "
            "please select the task from below. "
            "If you want to go back to the initial stage, "
            "select [Go to Initial Menu] from the menu below.")
    content1 = make_i18n_text(
        "If you have any additional questions, "
        "please select the task from below. "
        "If you want to go back to the initial stage, "
        "select [Go to Initial Menu] from the menu below.", "send", fmt)

    content1["quickReply"] = create_quick_replay()
    name, department = yield get_account_info(account_id)
    fmt = _("{department} {name} made an inquiry.")
    title = get_i18n_content_by_lang(fmt,
                                     "send",
                                     DEFAULT_LANG,
                                     department=department,
                                     name=name)
    prompt_message = yield create_articles(title, type, message, account_id)
    if prompt_message is not None:
        yield push_messages(account_id, [prompt_message])
        return

    clean_user_status(account_id)
    yield push_messages(account_id, [content, content1])
예제 #9
0
def modify(account_id, __, ___):
    """
    This function handles the user's modification of the question

    :param account_id: user account id.
    """
    status, __, ___, ____ = get_user_status(account_id)
    if status != "done":
        raise HTTPError(500, "user status error. status error")

    fmt = _("I’ll help you modify your question. "
            "Please write your question again.")
    content = make_i18n_text(
        "I’ll help you modify your question. Please write"
        " your question again.", "modify", fmt)

    yield asyncio.sleep(0.5)

    set_user_status(account_id, status='wait_in')

    yield push_message(account_id, content)
예제 #10
0
def query_leave(account_id, __, ___):
    """
    This function deals with the problems related to leave query.

    :param account_id: user account id.
    """
    status, __, type, message = get_user_status(account_id)
    if status == "wait_in":
        set_user_status(account_id, status="none")

    fmt = _("Here are FAQs about HR and leave.")
    text = make_i18n_text("Here are FAQs about HR and leave.", "query_leave",
                          fmt)

    fmt = _("Send a question")
    replay = create_quick_replay_item("transfer_leave", "query_leave",
                                      "Send a question", fmt)

    labels = ["See more", "See more", "See more", "See more"]

    fmt = _("See more")
    i18n_label_fmts = [fmt, fmt, fmt, fmt]

    titles = [
        "The types of leave.", "How many days of leave I have?",
        "To request a leave.", "To cancel my leave."
    ]

    i18n_title_fmts = [
        _("The types of leave."),
        _("How many days of leave I have?"),
        _("To request a leave."),
        _("To cancel my leave.")
    ]

    texts = [
        "Types of leave are classified in the Labor Standards Act.",
        "The remaining days of your leave are on in-house browser.",
        "You can request a leave via the in-house browser.",
        "You can cancel your leave request via the in-house browser."
    ]

    i18n_text_fmts = [
        _("Types of leave are classified in the Labor Standards Act."),
        _("The remaining days of your leave are on in-house browser."),
        _("You can request a leave via the in-house browser."),
        _("You can cancel your leave request via the in-house browser.")
    ]

    carousel = create_carousel("query_leave",
                               labels,
                               POST_BACK_URLS["leave"],
                               texts,
                               titles,
                               CAROUSEL["leave"],
                               fmt_labels=i18n_label_fmts,
                               fmt_texts=i18n_text_fmts,
                               fmt_titles=i18n_title_fmts)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])
예제 #11
0
def query_welfare(account_id, __, ___):
    """
    This function deals with user query welfare related problems.

    :param account_id: user account id.
    """
    status, __, type, message = get_user_status(account_id)
    if status == "wait_in":
        set_user_status(account_id, status="none")

    fmt = _("Here are FAQs about welfare and work support.")
    text = make_i18n_text("Here are FAQs about welfare and work support.",
                          "query_welfare", fmt)

    fmt = _("Send a question")
    replay = create_quick_replay_item("transfer_welfare", "query_welfare",
                                      "Send a question", fmt)

    labels = ["See more", "See more", "See more", "See more"]

    fmt = _("See more")
    i18n_label_fmts = [fmt, fmt, fmt, fmt]

    titles = [
        "The types of in-house welfare.",
        "What kinds of in-house clubs are there?", "Can I use a company car?",
        "How can I receive office supplies?"
    ]

    i18n_title_fmts = [
        _("The types of in-house welfare."),
        _("What kinds of in-house clubs are there?"),
        _("Can I use a company car?"),
        _("How can I receive office supplies?")
    ]

    texts = [
        "Welfare includes the four main insurances, checkup, etc.",
        "A variety of club activities such as sports are supported.",
        "Contact the Work Support Team to request a company car.",
        "Visit the Work Support Team to receive office supplies."
    ]

    i18n_text_fmts = [
        _("Welfare includes the four main insurances, checkup, etc."),
        _("A variety of club activities such as sports are supported."),
        _("Contact the Work Support Team to request a company car."),
        _("Visit the Work Support Team to receive office supplies.")
    ]

    carousel = create_carousel("query_welfare",
                               labels,
                               POST_BACK_URLS["welfare"],
                               texts,
                               titles,
                               CAROUSEL["welfare"],
                               fmt_labels=i18n_label_fmts,
                               fmt_texts=i18n_text_fmts,
                               fmt_titles=i18n_title_fmts)

    carousel["quickReply"] = replay

    yield push_messages(account_id, [text, carousel])