Exemplo n.º 1
0
def sendImgmap(event):  #圖片地圖
    try:
        image_url = 'https://i.imgur.com/Yz2yzve.jpg'  #圖片位址
        imgwidth = 1040  #原始圖片寛度一定要1040
        imgheight = 300
        message = ImagemapSendMessage(
            base_url=image_url,
            alt_text="圖片地圖範例",
            base_size=BaseSize(height=imgheight, width=imgwidth),  #圖片寬及高
            actions=[
                MessageImagemapAction(  #顯示文字訊息
                    text='你點選了紅色區塊!',
                    area=ImagemapArea(  #設定圖片範圍:左方1/4區域
                        x=0, 
                        y=0, 
                        width=imgwidth*0.25, 
                        height=imgheight  
                    )
                ),
                URIImagemapAction(  #開啟網頁
                    link_uri='http://www.e-happy.com.tw',
                    area=ImagemapArea(  #右方1/4區域(藍色1)
                        x=imgwidth*0.75, 
                        y=0, 
                        width=imgwidth*0.25, 
                        height=imgheight  
                    )
                ),
            ]
        )
        line_bot_api.reply_message(event.reply_token, message)
    except:
        line_bot_api.reply_message(event.reply_token,TextSendMessage(text='發生錯誤!'))
Exemplo n.º 2
0
def googlemap_imagemap_view(text):
    googlemap_geocoding_api_key = app.config['GOOGLE_MAP_API_KEY']
    googlemap_geocoding_base_url = "https://maps.googleapis.com/maps/api/geocode/json?"
    googlemap_geocoding_query = urllib.parse.urlencode({
        "address":
        text,
        "key":
        googlemap_geocoding_api_key
    })
    try:
        req = requests.get(googlemap_geocoding_base_url +
                           googlemap_geocoding_query)
        result = json.loads(req.text)
        lat = result["results"][0]["geometry"]["location"]["lat"]
        lng = result["results"][0]["geometry"]["location"]["lng"]
        googlemap_staticmap_api_key = app.config['GOOGLE_STATIC_MAPS_API_KEY']
        googlemap_staticmap_base_url = "https://maps.googleapis.com/maps/api/staticmap?"
        googlemap_staticmap_query = urllib.parse.urlencode({
            "center":
            "%s,%s" % (lat, lng),
            "size":
            "520x520",
            "sensor":
            "false",
            "scale":
            2,
            "maptype":
            "roadmap",
            "zoom":
            18,
            "markers":
            "%s,%s" % (lat, lng),
            "key":
            googlemap_staticmap_api_key
        })
        googlemap_staticmap_url = googlemap_staticmap_base_url + googlemap_staticmap_query

        view = ImagemapSendMessage(
            base_url='https://{}/imagemap/{}'.format(
                request.host,
                urllib.parse.quote_plus(googlemap_staticmap_url)),
            alt_text='googlemap',
            base_size=BaseSize(height=1040, width=1040),
            actions=[
                URIImagemapAction(
                    # link_uri='comgooglemaps://?ll=%f,%f&q=%s' % (lat, lng, text),
                    link_uri='http://maps.google.co.jp/maps?q=%f,%f' %
                    (lat, lng),
                    area=ImagemapArea(x=0, y=0, width=1040, height=1040))
            ])

    except:
        view = TextSendMessage(text="ん〜〜「%s」はGoogleMapにないなぁ..." % text)

    return view
Exemplo n.º 3
0
def push_ads(user_id):
    #photo_url = 'https://github.com/housekeepbao/flight_bot/blob/master/images/travel_test_img.png?raw=true'
    #link_url = 'https://www.google.com.tw/maps/place/%E5%8F%A4%E6%97%A9%E5%91%B3%E5%B0%8F%E5%90%83%E5%BA%97/@25.0629705,121.5012555,23.8z/data=!4m8!1m2!2m1!1z5Y-w5YyX5qmLIOe-jumjnw!3m4!1s0x3442a92298613293:0xcff4aac1356b306!8m2!3d25.0629585!4d121.50107?hl=zh-TW'
    photo_url, link_url, action_list = get_ads_info()
    imagemap_message = ImagemapSendMessage(
        base_url=photo_url,
        alt_text='this is an imagemap',
        base_size=BaseSize(height=1024, width=1024),
        actions=action_list
    )
    push_message(user_id, imagemap_message)
Exemplo n.º 4
0
    def setUp(self):
        self.tested = LineBotApi('d42b9b5dc4df7ad44e9bddd5ee915fc7')

        self.imagemap_message = ImagemapSendMessage(
            base_url='https://example.com/base',
            alt_text='this is an imagemap',
            base_size=BaseSize(height=1040, width=1040),
            actions=[
                URIImagemapAction(
                    link_uri='https://example.com/',
                    area=ImagemapArea(
                        x=0, y=0, width=520, height=1040
                    )
                ),
                MessageImagemapAction(
                    text='hello',
                    area=ImagemapArea(
                        x=520, y=0, width=520, height=1040
                    )
                )
            ]
        )

        self.message = [{
            "type": "imagemap",
            "baseUrl": "https://example.com/base",
            "altText": "this is an imagemap",
            "baseSize": {
                "height": 1040,
                "width": 1040
            },
            "actions": [
                {
                    "type": "uri",
                    "linkUri": "https://example.com/",
                    "area": {
                        "x": 0,
                        "y": 0,
                        "width": 520,
                        "height": 1040
                    }
                },
                {
                    "type": "message",
                    "text": "hello",
                    "area": {
                        "x": 520,
                        "y": 0,
                        "width": 520,
                        "height": 1040
                    }
                }
            ]
        }]
Exemplo n.º 5
0
def floor_plan():
    floor = ImagemapSendMessage(
        base_url='https://i.imgur.com/dMk5Vrj.png',
        alt_text='請用手機點選該位置!',
        base_size=BaseSize(height=1040, width=1040),
        actions=[
            MessageImagemapAction(text='上左',
                                  area=ImagemapArea(x=0,
                                                    y=0,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='上中',
                                  area=ImagemapArea(x=357,
                                                    y=0,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='上右',
                                  area=ImagemapArea(x=715,
                                                    y=0,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='中左',
                                  area=ImagemapArea(x=0,
                                                    y=357,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='中中',
                                  area=ImagemapArea(x=357,
                                                    y=357,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='中右',
                                  area=ImagemapArea(x=715,
                                                    y=357,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='下左',
                                  area=ImagemapArea(x=0,
                                                    y=715,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='下中',
                                  area=ImagemapArea(x=357,
                                                    y=715,
                                                    width=357,
                                                    height=357)),
            MessageImagemapAction(text='下右',
                                  area=ImagemapArea(x=715,
                                                    y=715,
                                                    width=357,
                                                    height=357)),
        ])

    return floor
Exemplo n.º 6
0
 def send_single_imagemap(self, user_ids, alt_text, image_url, keyword):
     payload = ImagemapSendMessage(base_url=image_url,
                                   alt_text=alt_text,
                                   base_size=BaseSize(height=1040,
                                                      width=1040),
                                   actions=[
                                       MessageImagemapAction(
                                           text=keyword,
                                           area=ImagemapArea(x=0,
                                                             y=0,
                                                             width=1040,
                                                             height=1040))
                                   ])
     user_ids = user_ids.split(",")
     self.__send_multicast(user_ids, payload)
Exemplo n.º 7
0
def generate_planning_poker_message(number):
    app.logger.info('[number] :' + number)
    data = redis.hgetall(number + '_member')
    tmpnum = generate_voting_target_image(number, data)

    count = len(data)
    if count < 3:
        vote_height = 260
        row_count = 1
    elif count < 7:
        vote_height = 520
        row_count = 2
    else:
        vote_height = 780
        row_count = 3

    message = ImagemapSendMessage(base_url=HEROKU_SERVER_URL + 'images/tmp/' +
                                  tmpnum,
                                  alt_text='vote board',
                                  base_size=BaseSize(height=vote_height,
                                                     width=1040))
    actions = []
    location = 0
    for i in range(0, row_count):
        for j in range(0, 4):
            if location == count + 1:  #最後
                actions.append(
                    MessageImagemapAction(
                        text=u'#' + str(number).encode('utf-8') + u' 11',
                        area=ImagemapArea(
                            x=j * POKER_IMAGEMAP_ELEMENT_WIDTH,
                            y=i * POKER_IMAGEMAP_ELEMENT_HEIGHT,
                            width=(j + 1) * POKER_IMAGEMAP_ELEMENT_WIDTH,
                            height=(i + 1) * POKER_IMAGEMAP_ELEMENT_HEIGHT)))
            else:
                actions.append(
                    MessageImagemapAction(
                        text=u'#' + str(number).encode('utf-8') + u' ' +
                        str(location).encode('utf-8'),
                        area=ImagemapArea(
                            x=j * POKER_IMAGEMAP_ELEMENT_WIDTH,
                            y=i * POKER_IMAGEMAP_ELEMENT_HEIGHT,
                            width=(j + 1) * POKER_IMAGEMAP_ELEMENT_WIDTH,
                            height=(i + 1) * POKER_IMAGEMAP_ELEMENT_HEIGHT)))
                location += 1
    message.actions = actions
    return message
Exemplo n.º 8
0
def handle_message(event):
    profile = line_bot_api.get_profile(event.source.user_id)
    user_name = profile.display_name
    print(user_name + " :")
    print(event.source.user_id)
    print(event.message.text)
    if event.message.text == "寶寶":
        flex_message = baby_talk(event.source.user_id)
        line_bot_api.reply_message(event.reply_token, flex_message)
    elif event.message.text == "媽媽論壇":
        print("社群")
        message = []
        message.append(TextSendMessage(text="請選擇想加入的社群分類~"))
        message.append(ImagemapSendMessage(
            base_url="https://i.imgur.com/Vuh7xIP.jpg",
            alt_text="This is an imagemap",
            base_size=BaseSize(1040,1040),
            actions=[
                MessageImagemapAction(type='message',text="$素人媽媽", area=ImagemapArea(0, 0, 520, 520)),
                MessageImagemapAction(type='message',text="$醫生", area=ImagemapArea(0, 520, 520, 520)),
                MessageImagemapAction(type='message',text="$部落客", area=ImagemapArea(520, 0, 520, 520)),
                MessageImagemapAction(type='message',text="$其他", area=ImagemapArea(520, 520, 520, 520))
            ]
        ))
        line_bot_api.reply_message(event.reply_token, message)
    elif event.message.text == "大補帖":
        template = template_env.get_template('quick_reply.json')
        with open('quick_reply/week%s.json' % (str(week))) as f:
            option = json.load(f)
        data = template.render(option)
        data = eval(data)
        message = TextSendMessage(text='請輸入欲搜尋文章的關鍵字~', quick_reply=QuickReply.new_from_json_dict(data))
        line_bot_api.reply_message(event.reply_token, message)
    elif event.message.text.startswith("\\"):
        message = article_fetching((event.message.text).replace("\\", ""))
        line_bot_api.reply_message(event.reply_token, message)
    elif event.message.text.startswith("$"):
        if event.message.text == "$醫生":
            dir_name = './line_group/doctor/'
        elif event.message.text == "$素人媽媽":
            dir_name = './line_group/mommy/'
        elif event.message.text == "$部落客":
            dir_name = './line_group/blogger/'
        elif event.message.text == "$其他":
            dir_name = './line_group/others/'
        message = get_line_group(dir_name)
        line_bot_api.reply_message(event.reply_token,message)
Exemplo n.º 9
0
def reply(request):
    return ImagemapSendMessage(
        base_url='https://example.com/base',
        alt_text='this is an imagemap',
        base_size=BaseSize(height=1040, width=1040),
        actions=[
            URIImagemapAction(link_uri='https://example.com/',
                              area=ImagemapArea(x=0,
                                                y=0,
                                                width=520,
                                                height=1040)),
            MessageImagemapAction(text='hello',
                                  area=ImagemapArea(x=520,
                                                    y=0,
                                                    width=520,
                                                    height=1040))
        ])
Exemplo n.º 10
0
def generateJoinButton():
    message = ImagemapSendMessage(base_url=HEROKU_SERVER_URL + 'images/button',
                                  alt_text='join',
                                  base_size=BaseSize(height=178, width=1040))
    actions = []
    actions.append(
        MessageImagemapAction(text='join',
                              area=ImagemapArea(x=0,
                                                y=0,
                                                width=BUTTON_ELEMENT_WIDTH,
                                                height=BUTTON_ELEMENT_HEIGHT)))
    actions.append(
        MessageImagemapAction(text='add',
                              area=ImagemapArea(x=BUTTON_ELEMENT_WIDTH,
                                                y=0,
                                                width=BUTTON_ELEMENT_WIDTH * 2,
                                                height=BUTTON_ELEMENT_HEIGHT)))
    message.actions = actions
    return message
Exemplo n.º 11
0
def handle_follow(event):
    sendMessage = [
        TextSendMessage(text='首次加入的朋友,請先註冊才能進行查詢及申請。'),
        ImagemapSendMessage(
            base_url='https://dc10101.serveo.net/static/1/',
            alt_text='1',
            base_size=BaseSize(height=1040, width=1040),
            actions=[
                URIImagemapAction(
                    link_uri='https://dc10101.serveo.net/static/1/1040.png',
                    area=ImagemapArea(x=0, y=0, width=1040, height=1040)),
                MessageImagemapAction(text='註冊',
                                      area=ImagemapArea(x=520,
                                                        y=0,
                                                        width=50,
                                                        height=50))
            ])
    ]
    line_bot_api.reply_message(event.reply_token, sendMessage)
def handle_message(event):
    if event.type == "message":
        if event.message.type == "text":
            actions = []
            actions.append(
                MessageImagemapAction(
                    text='Button Pushed!',
                    area=ImagemapArea(
                        # Button is 100px on 700px. So 149 on base size(1040px)
                        x=0,
                        y=0,
                        width=149,
                        height=149)))
            message = ImagemapSendMessage(
                base_url='https://' + request.host + '/imagemap/' +
                uuid.uuid4().hex,  # prevent cache
                alt_text='代替テキスト',
                base_size=BaseSize(height=1040, width=1040),
                actions=actions)
            line_bot_api.reply_message(event.reply_token, message)
Exemplo n.º 13
0
    def send_single_imagemap(self, user_ids, alt_text, image_url, keyword):
        payload = ImagemapSendMessage(base_url=image_url,
                                      alt_text=alt_text,
                                      base_size=BaseSize(height=1040,
                                                         width=1040),
                                      actions=[
                                          MessageImagemapAction(
                                              text=keyword,
                                              area=ImagemapArea(x=0,
                                                                y=0,
                                                                width=1040,
                                                                height=1040))
                                      ])
        user_ids = user_ids.split(",")
        self.__send_multicast(user_ids, payload)


# bot = Bot('jn/yYyTgYipzoNX7DmjxT41uhepnyu2CkqRrzBRRghfBpIRCxVyuso+k7YSl4ESPqdsjAm2kccVHSPN3SQO+hjnWrshmHzxWTqWMceCzYVro/GThips/r6MeDjpmClOD56LvFWQRzGo11IoS3jw8ca18BSl7lGXPAT9HRw/DX2c=')
# print bot.get_profile('U6fb98eb0f44be13523bbabd566e47dc4')
# print bot.get_profile('U6fb98eb0f44be13523bbabd566e47dc4')
Exemplo n.º 14
0
def generate_planning_poker_message(number):
    message = ImagemapSendMessage(
        base_url='https://scrummasterbot.herokuapp.com/images/planning_poker',
        alt_text='planning poker',
        base_size=BaseSize(height=790, width=1040))
    actions = []
    location = 0
    for i in range(0, 3):
        for j in range(0, 4):
            actions.append(
                MessageImagemapAction(
                    text=u'#' + number + u' ' +
                    mapping[str(location).encode('utf-8')],
                    area=ImagemapArea(
                        x=j * POKER_IMAGEMAP_ELEMENT_WIDTH,
                        y=i * POKER_IMAGEMAP_ELEMENT_HEIGHT,
                        width=(j + 1) * POKER_IMAGEMAP_ELEMENT_WIDTH,
                        height=(i + 1) * POKER_IMAGEMAP_ELEMENT_HEIGHT)))
            location += 1
    message.actions = actions
    return message
Exemplo n.º 15
0
 def _create_zapper_imgmap(self, event):
     zapper_imgmap = ImagemapSendMessage(
         base_url=ZAPPER_IMGMAP_URL,
         alt_text='user zapper information',
         base_size=BaseSize(height=1040, width=1040),
         actions=[
             MessageImagemapAction(
                 text=self.render_text('zapper_imgmap/bind_zapper.j2'),
                 area=ImagemapArea(x=0, y=0, width=520, height=520))
         ])
     try:
         line_user = LineUser.objects.get(user_id=event.source.user_id)
     except LineUser.DoesNotExist:
         logger.error('Line User Does Not Exist')
     else:
         if line_user.zapper_id:
             # Use slice to prepend these three object to actions list.
             zapper_imgmap.actions[:0] = [
                 MessageImagemapAction(text=self.render_text(
                     'zapper_imgmap/self_zapper_cond.j2'),
                                       area=ImagemapArea(x=520,
                                                         y=0,
                                                         width=520,
                                                         height=520)),
                 MessageImagemapAction(text=self.render_text(
                     'zapper_imgmap/area_zapper_cond.j2'),
                                       area=ImagemapArea(x=0,
                                                         y=520,
                                                         width=520,
                                                         height=520)),
                 MessageImagemapAction(text=self.render_text(
                     'zapper_imgmap/zapper_assist.j2'),
                                       area=ImagemapArea(x=520,
                                                         y=520,
                                                         width=520,
                                                         height=520))
             ]
     return zapper_imgmap
Exemplo n.º 16
0
def create_img_map_msg():
    actions = []
    actions.append(URIImagemapAction(
        link_uri='line://app/1614481927-WbXaLGy0',
        area=ImagemapArea(
            x=0, y=0, width=520, height=520
    )
    ))
    actions.append(URIImagemapAction(
        link_uri='line://app/1614481927-BqrGLbvl',
        area=ImagemapArea(
            x=0, y=520, width=520, height=520
        )
    ))
    actions.append(URIImagemapAction(
        link_uri='line://app/1614481927-2N50kX34',
        area=ImagemapArea(
            x=520, y=0, width=520, height=520
        )
    ))
    actions.append(URIImagemapAction(
        link_uri='line://app/1614481927-WLrPnOXQ',
        area=ImagemapArea(
            x=520, y=520, width=520, height=520
        )

    ))

    message = ImagemapSendMessage(
        base_url='https://' + request.host + '/imagemap/' + uuid.uuid4().hex,
        alt_text='こんにちは!',
        base_size=BaseSize(height=1040, width=1040),
        actions=actions
    )

    return message
Exemplo n.º 17
0
def handle_message(event):
    if event.type == "message":
        if (event.message.text == "Curry Menu") or (event.message.text == "chicken_curry_cancel") or (event.message.text == "green_curry_cancel") or (event.message.text == "keema_curry_cancel"):
            TextSendMessage(
                text='画像メニューから自分好みのカレーを選んでね。',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/images01',

                alt_text='curry_imagemap_no.01',

                base_size=BaseSize(height=453, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='chicken_curry',
                        area=ImagemapArea(
                            x=30, y=50, width=320, height=355
                        )
                    ),
                    MessageImagemapAction(
                        text='green_curry',
                        area=ImagemapArea(
                            x=360, y=50, width=320, height=355
                        )
                    ),
                    MessageImagemapAction(
                        text='keema_curry',
                        area=ImagemapArea(
                            x=690, y=50, width=320, height=355
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
#img_powder
    if event.type == "message":
        if (event.message.text == "Powder Spice"):
            TextSendMessage(
                text='画像メニューから自分好みのスパイスを選んでね。',
            ),
            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/powder_img',

                alt_text='powder_spice_img',

                base_size=BaseSize(height=750, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='spice_clove',
                        area=ImagemapArea(
                            x=0, y=10, width=160, height=330
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_cinnamon',
                        area=ImagemapArea(
                            x=160, y=0, width=160, height=330
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_cumin',
                        area=ImagemapArea(
                            x=330, y=0, width=160, height=330
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_tougarashi',
                        area=ImagemapArea(
                            x=860, y=10, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_blackpepper',
                        area=ImagemapArea(
                            x=510, y=10, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_mace',
                        area=ImagemapArea(
                            x=690, y=0, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_tougarashi',
                        area=ImagemapArea(
                            x=860, y=0, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_bigcardamon',
                        area=ImagemapArea(
                            x=0, y=340, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_nutmeg',
                        area=ImagemapArea(
                            x=160, y=340, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_allspice',
                        area=ImagemapArea(
                            x=330, y=340, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_bayleaf',
                        area=ImagemapArea(
                            x=510, y=340, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_greencardamon',
                        area=ImagemapArea(
                            x=680, y=340, width=170, height=320
                        )
                    ),
                    MessageImagemapAction(
                        text='spice_coriander',
                        area=ImagemapArea(
                            x=860, y=340, width=170, height=320
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)

#spice_flavor_ring            
    if event.type == "message":
        if (event.message.text == "Whole Spice"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/s.f.h',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=995, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='spicy_flavor',
                        area=ImagemapArea(
                            x=100, y=500, width=280, height=210
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_flavor',
                        area=ImagemapArea(
                            x=390, y=60, width=240, height=230
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_flavor',
                        area=ImagemapArea(
                            x=650, y=280, width=270, height=210
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_flavor',
                        area=ImagemapArea(
                            x=380, y=710, width=260, height=240
                        )
                    ),
                    MessageImagemapAction(
                        text='hot_flavor',
                        area=ImagemapArea(
                            x=110, y=250, width=250, height=240
                        )
                    ),
                    MessageImagemapAction(
                        text='herb_flavor',
                        area=ImagemapArea(
                            x=650, y=500, width=270, height=210
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
            
    #hall_spice_sweet
    if event.type == "message":
        if (event.message.text == "sweet_flavor"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/hall_spice/sweet',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=994, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='sweet_1',
                        area=ImagemapArea(
                            x = 61, y = 40, width = 293, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_2',
                        area=ImagemapArea(
                            x = 366, y = 42, width = 304, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_3',
                        area=ImagemapArea(
                            x = 681, y = 45, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_4',
                        area=ImagemapArea(
                            x = 61, y = 355, width = 289, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_5',
                        area=ImagemapArea(
                            x = 366, y = 356, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_6',
                        area=ImagemapArea(
                            x = 677, y = 351, width = 314, height = 305
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_7',
                        area=ImagemapArea(
                            x = 50, y = 660, width = 309, height = 299
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_8',
                        area=ImagemapArea(
                            x = 369, y = 661, width = 304, height = 298
                        )
                    ),
                    MessageImagemapAction(
                        text='sweet_9',
                        area=ImagemapArea(
                            x = 680, y = 661, width = 320, height = 296
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
#hall_spice_spicy
    if event.type == "message":
        if (event.message.text == "spicy_flavor"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/hall_spice/spicy',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=773, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='spicy_1',
                        area=ImagemapArea(
                            x = 61, y = 40, width = 293, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='spicy_2',
                        area=ImagemapArea(
                            x = 366, y = 42, width = 304, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='spicy_3',
                        area=ImagemapArea(
                            x = 681, y = 45, width = 304, height = 291
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
            
    #hall_spice_hot
    if event.type == "message":
        if (event.message.text == "hot_flavor"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/hall_spice/hot',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=994, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='hot_1',
                        area=ImagemapArea(
                            x = 61, y = 40, width = 293, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='hot_2',
                        area=ImagemapArea(
                            x = 366, y = 42, width = 304, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='hot_3',
                        area=ImagemapArea(
                            x = 681, y = 45, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='hot_4',
                        area=ImagemapArea(
                            x = 61, y = 355, width = 289, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='hot_5',
                        area=ImagemapArea(
                            x = 366, y = 356, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='hot_6',
                        area=ImagemapArea(
                            x = 677, y = 351, width = 314, height = 305
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
            
    #hall_spice_harbr
    if event.type == "message":
        if (event.message.text == "herb_flavor"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/hall_spice/harbr',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=957, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='harbr_1',
                        area=ImagemapArea(
                            x = 61, y = 40, width = 293, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='harbr_2',
                        area=ImagemapArea(
                            x = 366, y = 42, width = 304, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='harbr_3',
                        area=ImagemapArea(
                            x = 681, y = 45, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='harbr_4',
                        area=ImagemapArea(
                            x = 61, y = 355, width = 289, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='harbr_5',
                        area=ImagemapArea(
                            x = 366, y = 356, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='harbr_6',
                        area=ImagemapArea(
                            x = 677, y = 351, width = 314, height = 305
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
            
    #hall_spice_fresh
    if event.type == "message":
        if (event.message.text == "fresh_flavor"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/hall_spice/fresh',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=992, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='fresh_1',
                        area=ImagemapArea(
                            x = 61, y = 40, width = 293, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_2',
                        area=ImagemapArea(
                            x = 366, y = 42, width = 304, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_3',
                        area=ImagemapArea(
                            x = 681, y = 45, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_4',
                        area=ImagemapArea(
                            x = 61, y = 355, width = 289, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_5',
                        area=ImagemapArea(
                            x = 366, y = 356, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_6',
                        area=ImagemapArea(
                            x = 677, y = 351, width = 314, height = 305
                        )
                    ),
                    MessageImagemapAction(
                        text='fresh_7',
                        area=ImagemapArea(
                            x = 50, y = 660, width = 309, height = 299
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
            
    #hall_spice_bitter
    if event.type == "message":
        if (event.message.text == "bitter_flavor"):
            TextSendMessage(
                text='flavor_ring',
            ),

            imagemap_message = ImagemapSendMessage(

                base_url='https://foodseasoning.web.fc2.com/img/hall_spice/bitter',

                alt_text='spice_flavor_ring',

                base_size=BaseSize(height=994, width=1040),

                actions=[
                    MessageImagemapAction(
                        text='bitter_1',
                        area=ImagemapArea(
                            x = 61, y = 40, width = 293, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_2',
                        area=ImagemapArea(
                            x = 366, y = 42, width = 304, height = 296
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_3',
                        area=ImagemapArea(
                            x = 681, y = 45, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_4',
                        area=ImagemapArea(
                            x = 61, y = 355, width = 289, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_5',
                        area=ImagemapArea(
                            x = 366, y = 356, width = 304, height = 291
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_6',
                        area=ImagemapArea(
                            x = 677, y = 351, width = 314, height = 305
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_7',
                        area=ImagemapArea(
                            x = 50, y = 660, width = 309, height = 299
                        )
                    ),
                    MessageImagemapAction(
                        text='bitter_8',
                        area=ImagemapArea(
                            x = 369, y = 661, width = 304, height = 298
                        )
                    )
                ]
            )
            line_bot_api.push_message(event.source.user_id, imagemap_message)
            
       
            
#クイックリプライ(spice_g)
#def spice_quantity
    if event.type == "message":
        if (event.message.text == "spice_clove") or (event.message.text == "spice_allspice") or (event.message.text == "spice_nutmeg") or (event.message.text == "spice_cinnamon") or (event.message.text == "spice_bigcardamon") or (event.message.text == "spice_mace") or (event.message.text == "spice_bayleaf"):
            line_bot_api.reply_message(
                    event.reply_token,
                    TextSendMessage(
                        text='ブレンドする量を選択してください',
                        quick_reply=QuickReply(
                            items=[
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1/2", text="spice_小さじ1/2")
                        ),
                    ])))
    if event.type == "message":
        if (event.message.text == "spice_blackpepper") or (event.message.text == "spice_tougarashi"):
            line_bot_api.reply_message(
                    event.reply_token,
                    TextSendMessage(
                        text='ブレンドする量を選択してください',
                        quick_reply=QuickReply(
                            items=[
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1/2", text="spice_小さじ1/2")
                        ),
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1", text="spice_小さじ1")
                        ),
                    ])))
    if event.type == "message":
        if (event.message.text == "spice_greencardamon"):
            line_bot_api.reply_message(
                    event.reply_token,
                    TextSendMessage(
                        text='ブレンドする量を選択してください',
                        quick_reply=QuickReply(
                            items=[
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1/2", text="spice_小さじ1/2")
                        ),
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1", text="spice_小さじ1")
                        ),
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ2", text="spice_小さじ2")
                        ),
                    ])))
    if event.type == "message":
        if (event.message.text == "spice_cumin") or (event.message.text == "spice_coriander"):
            line_bot_api.reply_message(
                    event.reply_token,
                    TextSendMessage(
                        text='ブレンドする量を選択してください',
                        quick_reply=QuickReply(
                            items=[
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1/2", text="spice_小さじ1/2")
                        ),
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ1", text="spice_小さじ1")
                        ),
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ2", text="spice_小さじ2")
                        ),
                                QuickReplyButton(
                                    action=MessageAction(label="小さじ4", text="spice_小さじ4")
                        ),
                    ])))
            


            
#チキンカレー_flex            
    if event.type == "message":
        if (event.message.text == "chicken_curry"):
            bubble = BubbleContainer(
                direction='ltr',
                hero=ImageComponent(
                    url='https://images.unsplash.com/photo-1585937421612-70a008356fbe?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60',
                    size='full',
                    aspect_ratio='20:13',
                    aspect_mode='cover',
                ),
                body=BoxComponent(
                    layout='vertical',
                    contents=[
                    # title
                        TextComponent(text='チキンカレー', weight='bold', size='xl'),
                    # info
                        BoxComponent(
                            layout='vertical',
                            margin='lg',
                            spacing='sm',
                            contents=[
                                BoxComponent(
                                    layout='baseline',
                                    spacing='sm',
                                    contents=[
                                        TextComponent(
                                            text='材料名',
                                            color='#aaaaaa',
                                            size='sm',
                                            flex=1
                                        ),
                                        TextComponent(
                                            text=' ①鶏モモ肉\n ②タマネギ\n ③シメジ\n ④水\n ⑤オリーブオイル\n ⑥バター',
                                            wrap=True,
                                            color='#666666',
                                            size='sm',
                                            flex=5
                                        )
                                    ],
                                ),
                                BoxComponent(
                                    layout='baseline',
                                    spacing='sm',
                                    contents=[
                                        TextComponent(
                                            text='spice',
                                            color='#aaaaaa',
                                            size='sm',
                                            flex=1
                                        ),
                                        TextComponent(
                                            text=" ⑦お好きな調味料\n (トマトソース)\n ⑧お好きなスパイス",
                                            wrap=True,
                                            color='#666666',
                                            size='sm',
                                            flex=5,
                                        ),
                                    ],
                                ),
                            ],
                        )
                    ],
                ),
                footer=BoxComponent(
                layout='vertical',
                spacing='sm',
                contents=[
                    SpacerComponent(size='sm'),
                    ButtonComponent(
                        style='primary',
                        height='sm',
                        action=MessageAction(label='次へ進む', text='chicken_curry_next'),
                    ),
                    SeparatorComponent(),
                    ButtonComponent(
                        style='secondary',
                        height='sm',
                        action=MessageAction(label='カレーを選びなおす', text="chicken_curry_cancel")
                    )
                ]
                ),
            )
            message = FlexSendMessage(alt_text="hello", contents=bubble)
            line_bot_api.reply_message(
                event.reply_token,
                message
            )

            
#チキンカレー_flex 

#グリーンカレー_flex            
    if event.type == "message":
        if (event.message.text == "green_curry"):
            bubble = BubbleContainer(
                direction='ltr',
                hero=ImageComponent(
                    url='https://images.unsplash.com/photo-1560684352-8497838a2229?ixlib=rb-1.2.1&auto=format&fit=crop&w=800&q=60',
                    size='full',
                    aspect_ratio='20:13',
                    aspect_mode='cover',
                ),
                body=BoxComponent(
                    layout='vertical',
                    contents=[
                    # title
                        TextComponent(text='グリーンカレー', weight='bold', size='xl'),
                    # info
                        BoxComponent(
                            layout='vertical',
                            margin='lg',
                            spacing='sm',
                            contents=[
                                BoxComponent(
                                    layout='baseline',
                                    spacing='sm',
                                    contents=[
                                        TextComponent(
                                            text='材料名',
                                            color='#aaaaaa',
                                            size='sm',
                                            flex=1
                                        ),
                                        TextComponent(
                                            text=' ①鶏モモ肉\n ②タマネギ\n ③ほうれん草\n ④ナス\n ⑤エリンギ\n ⑥豆乳\n ⑦オリーブオイル',
                                            wrap=True,
                                            color='#666666',
                                            size='sm',
                                            flex=5
                                        )
                                    ],
                                ),
                                BoxComponent(
                                    layout='baseline',
                                    spacing='sm',
                                    contents=[
                                        TextComponent(
                                            text='spice',
                                            color='#aaaaaa',
                                            size='sm',
                                            flex=1
                                        ),
                                        TextComponent(
                                            text=" ⑦お好きな調味料\n (グリーンペースト)\n ⑧お好きなスパイス",
                                            wrap=True,
                                            color='#666666',
                                            size='sm',
                                            flex=5,
                                        ),
                                    ],
                                ),
                            ],
                        )
                    ],
                ),
                footer=BoxComponent(
                layout='vertical',
                spacing='sm',
                contents=[
                    SpacerComponent(size='sm'),
                    ButtonComponent(
                        style='primary',
                        height='sm',
                        action=MessageAction(label='次へ進む', text='green_curry_next'),
                    ),
                    SeparatorComponent(),
                    ButtonComponent(
                        style='secondary',
                        height='sm',
                        action=MessageAction(label='カレーを選びなおす', text="green_curry_cancel")
                    )
                ]
                ),
            )
            message = FlexSendMessage(alt_text="hello", contents=bubble)
            line_bot_api.reply_message(
                event.reply_token,
                message
            )

            
#グリーンカレー_flex

#キーマカレー_flex            
    if event.type == "message":
        if (event.message.text == "keema_curry"):
            bubble = BubbleContainer(
                direction='ltr',
                hero=ImageComponent(
                    url='https://production-orp.s3.amazonaws.com/uploads/recipes/image/0000300319/20160801160506.jpg',
                    size='full',
                    aspect_ratio='20:13',
                    aspect_mode='cover',
                ),
                body=BoxComponent(
                    layout='vertical',
                    contents=[
                    # title
                        TextComponent(text='キーマカレー', weight='bold', size='xl'),
                    # info
                        BoxComponent(
                            layout='vertical',
                            margin='lg',
                            spacing='sm',
                            contents=[
                                BoxComponent(
                                    layout='baseline',
                                    spacing='sm',
                                    contents=[
                                        TextComponent(
                                            text='材料名',
                                            color='#aaaaaa',
                                            size='sm',
                                            flex=1
                                        ),
                                        TextComponent(
                                            text=' ①豚挽肉\n ②ピーマン\n ③赤ピーマン\n ④タマネギ\n ⑤ニンジン\n ⑥コーン\n ⑦水\n ⑧オリーブオイル',
                                            wrap=True,
                                            color='#666666',
                                            size='sm',
                                            flex=5
                                        )
                                    ],
                                ),
                                BoxComponent(
                                    layout='baseline',
                                    spacing='sm',
                                    contents=[
                                        TextComponent(
                                            text='spice',
                                            color='#aaaaaa',
                                            size='sm',
                                            flex=1
                                        ),
                                        TextComponent(
                                            text=" ⑦お好きな調味料\n (味噌ソース)\n ⑧お好きなスパイス",
                                            wrap=True,
                                            color='#666666',
                                            size='sm',
                                            flex=5,
                                        ),
                                    ],
                                ),
                            ],
                        )
                    ],
                ),
                footer=BoxComponent(
                layout='vertical',
                spacing='sm',
                contents=[
                    SpacerComponent(size='sm'),
                    ButtonComponent(
                        style='primary',
                        height='sm',
                        action=MessageAction(label='次へ進む', text='keema_curry_next'),
                    ),
                    SeparatorComponent(),
                    ButtonComponent(
                        style='secondary',
                        height='sm',
                        action=MessageAction(label='カレーを選びなおす', text="keema_curry_cancel")
                    )
                ]
                ),
            )
            message = FlexSendMessage(alt_text="hello", contents=bubble)
            line_bot_api.reply_message(
                event.reply_token,
                message
            )          
#キーマカレー_flex
            
            
    message_content = line_bot_api.get_message_content(event.message.id)
    with tempfile.NamedTemporaryFile(dir=static_tmp_path, prefix=ext + '-', delete=False) as tf:
        for chunk in message_content.iter_content():
            tf.write(chunk)
        tempfile_path = tf.name

    dist_path = tempfile_path + '.' + ext
    dist_name = os.path.basename(dist_path)
    os.rename(tempfile_path, dist_path)

    line_bot_api.reply_message(
        event.reply_token, [
            TextSendMessage(text='Save content.'),
            TextSendMessage(text=request.host_url + os.path.join('static', 'tmp', dist_name))
        ])
Exemplo n.º 18
0
#!/usr/bin/env python
# coding: utf-8

# In[ ]:

#小遊戲imagemap
from linebot.models import (ImagemapArea, BaseSize, URIImagemapAction,
                            MessageImagemapAction, ImagemapSendMessage)

game_imagemap_message = ImagemapSendMessage(
    base_url='https://is.gd/b6IhTz',
    alt_text='小遊戲',
    base_size=BaseSize(height=624, width=1040),
    actions=[
        URIImagemapAction(link_uri="https://play.famobi.com/surfer-archers",
                          area=ImagemapArea(x=4, y=4, width=341, height=312)),
        URIImagemapAction(
            link_uri="https://play.famobi.com/highway-rider-extreme",
            area=ImagemapArea(x=347, y=0, width=341, height=312)),
        URIImagemapAction(link_uri="https://play.famobi.com/high-hills",
                          area=ImagemapArea(x=699, y=0, width=341,
                                            height=312)),
        URIImagemapAction(link_uri="https://play.famobi.com/pizza-ninja-3",
                          area=ImagemapArea(x=5, y=312, width=341,
                                            height=312)),
        URIImagemapAction(
            link_uri="https://play.famobi.com/billiard-blitz-challenge",
            area=ImagemapArea(x=349, y=312, width=341, height=312)),
        URIImagemapAction(
            link_uri="https://play.famobi.com/angry-flappy-wings",
            area=ImagemapArea(x=692, y=312, width=341, height=312))
Exemplo n.º 19
0
    def text_message_user(self, reply_token, text_message, profile):
        if not 'NotTest' in text_message:
            message = TextSendMessage('(=OωO=)')
            self.reply(reply_token, message)
            return

        user_id = profile.user_id
        if user_id is None:
            user_id = self._get_provider_id()

        if user_id != self._get_provider_id():
            message = TextSendMessage('にゃー!\n(Permission denied)')
            self.reply(reply_token, message)
            return

        test_messages = [
            TemplateSendMessage(
                alt_text='Buttons template',
                template=ButtonsTemplate(
                    thumbnail_image_url='https://example.com/image.jpg',
                    title='Menu',
                    text='Please select',
                    actions=[
                        PostbackTemplateAction(label='postback',
                                               text='postback text',
                                               data='action=buy&itemid=1'),
                        MessageTemplateAction(label='message',
                                              text='message text'),
                        URITemplateAction(label='uri',
                                          uri='http://example.com/')
                    ])),
            TemplateSendMessage(
                alt_text='Confirm template',
                template=ConfirmTemplate(
                    text='Are you sure?',
                    actions=[
                        PostbackTemplateAction(label='postback',
                                               text='postback text',
                                               data='action=buy&itemid=1'),
                        MessageTemplateAction(label='message',
                                              text='message text')
                    ])),
            TemplateSendMessage(
                alt_text='Carousel template',
                template=CarouselTemplate(columns=[
                    CarouselColumn(
                        thumbnail_image_url='https://example.com/item1.jpg',
                        title='this is menu1',
                        text='description1',
                        actions=[
                            PostbackTemplateAction(label='postback1',
                                                   text='postback text1',
                                                   data='action=buy&itemid=1'),
                            MessageTemplateAction(label='message1',
                                                  text='message text1'),
                            URITemplateAction(label='uri1',
                                              uri='http://example.com/1')
                        ]),
                    CarouselColumn(
                        thumbnail_image_url='https://example.com/item2.jpg',
                        title='this is menu2',
                        text='description2',
                        actions=[
                            PostbackTemplateAction(label='postback2',
                                                   text='postback text2',
                                                   data='action=buy&itemid=2'),
                            MessageTemplateAction(label='message2',
                                                  text='message text2'),
                            URITemplateAction(label='uri2',
                                              uri='http://example.com/2')
                        ])
                ])),
            TemplateSendMessage(
                alt_text='ImageCarousel template',
                template=ImageCarouselTemplate(columns=[
                    ImageCarouselColumn(
                        image_url='https://example.com/item1.jpg',
                        action=PostbackTemplateAction(
                            label='postback1',
                            text='postback text1',
                            data='action=buy&itemid=1')),
                    ImageCarouselColumn(
                        image_url='https://example.com/item2.jpg',
                        action=PostbackTemplateAction(
                            label='postback2',
                            text='postback text2',
                            data='action=buy&itemid=2'))
                ])),
            ImagemapSendMessage(
                base_url='https://example.com/base',
                alt_text='this is an imagemap',
                base_size=BaseSize(height=1040, width=1040),
                actions=[
                    URIImagemapAction(link_uri='https://example.com/',
                                      area=ImagemapArea(x=0,
                                                        y=0,
                                                        width=520,
                                                        height=1040)),
                    MessageImagemapAction(text='hello',
                                          area=ImagemapArea(x=520,
                                                            y=0,
                                                            width=520,
                                                            height=1040))
                ])
        ]

        self.reply(reply_token, test_messages)
        return
Exemplo n.º 20
0
def sendE2Floor(event, line_bot_api):  # 圖片地圖
    try:
        message = [  # 串列
            TextSendMessage(  # 傳送文字
                text="請選擇檢查的樓層"),
            ImagemapSendMessage(
                base_url='https://i.imgur.com/jYnxzhV.png',
                alt_text="This is the E2 floor's imagemap",
                base_size=BaseSize(height=1040, width=1040),
                actions=[
                    MessageImagemapAction(text='E2-8F',
                                          area=ImagemapArea(x=0,
                                                            y=90,
                                                            width=1040,
                                                            height=99)),
                    MessageImagemapAction(text='E2-7F',
                                          area=ImagemapArea(x=0,
                                                            y=191,
                                                            width=1040,
                                                            height=79)),
                    MessageImagemapAction(text='E2-6F',
                                          area=ImagemapArea(x=0,
                                                            y=273,
                                                            width=1040,
                                                            height=81)),
                    MessageImagemapAction(text='E2-5F',
                                          area=ImagemapArea(x=0,
                                                            y=357,
                                                            width=1040,
                                                            height=77)),
                    MessageImagemapAction(text='E2-4F',
                                          area=ImagemapArea(x=0,
                                                            y=437,
                                                            width=1040,
                                                            height=81)),
                    MessageImagemapAction(text='E2-3F',
                                          area=ImagemapArea(x=0,
                                                            y=519,
                                                            width=1040,
                                                            height=83)),
                    MessageImagemapAction(text='E2-2F',
                                          area=ImagemapArea(x=0,
                                                            y=604,
                                                            width=1040,
                                                            height=151)),
                    MessageImagemapAction(text='E2-1F',
                                          area=ImagemapArea(x=0,
                                                            y=754,
                                                            width=1040,
                                                            height=206)),
                    MessageImagemapAction(text='E2-B1',
                                          area=ImagemapArea(x=0,
                                                            y=963,
                                                            width=1040,
                                                            height=74))
                ])
        ]
        line_bot_api.reply_message(event.reply_token, message)
    except:
        line_bot_api.reply_message(
            event.reply_token, TextSendMessage(text='發生錯誤!sendFloorImgMap'))
Exemplo n.º 21
0
    def send_ifLineResult_message(self, reply_token, venue, status, dist,
                                  noLine_venues):

        if venue == "臺中市不動產開發公會竹跡館" or venue == "楷模創生館":
            buttons_template = ButtonsTemplate(
                title='想看看' + dist + '的其他資訊嗎?',
                text='請點擊以下按鈕',
                actions=[
                    MessageAction(label='查詢其他展館資訊', text='查詢特定展館資訊'),
                    MessageAction(label='查詢不用排隊的展館', text='查詢不用排隊的展館')
                ])

        else:
            buttons_template = ButtonsTemplate(
                title='想看看' + dist + '的其他資訊嗎?',
                text='請點擊以下按鈕',
                actions=[
                    PostbackAction(label="現場人潮照片",
                                   data='guest-currentSituation_' + venue),
                    MessageAction(label='查詢其他展館資訊', text='查詢特定展館資訊'),
                    MessageAction(label='查詢不用排隊的展館', text='查詢不用排隊的展館')
                ])

        buttons_template_message = TemplateSendMessage(
            alt_text='想看看' + dist + '的其他資訊嗎?', template=buttons_template)

        if "不用排隊" in status:
            pic_url = quote(venue + "_0" + ".png")

            imagemap_message = ImagemapSendMessage(
                base_url="https://2018floraexpo.tk/static/sources/ifLine/" +
                pic_url + "#v1.0/1024",
                alt_text=venue + status,
                base_size=BaseSize(height=1024, width=1024),
                actions=[
                    MessageImagemapAction(text="目前不用排隊,\n可以快快去" + venue +
                                          "卡位喔^_^",
                                          area=ImagemapArea(x=0,
                                                            y=0,
                                                            width=1024,
                                                            height=1024))
                ])

            self.line_bot_api.reply_message(
                reply_token, [imagemap_message, buttons_template_message])

            return

        if "15" in status:
            pic_url = quote(venue + "_15" + ".png")

            imagemap_message = ImagemapSendMessage(
                base_url="https://2018floraexpo.tk/static/sources/ifLine/" +
                pic_url + "#v1.1/1024",
                alt_text=venue + status,
                base_size=BaseSize(height=1024, width=1024),
                actions=[
                    MessageImagemapAction(text="目前排隊時間很少,\n可以快快去" + venue +
                                          "卡位喔^_^",
                                          area=ImagemapArea(x=0,
                                                            y=0,
                                                            width=1024,
                                                            height=1024))
                ])

            self.line_bot_api.reply_message(
                reply_token, [imagemap_message, buttons_template_message])

            return

        if "30分鐘" in status or "45分鐘" in status:
            minute = status.split("分")[0].split("約莫")[1]
            pic_url = quote(venue + "_" + minute + ".png")

        elif "1小時" in status:
            pic_url = quote(venue + "_60" + ".png")

        imagemap_message = ImagemapSendMessage(
            base_url="https://2018floraexpo.tk/static/sources/ifLine/" +
            pic_url + "#v1.2/1024",
            alt_text=venue + status,
            base_size=BaseSize(height=1024, width=1024),
            actions=[
                MessageImagemapAction(text="我要申請排隊提醒_" + venue,
                                      area=ImagemapArea(x=0,
                                                        y=0,
                                                        width=1024,
                                                        height=1024))
            ])

        text_message = TextMessage(text=venue + "等待入館時間較久,歡迎您先前往" + dist +
                                   "內其他不用排隊的展館喔")

        carousel_template_message = self._generate_noLine_venues_message(
            noLine_venues=noLine_venues)

        self.line_bot_api.reply_message(
            reply_token, [imagemap_message, buttons_template_message])
Exemplo n.º 22
0
def art(reply_token):
    image_url1 = createUri('/static/pics/AI1.jpg')
    image_url2 = createUri('/static/pics/PI1.jpg')
    image_url3 = createUri('/static/pics/PI2.png')
    image_url4 = createUri('/static/pics/PS2.jpg')
    image_url5 = createUri('/static/pics/PS2-1.png')
    image_url6 = createUri('/static/pics/PS3.jpg')
    image_url7 = createUri('/static/pics/PS3-1.jpg')
    image_url8 = createUri('/static/pics/PS5.jpg')
    image_url9 = createUri('/static/pics/PS5-1.png')

    imagemap_message1 = ImagemapSendMessage(
        base_url=createUri('/static/pics/imagemap'),
        alt_text='繪畫作品',
        base_size=BaseSize(height=1040, width=1040),
        actions=[
            URIImagemapAction(link_uri=image_url1,
                              area=ImagemapArea(x=0,
                                                y=0,
                                                width=520,
                                                height=520)),
            URIImagemapAction(link_uri=image_url2,
                              area=ImagemapArea(x=520,
                                                y=0,
                                                width=520,
                                                height=520)),
            URIImagemapAction(link_uri=image_url3,
                              area=ImagemapArea(x=0,
                                                y=520,
                                                width=1040,
                                                height=520))
        ])

    imagemap_message2 = ImagemapSendMessage(
        base_url=createUri('/static/pics/imagemap2'),
        alt_text='修圖作品',
        base_size=BaseSize(height=1040, width=1040),
        actions=[
            URIImagemapAction(link_uri=image_url4,
                              area=ImagemapArea(x=0,
                                                y=0,
                                                width=475,
                                                height=325)),
            URIImagemapAction(link_uri=image_url5,
                              area=ImagemapArea(x=565,
                                                y=0,
                                                width=475,
                                                height=325)),
            URIImagemapAction(link_uri=image_url6,
                              area=ImagemapArea(x=0,
                                                y=325,
                                                width=475,
                                                height=325)),
            URIImagemapAction(link_uri=image_url7,
                              area=ImagemapArea(x=565,
                                                y=325,
                                                width=475,
                                                height=325)),
            URIImagemapAction(link_uri=image_url8,
                              area=ImagemapArea(x=0,
                                                y=650,
                                                width=475,
                                                height=390)),
            URIImagemapAction(link_uri=image_url9,
                              area=ImagemapArea(x=565,
                                                y=650,
                                                width=475,
                                                height=390))
        ])

    line_bot_api.reply_message(reply_token,
                               [imagemap_message1, imagemap_message2])
Exemplo n.º 23
0
from linebot.models import BaseSize
from linebot.models import ImagemapArea
from linebot.models import ImagemapSendMessage
from linebot.models import MessageImagemapAction
from linebot.models import URIImagemapAction

imagemaps = [{
    "id":
    "example",
    "payload":
    ImagemapSendMessage(base_url='https://example.com/base',
                        alt_text='this is an imagemap',
                        base_size=BaseSize(height=1040, width=1040),
                        actions=[
                            URIImagemapAction(link_uri='https://example.com/',
                                              area=ImagemapArea(x=0,
                                                                y=0,
                                                                width=520,
                                                                height=1040)),
                            MessageImagemapAction(text='hello',
                                                  area=ImagemapArea(
                                                      x=520,
                                                      y=0,
                                                      width=520,
                                                      height=1040))
                        ])
}, {
    "id":
    "pulsa",
    "payload":
    ImagemapSendMessage(
Exemplo n.º 24
0
def handle_message(event):
    print(event.message.text)

    #使用者要求寫入資料庫
    av_data = {
        '文字': [event.message.text],
        '時間': [time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())]
    }
    write = pandas.DataFrame(av_data)

    with lite.connect('av_data.sqlite') as db:
        write.to_sql('user_say', con=db, if_exists='append')
    #使用者要求寫入資料庫

    if event.message.text == '眾天使':

        with lite.connect('av_data.sqlite') as db:
            read = pandas.read_sql_query('select * from face_search', con=db)

        word = '\n'.join(list(set(read['名子'].tolist())))
        av_amount = str(len(list(set(read['名子'].tolist()))))

        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text='目前天使庫:' + av_amount + '位\n' + word))

    elif event.message.text == '許願':

        #隨機選擇一位老婆

        three_boss = list(range(1, 2 + 1))
        with lite.connect('av_data.sqlite') as db:
            read = pandas.read_sql_query('select * from face_search', con=db)
            select = list(set(read['名子'].tolist()))

            for item in three_boss:
                select += ['馬英九']
                select += ['蔡英文']
                select += ['柯p']

            rad = random.randint(0, len(select) - 1)
            sent_name = read[read['名子'] == select[rad]].iloc[0]['名子']
            sent_logo = read[read['名子'] == select[rad]].iloc[0]['logo']
            if sent_logo == '':
                sent_logo = 'https://i.imgur.com/JrohLrx.jpg'

            if sent_name == '馬英九' or sent_name == '蔡英文' or sent_name == '柯p':
                set_label = '你好 我是三幻神之一'
                set_title = '墮天使'
                set_text = '神抽'
            elif sent_name == '紗倉真菜' or sent_name == '三上悠亞' or sent_name == '高橋聖子':
                set_label = '你好 我是三大神之一'
                set_title = '主天使'
                set_text = '神抽'

            elif sent_name == '光頭葛格':
                set_label = '你好 我是最大雷'
                set_title = '露西法'
                set_text = '降臨'
            else:
                set_label = '你好 我是'
                set_title = '天使'
                set_text = '降臨'

            sent_Column = CarouselColumn(
                thumbnail_image_url=sent_logo,
                title=set_title,
                text=set_text,
                actions=[
                    PostbackTemplateAction(label=set_label,
                                           text=' ',
                                           data='action=buy&itemid=1'),
                    MessageTemplateAction(label=sent_name, text=' '),
                    URITemplateAction(
                        label='按這搜尋去~',
                        uri='https://www.google.com.tw/search?q=' + sent_name)
                ])

        #隨機選擇一位老婆

        carousel_template_message = TemplateSendMessage(
            alt_text='Carousel template',
            template=CarouselTemplate(columns=[sent_Column]))
        line_bot_api.reply_message(event.reply_token,
                                   carousel_template_message)

    elif event.message.text == '使用說明':
        print(event.message.text)

        #使用者要求寫入資料庫
        av_data = {
            '文字': [event.message.text],
            '時間': [time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())]
        }
        write = pandas.DataFrame(av_data)

        with lite.connect('av_data.sqlite') as db:
            write.to_sql('user_say', con=db, if_exists='append')
        #使用者要求寫入資料庫
        sent_word = '你好!請對我們傳送圖片~\n\n我們來幫你找你的天使w\n\n對了 你可以拍照截圖做到以下幾點 天使會更容易找到:\n1.正面臉\n2.清晰照\n3.不截到其他人頭\n\n另外 你可以\n輸入"許願":來找尋天使'
        sent_word = TextSendMessage(text=sent_word)

        imagemap_message_bad = ImagemapSendMessage(
            base_url='https://i.imgur.com/AFbIhlz.jpg',
            alt_text='this is an imagemap',
            base_size=BaseSize(height=1040, width=1040),
            actions=[])
        imagemap_message_good = ImagemapSendMessage(
            base_url='https://i.imgur.com/NQ869qM.jpg',
            alt_text='this is an imagemap',
            base_size=BaseSize(height=1040, width=1040),
            actions=[])
        line_bot_api.reply_message(
            event.reply_token,
            [imagemap_message_bad, imagemap_message_good, sent_word])

    else:
        None
Exemplo n.º 25
0
def handle_location(event):
    global near_station_name
    global near_station_address
    global near_station_geo_lat
    global near_station_geo_lon

    lat = event.message.latitude
    lon = event.message.longitude

    zoomlevel = 18
    imagesize = 1040

    # SimpleAPIから最寄駅リストを取得
    near_station_url = 'http://map.simpleapi.net/stationapi?x={}&y={}&output=xml'.format(
        lon, lat)
    near_station_req = urllib.request.Request(near_station_url)
    with urllib.request.urlopen(near_station_req) as response:
        near_station_XmlData = response.read()
    near_station_root = ET.fromstring(near_station_XmlData)
    near_station_list = near_station_root.findall(".//name")
    near_station_n = len(near_station_list)

    # 最寄駅名から座標を取得
    near_station_geo_url = 'https://maps.googleapis.com/maps/api/place/textsearch/xml?query={}&key={}'.format(
        urllib.parse.quote_plus(near_station_list[0].text, encoding='utf-8'),
        google_places_api_key)
    near_station_geo_req = urllib.request.Request(near_station_geo_url)
    with urllib.request.urlopen(near_station_geo_req) as response:
        near_station_geo_XmlData = response.read()
    near_station_geo_root = ET.fromstring(near_station_geo_XmlData)

    #最寄駅情報(名前、住所、緯度経度)を取得
    near_station_name = near_station_geo_root.findtext(".//name")
    near_station_address = near_station_geo_root.findtext(
        ".//formatted_address")
    near_station_geo_lat = near_station_geo_root.findtext(".//lat")
    near_station_geo_lon = near_station_geo_root.findtext(".//lng")

    #徒歩時間を取得
    near_station_direction_url = 'https://maps.googleapis.com/maps/api/directions/xml?origin={},{}&destination={},{}&mode=walking&key={}'.format(
        lat, lon, near_station_geo_lat, near_station_geo_lon,
        google_directions_api_key)
    near_station_direction_req = urllib.request.Request(
        near_station_direction_url)
    with urllib.request.urlopen(near_station_direction_req) as response:
        near_station_direction_XmlData = response.read()
    near_station_direction_root = ET.fromstring(near_station_direction_XmlData)
    near_station_direction_time_second = int(
        near_station_direction_root.findtext(".//leg/duration/value"))
    near_station_direction_distance_meter = int(
        near_station_direction_root.findtext(".//leg/distance/value"))
    near_station_direction_time_min = near_station_direction_time_second // 60
    near_station_direction_distance_kilo = near_station_direction_distance_meter // 1000 + (
        (near_station_direction_distance_meter // 100) % 10) * 0.1

    map_image_url = 'https://maps.googleapis.com/maps/api/staticmap?size=520x520&scale=2&maptype=roadmap&key={}'.format(
        google_staticmaps_api_key)
    map_image_url += '&markers=color:{}|label:{}|{},{}'.format(
        'red', '', near_station_geo_lat, near_station_geo_lon)
    map_image_url += '&markers=color:{}|label:{}|{},{}'.format(
        'blue', '', lat, lon)

    actions = [
        MessageImagemapAction(text="位置情報教えて!",
                              area=ImagemapArea(x=0,
                                                y=0,
                                                width=1040,
                                                height=1040))
    ]

    line_bot_api.reply_message(event.reply_token, [
        ImagemapSendMessage(
            base_url='https://{}/imagemap/{}'.format(
                request.host, urllib.parse.quote_plus(map_image_url)),
            alt_text='地図',
            base_size=BaseSize(height=imagesize, width=imagesize),
            actions=actions,
        ),
        TextSendMessage(text=near_station_list[0].text + 'が最寄り駅です。'),
        TextSendMessage(text='歩いて約' + str(near_station_direction_time_min) +
                        '分。距離は約' + str(near_station_direction_distance_kilo) +
                        'kmです。'),
        TextSendMessage(text='画像をタップすると駅の位置情報を表示できます。'),
    ])
Exemplo n.º 26
0
def send_E2_4F_East_classroom(event, line_bot_api):  # 圖片地圖
    try:
        imagemap_message = ImagemapSendMessage(
            base_url='https://i.imgur.com/AUIICvS.png',
            alt_text="This is the E2 4F East classroom's imagemap",
            base_size=BaseSize(height=1040, width=1040),
            actions=[
                MessageImagemapAction(text='E2-412教學電腦室',
                                      area=ImagemapArea(x=78,
                                                        y=798,
                                                        width=377,
                                                        height=207)),
                MessageImagemapAction(text='E2-413研究室',
                                      area=ImagemapArea(x=78,
                                                        y=714,
                                                        width=377,
                                                        height=78)),
                MessageImagemapAction(text='E2-414研究室',
                                      area=ImagemapArea(x=78,
                                                        y=630,
                                                        width=377,
                                                        height=77)),
                MessageImagemapAction(text='E2-415研究室',
                                      area=ImagemapArea(x=78,
                                                        y=543,
                                                        width=377,
                                                        height=78)),
                MessageImagemapAction(text='E2-416研究室',
                                      area=ImagemapArea(x=78,
                                                        y=455,
                                                        width=377,
                                                        height=83)),
                MessageImagemapAction(text='E2-417研究室',
                                      area=ImagemapArea(x=78,
                                                        y=373,
                                                        width=377,
                                                        height=77)),
                MessageImagemapAction(text='E2-418研究室',
                                      area=ImagemapArea(x=78,
                                                        y=288,
                                                        width=377,
                                                        height=77)),
                MessageImagemapAction(text='E2-419研究室',
                                      area=ImagemapArea(x=78,
                                                        y=201,
                                                        width=377,
                                                        height=79)),
                MessageImagemapAction(text='E2-420儲藏室',
                                      area=ImagemapArea(x=316,
                                                        y=30,
                                                        width=137,
                                                        height=165)),
                MessageImagemapAction(text='女廁',
                                      area=ImagemapArea(x=186,
                                                        y=32,
                                                        width=119,
                                                        height=163)),
                MessageImagemapAction(text='男廁',
                                      area=ImagemapArea(x=78,
                                                        y=32,
                                                        width=98,
                                                        height=164)),
                MessageImagemapAction(text='E2-406網路控制室',
                                      area=ImagemapArea(x=705,
                                                        y=201,
                                                        width=215,
                                                        height=251)),
                MessageImagemapAction(text='E2-407教授研究室',
                                      area=ImagemapArea(x=705,
                                                        y=457,
                                                        width=215,
                                                        height=79)),
                MessageImagemapAction(text='E2-408教授研究室',
                                      area=ImagemapArea(x=705,
                                                        y=543,
                                                        width=215,
                                                        height=79)),
                MessageImagemapAction(text='E2-409教授研究室',
                                      area=ImagemapArea(x=705,
                                                        y=630,
                                                        width=215,
                                                        height=78)),
                MessageImagemapAction(text='E2-410教授研究室',
                                      area=ImagemapArea(x=705,
                                                        y=714,
                                                        width=215,
                                                        height=78)),
                MessageImagemapAction(text='E2-411教授研究室',
                                      area=ImagemapArea(x=705,
                                                        y=799,
                                                        width=215,
                                                        height=78)),
                MessageImagemapAction(text='E2-4F東側樓梯間',
                                      area=ImagemapArea(x=705,
                                                        y=884,
                                                        width=213,
                                                        height=121))
            ])
        line_bot_api.reply_message(event.reply_token, imagemap_message)
    except:
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text='發生錯誤!send_E2_4F_East_classroom'))
Exemplo n.º 27
0
def handle_location(event):
    user_id = event.source.user_id
    pins = []
    address = []

    lat = event.message.latitude
    lon = event.message.longitude

    zoomlevel = 18
    imagesize = 1040

    key = os.environ['GOOGLE_API_KEY']
    types = 'convenience_store'
    query = 'トイレ'
    place_map_url_convenience = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?&language=ja&radius=50&location={},{}&types={}&key={}'.format(
        lat, lon, types, key)
    placeJson_convenience = requests.get(place_map_url_convenience)
    placeData_convenience = json.loads(placeJson_convenience.text)

    place_map_url_toilet = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?&language=ja&radius=50&location={},{}&query={}&key={}'.format(
        lat, lon, query, key)
    placeJson_toilet = requests.get(place_map_url_toilet)
    placeData_toilet = json.loads(placeJson_toilet.text)

    for store in placeData_convenience["results"][:6]:
        pins.append([
            store["geometry"]["location"]["lat"],
            store["geometry"]["location"]["lng"]
        ])
        address.append(store["name"], store["vicinity"])
    for toilet in placeData_toilet["results"][:6]:
        pins.append([
            toilet["geometry"]["location"]["lat"],
            toilet["geometry"]["location"]["lng"]
        ])
        address.append([toilet["name"], toilet["vicinity"]])
    print(pins)
    print(address)
    conn = psycopg2.connect("dbname=" + dbname + " host=" + host + " user="******" password="******"CREATE TABLE users (id serial PRIMARY KEY, user_id text, pins real[], address text[]);")
    #cur.execute("INSERT INTO users (user_id, pins, address) VALUES (%s, %s, %s)", (user_id, pins, address))
    cur.execute("UPDATE users SET pins=%s, address=%s WHERE user_id=%s",
                (pins, address, user_id))
    cur.execute("SELECT * FROM users;")
    row = cur.fetchone()
    print(row)
    conn.commit()
    cur.close()
    conn.close()

    map_image_url = 'https://maps.googleapis.com/maps/api/staticmap?center={},{}&zoom={}&size=520x520&scale=2&maptype=roadmap&key={}'.format(
        lat, lon, zoomlevel, key)
    map_image_url += '&markers=color:{}|label:{}|{},{}'.format(
        'red', '', lat, lon)

    center_lat_pixel, center_lon_pixel = latlon_to_pixel(lat, lon)

    marker_color = 'blue'
    pin_width = 60 * 1.5
    pin_height = 84 * 1.5

    actions = []
    for i, pin in enumerate(pins):

        target_lat_pixel, target_lon_pixel = latlon_to_pixel(pin[0], pin[1])

        # (4)
        delta_lat_pixel = (target_lat_pixel -
                           center_lat_pixel) >> (21 - zoomlevel - 1)
        delta_lon_pixel = (target_lon_pixel -
                           center_lon_pixel) >> (21 - zoomlevel - 1)

        marker_lat_pixel = imagesize / 2 + delta_lat_pixel
        marker_lon_pixel = imagesize / 2 + delta_lon_pixel

        x = marker_lat_pixel
        y = marker_lon_pixel

        label = str(i)

        if (pin_width / 2 < x < imagesize - pin_width / 2
                and pin_height < y < imagesize - pin_width):

            map_image_url += '&markers=color:{}|label:{}|{},{}'.format(
                marker_color, label, pin[0], pin[1])

            actions.append(
                MessageImagemapAction(text=str(i),
                                      area=ImagemapArea(x=x - pin_width / 2,
                                                        y=y - pin_height / 2,
                                                        width=pin_width,
                                                        height=pin_height)))
            if len(actions) > 10:
                break

    line_bot_api.reply_message(event.reply_token, [
        ImagemapSendMessage(base_url='https://{}/imagemap/{}'.format(
            request.host, urllib.parse.quote_plus(map_image_url)),
                            alt_text='地図',
                            base_size=BaseSize(height=imagesize,
                                               width=imagesize),
                            actions=actions),
        TextSendMessage(
            text='ピンをタップするかピンの番号を入力すると詳細が送られるよ!{}'.format(chr(0x100029)))
    ])
Exemplo n.º 28
0
def handle_location(event):
    lat = event.message.latitude
    lon = event.message.longitude

    zoomlevel = 18
    imagesize = 1040
    # 縦横1040ピクセルの画像を取得
    map_image_url = 'https://maps.googleapis.com/maps/api/staticmap?center={},{}&zoom={}&size=520x520&scale=2&maptype=roadmap&key={}'.format(
        lat, lon, zoomlevel, 'AIzaSyAtbs1MG9dES1JhT1gRDmx-QQtyhYpr2_g')
    map_image_url += '&markers=color:{}|label:{}|{},{}'.format(
        'blue', '', lat, lon)

    # タップ可能なピンを配置する

    center_lat_pixel, center_lon_pixel = latlon_to_pixel(lat, lon)

    marker_color = 'red'
    label = 'E'

    # タップエリアのサイズ
    pin_width = 60 * 1.5
    pin_height = 84 * 1.5

    actions = []
    for i, pin in enumerate(pins):

        # 中心の緯度経度をピクセルに変換
        target_lat_pixel, target_lon_pixel = latlon_to_pixel(pin[0], pin[1])

        # 差分を計算
        delta_lat_pixel = (target_lat_pixel -
                           center_lat_pixel) >> (21 - zoomlevel - 1)
        delta_lon_pixel = (target_lon_pixel -
                           center_lon_pixel) >> (21 - zoomlevel - 1)

        marker_lat_pixel = imagesize / 2 + delta_lat_pixel
        marker_lon_pixel = imagesize / 2 + delta_lon_pixel

        x = marker_lat_pixel
        y = marker_lon_pixel

        # 範囲外のを除外
        if (pin_width / 2 < x < imagesize - pin_width / 2
                and pin_height < y < imagesize - pin_width):

            map_image_url += '&markers=color:{}|label:{}|{},{}'.format(
                marker_color, label, pin[0], pin[1])

            actions.append(
                MessageImagemapAction(text=str(i),
                                      area=ImagemapArea(x=x - pin_width / 2,
                                                        y=y - pin_height / 2,
                                                        width=pin_width,
                                                        height=pin_height)))
            if len(actions) > 10:
                break

    # Imagemap Message
    message = ImagemapSendMessage(base_url='https://{}/imagemap/{}'.format(
        request.host, urllib.parse.quote_plus(map_image_url)),
                                  alt_text='地図',
                                  base_size=BaseSize(height=imagesize,
                                                     width=imagesize),
                                  actions=actions)
    line_bot_api.reply_message(
        event.reply_token, [TextSendMessage(text='終電まで空いている出口一覧です􀁇'), message])
Exemplo n.º 29
0
            "label": "條件?��?",
            "text": "[::text:]條件?��?",
            "data": "資�? 2"
          }
        ]
    )
)

from linebot.models import (
    ImagemapArea, BaseSize, URIImagemapAction, MessageImagemapAction,ImagemapSendMessage
)

camp_search_imagemap_message = ImagemapSendMessage(
    base_url='https://is.gd/VKXD9X',
    alt_text='?��?類�?',
    base_size=BaseSize(height=1473,width=1040)
     ,actions=[
        MessageImagemapAction(
            text="[::text:]親�??��?",
            area=ImagemapArea(x=7,y=271,width=513,height=128)
        ),
         MessageImagemapAction(
            text="[::text:]?��??��?",
            area=ImagemapArea(x=5,y=404,width=513,height=132)
        ),
         MessageImagemapAction(
            text="[::text:]觀賞�???,
            area=ImagemapArea(x=4,y=540,width=513,height=132)
        )
        
    ]
Exemplo n.º 30
0
def message_imagemap(base_url, alt_text, lists_actions):
    return ImagemapSendMessage(base_url=base_url,
                               alt_text=alt_text,
                               base_size=BaseSize(height=1040, width=1040),
                               actions=lists_actions)