\n제작 신청 완료 :o:".format(book_name=book_name), "img": "https://img1.daumcdn.net/thumb/R658x0.q70/?fname=https://t1.daumcdn.net/news/202105/22/ziksir/20210522002753132raip.jpg" } elif result == "False": response = { "text": "<{book_name}>\n제작 불가능 :x:\n(제작 가능한 페이지 없음)".format(book_name=book_name), "img": "https://mblogthumb-phinf.pstatic.net/MjAxNzA4MjFfOSAg/MDAxNTAzMjc3NDY3NjAy.iS-qa_d7LLGYxZ8vbwqFgntQ1QUxOXeRYcP-OVbVVCMg._E-iFuVvR"> \n제작 신청 완료 :o:".format(book_name=book_name), "img": "https://img1.daumcdn.net/thumb/R658x0.q70/?fname=https://t1.daumcdn.net/news/202105/22/ziksir/20210522002753132raip.jpg" } elif result == "False": response = { "text": "<{book_name}>\n제작 불가능 :x:\n(제작 가능한 페이지 없음)".format(book_name=book_name), "img": "https://mblogthumb-phinf.pstatic.net/MjAxNzA4MjFfOSAg/MDAxNTAzMjc3NDY3NjAy.iS-qa_d7LLGYxZ8vbwqFgntQ1QUxOXeRYcP-OVbVVCMg._E-iFuVvR"> \n제작 신청 완료 :o:".format(book_name=book_name), "img": "https://img1.daumcdn.net/thumb/R658x0.q70/?fname=https://t1.daumcdn.net/news/202105/22/ziksir/20210522002753132raip.jpg" } elif result == "False": response = { "text": "<{book_name}>\n제작 불가능 :x:\n(제작 가능한 페이지 없음)".format(book_name=book_name), "img": "https://mblogthumb-phinf.pstatic.net/MjAxNzA4MjFfOSAg/MDAxNTAzMjc3NDY3NjAy.iS-qa_d7LLGYxZ8vbwqFgntQ1QUxOXeRYcP-OVbVVCMg._E-iFuVvR">
import json
import selenium_function
import message_function

def lambda_handler(event, context):
    data = json.loads((json.dumps(event)))
    print(json.dumps(event))
    
    book_url = data["actions"][0]["value"]
    book_name = data["message"]["blocks"][1]["alt_text"]
    channel_id = data["container"]["channel_id"]
    message_ts = data["container"]["message_ts"]
    
    result = selenium_function.auto_booking(book_url)
    if result == "True":
        response = {
            "text": "<{book_name}>\\n제작 신청 완료 :o:".format(book_name=book_name),
            "img": "<https://img1.daumcdn.net/thumb/R658x0.q70/?fname=https://t1.daumcdn.net/news/202105/22/ziksir/20210522002753132raip.jpg>"
        }
    elif result == "False":
        response = {
            "text": "<{book_name}>\\n제작 불가능 :x:\\n(제작 가능한 페이지 없음)".format(book_name=book_name),
            "img": "<https://mblogthumb-phinf.pstatic.net/MjAxNzA4MjFfOSAg/MDAxNTAzMjc3NDY3NjAy.iS-qa_d7LLGYxZ8vbwqFgntQ1QUxOXeRYcP-OVbVVCMg._E-iFuVvRcy-sVtWvbYPEJpjHagk3r5iE2nTUWOlLeIg.JPEG.lccthebox/IMG_4642.jpg?type=w800>"
        }
    else:
         response = {
            "text": "<{book_name}>\\n제작 불가능 :x:\\n(편집 중인 도서 존재)".format(book_name=book_name),
            "img": "<https://thumb.pann.com/tc_480/http://fimg3.pann.com/new/download.jsp?FileID=34491102>"
        }
    
    print(response)
        
    message_function.update(channel_id, message_ts, response)
    
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }