def reminder_message(process):
    """
    Illegal request reminder.

    :param process: Current user's progress
    :return: text type message
    """
    text = None
    if process == "sign_in_done":
        fmt = _("There is already a clock-in time. Please select "
                "\"Record\" on the bottom of the menu when you clock out.")
        text = make_i18n_text("There is already a clock-in time. "
                              "Please select \"Record\" on the "
                              "bottom of the menu when you clock out.",
                              "message", fmt)

    elif process == "sign_out_done":
        fmt = _("There is already a clock-out time. "
                "Please select \"Record\" on the bottom "
                "of the menu when you clock in.")
        text = make_i18n_text("There is already a clock-out time. "
                              "Please select \"Record\" on the bottom "
                              "of the menu when you clock in.",
                              "message", fmt)
    elif process is None:
        fmt = _("Today's clock-in time has not been registered. "
                "Please select \"Record clock-in\" on the bottom of the menu, "
                "and enter your clock-in time.")
        text = make_i18n_text("Today's clock-in time has not been registered. "
                              "Please select \"Record clock-in\" on the bottom "
                              "of the menu, and enter your clock-in time.",
                              "message", fmt)
    return text
예제 #2
0
def to_first(account_id, ____, __, ___):
    fmt = _("Please select \"Record\" on the bottom of "
            "the menu each time when you clock in and clock out.")
    content = make_i18n_text("Please select \"Record\" on the bottom of the "
                             "menu each time when you clock in and clock out.",
                             "to_first", fmt)
    yield push_message(account_id, content)
def start_content(account_id):
    yield sign(account_id)

    fmt = _("Hello, I'm an attendance management bot of WORKS "
            "that helps your timeclock management and entry.")
    content1 = make_i18n_text(
        "Hello, I'm an attendance management bot of "
        "WORKS that helps your timeclock "
        "management and entry.", "start", fmt)
    content2 = image_introduce()

    return [content1, content2]
예제 #4
0
def manual_sign_in_message():
    """
    generate manual check-in message

    :return: message content list
    """
    fmt = _("Please manually enter the clock-in time.")
    text1 = make_i18n_text("Please manually enter the clock-in time.",
                           "manual_sign_in", fmt)

    text2 = prompt_input()

    return [text1, text2]
def invalid_message():
    """
    Invalid input data reminder.

    :return: text type message
    """
    fmt = _("The text could not be understood. "
            "Please select the appropriate \"Record\" button on "
            "the bottom of the menu when you clock in or clock out.")

    return make_i18n_text("The text could not be understood. "
                          "Please select the appropriate \"Record\" button on "
                          "the bottom of the menu when you clock in or clock out.",
                          "message", fmt)
def error_message():
    """
    Wrong data entered

    :return: text type message
    """
    fmt = _("Sorry, but unable to comprehend your composed time. "
            "Please check the time entry method again, and enter the time.")
    text1 = make_i18n_text("Sorry, but unable to comprehend your composed time. "
                           "Please check the time entry method again, "
                           "and enter the time.", "message", fmt)

    text2 = prompt_input()
    return [text1, text2]
예제 #7
0
def deal_sign_in_message(sign_time, manual_flag):
    """
    Generate a message returned to the user when checking in.

    :param sign_time: The user's check-in time is a timestamp.
    :param manual_flag: Boolean value. True is manually enters time.
    :return: message content is a json.
    """
    call_back = "sign_in"
    if manual_flag:
        call_back = "manual_sign_in"

    user_time = TimeStruct(sign_time)

    fmt = _("Register the current time {date} as clock-in time?")
    fmt1 = _("%A, %B %-d at %-I:%M %P")

    text = make_i18n_text("Register the current time {date} as clock-in time?",
                          "direct_sign_in",
                          fmt,
                          fmt1=fmt1,
                          date=user_time.date_time)

    if manual_flag:
        fmt = _("Register the entered {date} as clock-in time?")
        text = make_i18n_text("Register the entered {date} as clock-in time?",
                              "direct_sign_in",
                              fmt,
                              fmt1=fmt1,
                              date=user_time.date_time)

    reply_items = create_quick_replay_items(
        "confirm_in&time=" + user_time.str_current_time_tick, call_back)

    text["quickReply"] = make_quick_reply(reply_items)

    return text
def deal_confirm_in(account_id, create_time, callback):
    """
    will be linked with the calendar internally, Check in time of registered user.
    Check also: attendance_management_bot/externals/calendar_req.py

    :param account_id: user account id.
    :param create_time: current date by local time.
    :param callback: The message content of the callback,
        include the user's check-in time
    :return: Prompt message of successful check in.
    """
    print("deal_confirm_in")
    pos = callback.find("time=")
    str_time = callback[pos + 5:]
    user_time = int(str_time)
    my_end_time = user_time + 60
    begin_time = local_date_time(user_time)
    current_date = datetime.strftime(begin_time, '%Y-%m-%d')

    info = get_schedule_by_user(account_id, current_date)
    if info is not None:
        raise HTTPError(500, "Internal data error")

    end_time = begin_time + timedelta(minutes=1)
    cur_time = local_date_time(create_time)
    fmt = _("{account}'s clock-in time on {date}")
    fmt1 = _("%A, %B %d")

    print("deal_confirm_in:get_i18n")
    title = get_i18n_content_by_lang(
        fmt,
        "confirm_in",
        DEFAULT_LANG,
        fmt1=fmt1,
        account=get_user_info_by_account(account_id),
        date=begin_time)

    print("deal_confirm_in:create_schedule")
    schedule_uid = create_schedule(cur_time, end_time, begin_time, account_id,
                                   title)

    print("deal_confirm_in:set_schedule_by_user")
    set_schedule_by_user(schedule_uid, account_id, current_date, user_time,
                         my_end_time)

    fmt = _("Clock-in time has been registered.")
    return make_i18n_text("Clock-in time has been registered.", "confirm_in",
                          fmt)
def number_message():
    """
    Non digital message entered.

    :return: text type message
    """
    fmt = _("Clock-out time was recorded as being earlier than the time of "
            "clock-in. Please check the clock-out time again and re-enter it. ")
    text1 = make_i18n_text("Clock-out time was recorded as being earlier "
                           "than the time of clock-in."
                           "Please check the clock-out time again "
                           "and re-enter it. ",
                           "message", fmt)

    text2 = prompt_input()
    return [text1, text2]
def prompt_input():
    """
    Format to remind users to enter time.

    :return: text type message
    """

    fmt = _("Please use the military time format with a total of 4 numerical "
            "digits (hhmm) when entering the time. "
            "For example, type 2020 to indicate 8:20 PM. ")

    return make_i18n_text("Please use the military time format "
                          "with a total of 4 numerical digits (hhmm) "
                          "when entering the time. For example, "
                          "type 2020 to indicate 8:20 PM. ",
                          "message", fmt)