def deal_sign_out_message(sign_time, manual_flag=False): call_back = "sign_out" if manual_flag: call_back = "manual_sign_out" user_time = TimeStruct(sign_time) text = make_text("Register the current time {date} at {hours}:{min} " "{interval} as clock-out time?" .format(date=user_time.date_time.strftime('%m, %d %A'), hours=user_time.hours, min=user_time.min, interval=user_time.interval_en)) if manual_flag: text = make_text("Register the entered {date} at {hours}:{min} " "{interval} as clock-out time?" .format(date=user_time.date_time.strftime('%m, %d %A'), hours=user_time.hours, min=user_time.min, interval=user_time.interval_en)) reply_items = create_quick_replay_items( "confirm_out&time=" + user_time.str_current_time_tick, call_back) text["quickReply"] = make_quick_reply(reply_items) return text
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) text = make_text("Register the current time {date} at {hours}:{min} " "{interval} as clock-in time?".format( date=user_time.date_time.strftime('%m, %d %A'), hours=user_time.hours, min=user_time.min, interval=user_time.interval_en)) if manual_flag: text = make_text("Register the entered {date} at {hours}:{min} " "{interval} as clock-in time?".format( date=user_time.date_time.strftime('%m, %d %A'), hours=user_time.hours, min=user_time.min, interval=user_time.interval_en)) 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 reminder_message(process): text = None if process == "sign_in_done": text = make_text("There is already a clock-in time. " "Please select \"Record\" on the " "bottom of the menu when you clock out.") elif process == "sign_out_done": text = make_text("There is already a clock-out time." "Please select \"Record\" on the bottom " "of the menu when you clock in.") elif process is None: text = make_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.") 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: calendar_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. """ 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) title = "[{account}]'s clock-in time on {date}".\ format(account=account_id, date=datetime.strftime(begin_time, '%A, %B %d')) schedule_uid = create_schedule(cur_time, end_time, begin_time, account_id, title) set_schedule_by_user(schedule_uid, account_id, current_date, user_time, my_end_time) return make_text("Clock-in time has been registered.")
def number_message(): text1 = make_text("You have created your leave time " "earlier than your leave time. " "Please check your work time and enter again.") text2 = prompt_input() return [text1, text2]
def error_message(): text1 = make_text("Sorry, but unable to " "comprehend your composed time. " "Please check the time entry method again, " "and enter the time.") text2 = prompt_input() return [text1, text2]
def confirm_out_message(user_time, hours, min): user_time = TimeStruct(user_time) return make_text("Clock-out time has been registered." "The total working hours for {date} " "is {hours} hours and {minutes} minutes." .format(date=user_time.date_time.strftime('%A, %B %d'), hours=hours, minutes=min))
def start_content(account_id): yield sign(account_id) content1 = make_text("Hello, I'm an attendance management bot of " "LINE WORKS that helps your timeclock " "management and entry.") content2 = image_introduce() return [content1, content2]
def invalid_message(): """ Invalid input data reminder. :return: text type message """ return make_text("I didn't understand the text. " "When you go to work or go home, " "Please select the appropriate " "\"Record\" button for each.")
def prompt_input(): """ Format to remind users to enter time. :return: text type message """ return make_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. ")
def manual_sign_out_message(): """ generate manual check-out message :return: message content list """ text1 = make_text("Please manually enter the clock-out time.") text2 = prompt_input() return [text1, text2]
def manual_sign_out_message(): jp_text = i18n_text("ja_JP", "退勤時間を直接入力してください。") en_text = i18n_text("en_US", "Please manually enter the clock-out time.") kr_text = i18n_text("ko_KR", "퇴근 시간을 직접 입력해 주세요. ") i18n_texts1 = [jp_text, en_text, kr_text] text1 = make_text("퇴근 시간을 직접 입력해 주세요. ", i18n_texts1) text2 = prompt_input() return [text1, text2]
def to_first_content(): kr_text = i18n_text("ko_KR", "출근, 퇴근하실 때 하단 메뉴에서 " "각각에 맞는 ‘기록하기’ 버튼을 선택해 주세요") en_text = i18n_text( "en_US", "Please select \"Record\" on the bottom of " "the menu each time when you clock in " "and clock out.") jp_text = i18n_text("ja_JP", "出勤、退勤するときに下のメニューから " "それぞれ「記録する」ボタンを選択してください。") i18n_texts = [kr_text, en_text, jp_text] text = make_text("출근, 퇴근하실 때 하단 메뉴에서 " "각각에 맞는 ‘기록하기’ 버튼을 선택해 주세요", i18n_texts) return text
def first_message(): kr_text = i18n_text( "ko_KR", "안녕하세요, 출퇴근 시간을 입력하고 " "관리할 수 있도록 도와드리는 " "LINE WORKS의 근태관리 봇 입니다.") en_text = i18n_text( "en_US", "Hello, I'm an attendance management " "bot of LINE WORKS that helps your " "timeclock management and entry.") jp_text = i18n_text( "ja_JP", "こんにちは。出退勤の時間を入力して " "管理できるようサポートするLINE WORKSの " "勤怠管理Botです。") i18n_texts = [kr_text, en_text, jp_text] text = make_text( "안녕하세요, 출퇴근 시간을 입력하고 " "관리할 수 있도록 도와드리는 " "LINE WORKS의 근태관리 봇 입니다.", i18n_texts) return text
def deal_confirm_in(account_id, create_time, callback): 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) schedule_uid = create_schedule(cur_time, end_time, begin_time, account_id) set_schedule_by_user(schedule_uid, account_id, current_date, user_time, my_end_time) return make_text("Clock-in time has been registered.")
def manual_sign_out_message(): text1 = make_text("Please manually enter the clock-out time.") text2 = prompt_input() return [text1, text2]
def to_first(account_id, _, __, ___): content = make_text("Please select \"Record\" on the bottom of " "the menu each time when you clock in and clock out.") yield push_message(account_id, content)
def invalid_message(): return make_text("I didn't understand the text. " "When you go to work or go home, " "Please select the appropriate " "\"Record\" button for each.")