• Share this text:
Report Abuse
Fucntion for msg markup - posted by guest on 22nd December 2019 10:58:48 AM

def box_list(key,value):

    each_box = {

                "type": "box",

                "layout": "vertical",

                "contents": [

                {

                    "type": "text",

                    "text": "| {}".format(key),

                    "size": "sm",

                    "color": "#888888",

                    "flex": 0

                },

                {

                    "type": "text",

                    "text": value,

                    "size": "xxs",

                    "color": "#111111",

                    "align": "start",

                    "wrap": True

                }

                ]

        }

    return each_box

def flex_find_row(แถวที่พบ,คำที่ค้นหา,คะแนนความเที่ยงตรง,คอลัมน์ที่ค้นพบคำนี้,รายการที่ค้นพบ):

    all_boxes = []

    for key,val in รายการที่ค้นพบ.items():

        box = box_list(key,val)

        all_boxes.append(box)

    seperator = {

                "type": "separator",

                "margin": "sm"

            }

    all_boxes.append(seperator)

     bubble ={

    "type": "bubble",

    "size": "giga",

    "body": {

        "type": "box",

        "layout": "vertical",

        "contents": [

        {

            "type": "text",

            "text": "โครงการ :บ้านสองชั้น 20 ล้าน",

            "weight": "bold",

            "color": "#1DB446",

            "size": "sm"

        },

        {

            "type": "text",

            "text": "| ตำแหน่งที่พบ : แถวที่ {}".format(แถวที่พบ),

            "weight": "bold",

            "size": "lg",

            "margin": "xs"

        },

        {

            "type": "text",

            "text": "คำที่ค้นหา : {}".format(คำที่ค้นหา),

            "size": "xs",

            "color": "#aaaaaa",

            "wrap": True,

            "align": "start",

            "margin": "md"

        },

        {

            "type": "text",

            "text": "คะแนนความเที่ยงตรง : {}".format(คะแนนความเที่ยงตรง),

            "size": "xs",

            "color": "#aaaaaa",

            "wrap": True,

            "align": "start",

            "margin": "none"

        },

        {

            "type": "text",

            "size": "xs",

            "color": "#aaaaaa",

            "wrap": True,

            "align": "start",

            "text": "คอลัมน์ที่ค้นพบคำนี้ : {}".format(คอลัมน์ที่ค้นพบคำนี้)

        },

        {

            "type": "separator",

            "margin": "xxl"

        },

        {

            "type": "box",

            "layout": "vertical",

            "margin": "xl",

            "spacing": "sm",

            "contents": all_boxes

        },

        {

            "type": "separator",

            "margin": "xxl"

        },

        {

            "type": "box",

            "layout": "horizontal",

            "margin": "md",

            "contents": [

            {

                "type": "text",

                "text": "ลิงค์ Google Sheet",

                "size": "xs",

                "color": "#aaaaaa",

                "flex": 0

            },

            {

                "type": "text",

                "text": "คลิก",

                "color": "#1DB446",

                "size": "xs",

                "align": "end",

                "action": {

                "type": "uri",

                "label": "action",

                "uri": "https://docs.google.com/spreadsheets/d/1jJh2FrTGco-c_-W_a6ZRvr_Vhu3lu5lxS5TalCLozqg/edit#gid=680682167"

                }

            }

            ]

        },

        {

            "type": "box",

            "layout": "vertical",

            "contents": [

            {

                "type": "image",

                "url": "https://cdn-images.prod.thinkofliving.com/wp-content/uploads/1/2019/04/24112413/05-NEO-HOME_Italian-Style.jpg",

                "position": "relative",

                "size": "md",

                "aspectMode": "cover"

            }

            ],

            "position": "absolute",

            "cornerRadius": "50px",

            "borderWidth": "2px",

            "borderColor": "#000000",

            "offsetEnd": "20px",

            "offsetTop": "20px"

        }

        ]

    },

    "styles": {

        "footer": {

        "separator": True

        }

    }

    }

    return bubble

def make_carousel(all_bubble):

    carousel = {

  "type": "carousel",

  "contents": all_bubble

  }

    flex = {

  "type": "flex",

  "altText": "Flex Message",

  "contents": carousel

  }

  return flex

Report Abuse

Login or Register to edit or copy and save this text. It's free.