Beispiel #1
0
def batch_record(event):
    if event.message.text == 'batch':
        try:
            reply = '權限不足'
            if access_right(event.source.user_id):
                timestamp = event.timestamp
                date_time = Methods.Timestamp_Datetime(timestamp)
                editor = event.source.user_id
                df = Google_API.Batch_import()
                c = 0
                for location in df.values.tolist():
                    location = location[0]
                    lat, lng, address = Google_API.get_GC(location)
                    if lat != None:
                        My_SQL.DB.insert_data(date_time, location, address,
                                              lat, lng, editor)
                        c += 1
                reply = '成功匯入{}筆資料'.format(c)
            line_bot_api.reply_message(event.reply_token,
                                       TextSendMessage(reply))
        except Exception as msg:
            print(msg)
        return True
    else:
        return False
Beispiel #2
0
def clock(event):
    if event.message.text == '打卡':
        try:
            user_id = event.source.user_id
            timestamp = event.timestamp
            date_time = Methods.Timestamp_Datetime(timestamp)
            data = My_SQL.DB.select_profile(user_id)

            if data:
                user_name = data[0][1]
                user_info = data[0][3]
                user_image = data[0][4]

                contents = Flex_Message.simulator(user_image, user_name,
                                                  user_info, date_time)

                line_bot_api.reply_message(
                    event.reply_token,
                    FlexSendMessage(alt_text='說明文字', contents=contents))
            else:
                line_bot_api.reply_message(event.reply_token,
                                           TextSendMessage('你是誰??先去報到'))
        except Exception as msg:
            print(msg)
        return True
    else:
        return False
Beispiel #3
0
def handle_postback(event):
    user_id = event.source.user_id
    timestamp = event.timestamp
    time_is = Methods.Timestamp_Datetime(timestamp)

    if event.postback.data == 'clock_in':
        reply = clock_in(user_id, time_is)

    elif event.postback.data == 'clock_out':
        reply = clock_out(user_id, time_is)

    line_bot_api.reply_message(event.reply_token, TextSendMessage(text=reply))
Beispiel #4
0
def insert_record(event):
    if '@' in event.message.text:
        try:
            timestamp = event.timestamp
            date_time = Methods.Timestamp_Datetime(timestamp)
            location = event.message.text.strip('@')
            lat, lng, address = Google_API.get_GC(location)
            editor = event.source.user_id
            if lat != None:
                reply = My_SQL.DB.insert_data(date_time, location, address,
                                              lat, lng, editor)
            else:
                reply = '請輸入正確地標或地址'
            line_bot_api.reply_message(event.reply_token,
                                       TextSendMessage(reply))
        except Exception as msg:
            print(msg)
        return True
    else:
        return False
Beispiel #5
0
def completed_record(event):
    if '#' in event.message.text:
        try:
            timestamp = event.timestamp
            Completion = Methods.Timestamp_Datetime(timestamp)
            Labor = event.source.user_id
            Location = event.message.text.strip('#')
            access = clocked(Labor, Completion)
            if access:
                reply = My_SQL.DB.mission_completed(Location, Labor,
                                                    Completion)
            else:
                reply = '先去打卡喔!'
            line_bot_api.reply_message(event.reply_token,
                                       TextSendMessage(reply))
        except Exception as msg:
            print(msg)
        return True
    else:
        return False