Пример #1
0
def Pose(event):  #圖片轉盤
    print("### module.sendCarousel.Pose")
    try:
        message = TemplateSendMessage(
            alt_text='圖片轉盤樣板',
            template=ImageCarouselTemplate(columns=[
                ImageCarouselColumn(
                    image_url=
                    'https://mmbiz.qpic.cn/mmbiz_gif/BIatWXEC82a8OZkXr3tYwIpzNJulySPHZuZftKf5B7w3wcGrjerpicMI5BSCPXGsPwmE6qzpgFfr1jGkxkoqpPA/640?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1',
                    action=URITemplateAction(
                        label='深蹲20下', uri='line://app/1653356616-5Jkb6kLV')),
                ImageCarouselColumn(
                    image_url=
                    'https://s3-ap-southeast-1.amazonaws.com/img.khoobsurati.com/wp-content/uploads/2015/05/img-Push-Ups-2018-07.gif',
                    action=URITemplateAction(
                        label='伏地挺身20下',
                        uri='line://app/1653356616-5Jkb6kLV')),
                ImageCarouselColumn(
                    image_url=
                    'https://cdn.shopify.com/s/files/1/1501/0558/files/SitUp.gif?v=1514735483',
                    action=URITemplateAction(
                        label='仰臥起坐20下',
                        uri='line://app/1653356616-5Jkb6kLV')),
                ImageCarouselColumn(
                    image_url=
                    'https://us.123rf.com/450wm/logo3in1/logo3in11510/logo3in1151000001/46716051-woman-making-perfect-body-with-the-plank-exercis.jpg?ver=6',
                    action=URITemplateAction(
                        label='棒棒式40秒', uri='line://app/1653356616-5Jkb6kLV'))
            ]))

        #return HttpResponse()
        line_bot_api.reply_message(event.reply_token, message)
    except:
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text='發生錯誤!'))
def handle_text_message(event):
    text = event.message.text

    if str(text).lower() == 'movies':
        image_carousel_template = ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url=
                'https://m.media-amazon.com/images/M/MV5BMDU2ZWJlMjktMTRhMy00ZTA5LWEzNDgtYmNmZTEwZTViZWJkXkEyXkFqcGdeQXVyNDQ2OTk4MzI@._V1_UY1200_CR87,0,630,1200_AL_.jpg',
                action=PostbackAction(label='Select', data='Toy Story')),
            ImageCarouselColumn(
                image_url=
                'https://m.media-amazon.com/images/M/MV5BM2MyNjYxNmUtYTAwNi00MTYxLWJmNWYtYzZlODY3ZTk3OTFlXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UY1200_CR107,0,630,1200_AL_.jpg',
                action=PostbackAction(label='Select', data='The Godfather')),
            ImageCarouselColumn(
                image_url=
                'https://m.media-amazon.com/images/M/MV5BMTY4ODM0OTc2M15BMl5BanBnXkFtZTcwNzE0MTk3OA@@._V1_.jpg',
                action=PostbackAction(label='Select', data='Die Hard')),
        ])
        template_message = TemplateSendMessage(
            alt_text='ImageCarousel alt text',
            template=image_carousel_template)
        line_bot_api.reply_message(event.reply_token, template_message)
    else:
        text = event.message.text
        movie_recommend = get_recommendations(text)
        print(movie_recommend)
        line_bot_api.reply_message(event.reply_token,
                                   [TextSendMessage(text=movie_recommend)])
Пример #3
0
def handle_postback(event):
    print("postbackEvent", event)

    if event.postback.data:

        person_id = event.postback.data

        r = redis.from_url(settings.REDIS_URL)
        rcache = r.get(person_id)

        if not rcache:
            return

        data = json.loads(rcache.decode())
        name = data.get('name')
        image_urls = data.get('images')

        if not len(image_urls):
            return

        columns = [
            ImageCarouselColumn(image_url=image_url,
                                action=URIAction(
                                    label='画像出典元',
                                    uri=image_url,
                                )) for image_url in image_urls[:10]
        ]

        messages = TemplateSendMessage(
            alt_text='%sの画像一覧' % (name),
            template=ImageCarouselTemplate(columns=columns),
        )

        reply_message(event, messages)
Пример #4
0
    def send_currentSituation_picture_message(self, reply_token, pictures):

        template_message = self._generate_anotherQuestion_confirmTemplate()

        if len(pictures) == 0:
            text_message = TextMessage(text='目前還沒更新照片,你可以看看其他館喔:)')
            self.line_bot_api.reply_message(
                reply_token, messages=[text_message, template_message])
            return

        imageCarouselColumns = []

        for picture in pictures:

            imageCarouselColumn = ImageCarouselColumn(
                image_url="https://2018floraexpo.tk/" + picture["path"],
                action=URIAction(uri="https://2018floraexpo.tk/" +
                                 picture["path"]))

            imageCarouselColumns.append(imageCarouselColumn)

        image_carousel_template_message = TemplateSendMessage(
            alt_text='照片如下',
            template=ImageCarouselTemplate(columns=imageCarouselColumns))

        text_message = TextMessage(text='以上是展館的前三張照片,希望可以幫助到您:)')

        self.line_bot_api.reply_message(reply_token,
                                        messages=[
                                            image_carousel_template_message,
                                            text_message, template_message
                                        ])
Пример #5
0
def send_image_carousel(all_infor, id, watch_type):

    line_bot_api = LineBotApi(channel_access_token)
    cols = []
    for infor in all_infor:
        data = ""

        if (watch_type == "Movie"):
            data = "detail,"+infor.name+","+infor.date+"," + \
                infor.outline+","+infor.link+","+str(infor.idx)
            # print(data)
        elif (watch_type == "TV"):
            data = "detail," + infor.name + "," + infor.outline + "," + infor.star + "," + infor.link
        else:
            data = "detail@ "+infor.name+"@" + infor.outline+"@" + infor.popularity + \
                "@" + infor.author+"@"+infor.link
            # print(data)

        cols.append(
            ImageCarouselColumn(image_url=infor.image,
                                action=PostbackTemplateAction(
                                    label=infor.name[:10],
                                    data=data,
                                    text="detail")))

    message = TemplateSendMessage(alt_text='ImageCarousel template',
                                  template=ImageCarouselTemplate(columns=cols))
    line_bot_api.push_message(id, message)
    return "OK"
Пример #6
0
def send_central_divition_team(reply_token):
    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url='https://i.imgur.com/Vq9uSfw.png',
                action=PostbackTemplateAction(
                    label='公鹿', text='bucks', data='action=buy&itemid=1')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/49Py8da.png',
                action=PostbackTemplateAction(
                    label='溜馬', text='pacers', data='action=buy&itemid=2')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/ccm79f8.png',
                action=PostbackTemplateAction(
                    label='活塞', text='pistons', data='action=buy&itemid=3')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/jgM2e8T.png',
                action=PostbackTemplateAction(
                    label='公牛', text='bulls', data='action=buy&itemid=4')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/9j4vObi.png',
                action=PostbackTemplateAction(
                    label='騎士', text='caveliers', data='action=buy&itemid=5'))
        ]))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #7
0
def send_southwest_divition_team(reply_token):
    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(image_url='https://i.imgur.com/KfhWlHX.png',
                                action=PostbackTemplateAction(
                                    label='獨行俠',
                                    text='mavericks',
                                    data='action=buy&itemid=1')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/MwZ7gOG.png',
                action=PostbackTemplateAction(
                    label='灰熊', text='grizzles', data='action=buy&itemid=2')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/rSfD5It.png',
                action=PostbackTemplateAction(
                    label='鵜鶘', text='pelicans', data='action=buy&itemid=3')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/VakO1Td.png',
                action=PostbackTemplateAction(
                    label='火箭', text='rockets', data='action=buy&itemid=4')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/76CbfhM.png',
                action=PostbackTemplateAction(
                    label='馬刺', text='spurs', data='action=buy&itemid=5'))
        ]))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #8
0
def send_atalantic_divition_team(reply_token):
    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url='https://i.imgur.com/hQV1mql.png',
                action=PostbackTemplateAction(
                    label='暴龍', text='raptors', data='action=buy&itemid=1')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/MNlnQcA.png',
                action=PostbackTemplateAction(
                    label='賽爾提克', text='celtics', data='action=buy&itemid=2')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/DPFhrrX.png',
                action=PostbackTemplateAction(
                    label='76人', text='76ers', data='action=buy&itemid=3')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/vo4yWWw.png',
                action=PostbackTemplateAction(
                    label='籃網', text='nets', data='action=buy&itemid=4')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/RMKhZxx.png',
                action=PostbackTemplateAction(
                    label='尼克', text='knics', data='action=buy&itemid=5'))
        ]))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #9
0
def handle_beacon(event):
    Menu_url = "http://149.28.153.220:1880/ui/#/0" # Menu Web Url
    image_carousel_template = ImageCarouselTemplate(columns=[
        ImageCarouselColumn(image_url='https://scontent.fbkk6-1.fna.fbcdn.net/v/t1.0-9/39454660_1001737283342645_6691743344214671360_n.jpg?_nc_cat=100&_nc_ht=scontent.fbkk6-1.fna&oh=8155c7522c7b274d7afcf65d5d07dfc2&oe=5CA6BAA1',
                            action=URIAction(uri=Menu_url,
                                             label='500 Baht')),
        ImageCarouselColumn(image_url='https://scontent.fbkk6-2.fna.fbcdn.net/v/t1.0-9/39442752_1001738930009147_2170020964899749888_n.jpg?_nc_cat=103&_nc_ht=scontent.fbkk6-2.fna&oh=ec390fe97902d919704e68cc36534165&oe=5CAFD3A8',
                            action=URIAction(uri=Menu_url,
                                             label='80 Baht')),
        ImageCarouselColumn(image_url='https://scontent.fbkk6-1.fna.fbcdn.net/v/t1.0-9/39221449_1001737313342642_6907313284718788608_n.jpg?_nc_cat=108&_nc_ht=scontent.fbkk6-1.fna&oh=63d6884a0af21043195873c19de8a1fc&oe=5CA5B7BB',
                            action=URIAction(uri=Menu_url,
                                             label='200 Baht'))
    ])
    template_message = TemplateSendMessage(
        alt_text="Thank you.", template=image_carousel_template)
    line_bot_api.reply_message(event.reply_token, template_message)
    line_bot_api.reply_message(
        event.reply_token,
        TextSendMessage(
            text='Got beacon event. hwid={}, device_message(hex string)={}'.format(
                event.beacon.hwid, event.beacon.dm)))
    line_bot_api.reply_message(
                event.reply_token, [
                    TextSendMessage(text="Hi")
                ]
            )
Пример #10
0
def send_pacific_divition_team(reply_token):
    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url='https://i.imgur.com/NjIZPvy.png',
                action=PostbackTemplateAction(
                    label='快艇', text='clippers', data='action=buy&itemid=1')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/hLTYqcQ.png',
                action=PostbackTemplateAction(
                    label='國王', text='kings', data='action=buy&itemid=2')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/2zTrz4Z.png',
                action=PostbackTemplateAction(
                    label='湖人', text='lakers', data='action=buy&itemid=3')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/6FdkdEf.png',
                action=PostbackTemplateAction(
                    label='太陽', text='suns', data='action=buy&itemid=4')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/YRwCVJl.png',
                action=PostbackTemplateAction(
                    label='勇士', text='warriors', data='action=buy&itemid=5'))
        ]))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #11
0
 def on_enter_female2(self, event):
     # index = 0
     # s = ""
     # while index < 16:
     #     s += str(female_uese[index]) + " "
     #     index += 1
     # reply_token = event.reply_token
     # send_text_message(reply_token,s)
     num1 = random.randint(0, 15)
     num2 = random.randint(0, 15)
     while female_uese[num1] != 2:
         num1 = random.randint(0, 15)
     while num1 == num2 or female_uese[num2] == -1:
         num2 = random.randint(0, 15)
     female_uese[num1] = -1
     female_uese[num2] = -1
     s1 = female_twitcher_name[num1]
     s2 = female_twitcher_name[num2]
     u1 = female_url[num1]
     u2 = female_url[num2]
     line_bot_api.reply_message(event.reply_token, [
         TextSendMessage(text="===========       1/4       ==========="),
         TemplateSendMessage(
             alt_text='ImageCarousel template',
             template=ImageCarouselTemplate(columns=[
                 ImageCarouselColumn(
                     image_url=u1,
                     action=PostbackTemplateAction(
                         label=s1, text=s1, data='action=buy&itemid=1')),
                 ImageCarouselColumn(
                     image_url=u2,
                     action=PostbackTemplateAction(
                         label=s2, text=s2, data='action=buy&itemid=2'))
             ]))
     ])
Пример #12
0
def send_carousel_message(reply_token, col):
    line_bot_api = LineBotApi(channel_access_token)
    message = TemplateSendMessage(alt_text='Carousel template',
                                  template=ImageCarouselTemplate(columns=col))
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #13
0
def handle_message(event):
    text = event.message.text

    r = redis.from_url(settings.REDIS_URL)
    rcache = r.get(text)

    if not rcache:
        messages = [
            TextSendMessage(text='画像か名前を送ってみてね!'),
        ]
        reply_message(event, messages)
        return

    image_urls = json.loads(rcache.decode())

    if not len(image_urls):
        return

    columns = [
        ImageCarouselColumn(image_url=image_url,
                            action=URIAction(
                                label='画像出典元',
                                uri=image_url,
                            )) for image_url in image_urls[:10]
    ]

    messages = TemplateSendMessage(
        alt_text='%sの画像一覧' % (text),
        template=ImageCarouselTemplate(columns=columns),
    )

    reply_message(event, messages)
Пример #14
0
def sendImgCarousel(event):  #圖片轉盤
    try:
        message = TemplateSendMessage(
            alt_text='圖片轉盤樣板',
            template=ImageCarouselTemplate(
                columns=[
                    ImageCarouselColumn(
                        image_url='https://i.imgur.com/4QfKuz1.png',
                        action=MessageTemplateAction(
                            label='文字訊息',
                            text='賣披薩'
                        )
                    ),
                    ImageCarouselColumn(
                        image_url='https://i.imgur.com/qaAdBkR.png',
                        action=PostbackTemplateAction(
                            label='回傳訊息',
                            data='action=sell&item=飲料'
                        )
                    )
                ]
            )
        )
        line_bot_api.reply_message(event.reply_token,message)
    except:
        line_bot_api.reply_message(event.reply_token,TextSendMessage(text='發生錯誤!'))
Пример #15
0
def sendImgCarousel(event):  #圖片轉盤
    try:
        message = TemplateSendMessage(
            alt_text='了解特色景點更多',
            template=ImageCarouselTemplate(
                columns=[
                    ImageCarouselColumn(
                        image_url='https://raw.githubusercontent.com/sabucchen/pic/main/%E5%A4%A7%E7%A8%BB%E5%9F%95%E7%A2%BC%E9%A0%AD.jpg',
                        action=MessageTemplateAction(
                            label='大稻埕碼頭',
                            text='大稻埕碼頭'
                        )
                    ),
                    ImageCarouselColumn(
                        image_url='https://raw.githubusercontent.com/sabucchen/pic/main/%E5%A4%A7%E7%A8%BB%E5%9F%95%E6%88%B2%E9%99%A2.jpg',
                        action=MessageTemplateAction(
                            label='大稻埕戲院',
                            text='大稻埕戲院'
                        )
                    )
                ]
            )
        )
        line_bot_api.reply_message(event.reply_token,message)
    except:
        line_bot_api.reply_message(event.reply_token,TextSendMessage(text='發生錯誤!'))
Пример #16
0
def send_northwest_divition_team(reply_token):
    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url='https://i.imgur.com/Za8Kg4H.png',
                action=PostbackTemplateAction(
                    label='爵士', text='jazz', data='action=buy&itemid=1')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/2lUGdbv.png',
                action=PostbackTemplateAction(
                    label='金塊', text='nuggets', data='action=buy&itemid=2')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/2ie9dVz.png',
                action=PostbackTemplateAction(
                    label='雷霆', text='thunders', data='action=buy&itemid=3')),
            ImageCarouselColumn(image_url='https://i.imgur.com/ZZrjJed.png',
                                action=PostbackTemplateAction(
                                    label='灰狼',
                                    text='timberwolves',
                                    data='action=buy&itemid=4')),
            ImageCarouselColumn(image_url='https://i.imgur.com/2rokfHw.png',
                                action=PostbackTemplateAction(
                                    label='拓荒者',
                                    text='trail blazers',
                                    data='action=buy&itemid=5'))
        ]))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #17
0
 def on_enter_male(self, event):
     global male_used
     num1 = random.randint(0, 15)
     num2 = random.randint(0, 15)
     while num1 == num2:
         num2 = random.randint(0, 15)
     male_used[num1] = -1
     male_used[num2] = -1
     s1 = male_twicher_name[num1]
     s2 = male_twicher_name[num2]
     u1 = male_url[num1]
     u2 = male_url[num2]
     line_bot_api.reply_message(event.reply_token, [
         TextSendMessage(text="===========       1/8       ==========="),
         TemplateSendMessage(
             alt_text='ImageCarousel template',
             template=ImageCarouselTemplate(columns=[
                 ImageCarouselColumn(
                     image_url=u1,
                     action=PostbackTemplateAction(
                         label=s1, text=s1, data='action=buy&itemid=1')),
                 ImageCarouselColumn(
                     image_url=u2,
                     action=PostbackTemplateAction(
                         label=s2, text=s2, data='action=buy&itemid=2'))
             ]))
     ])
Пример #18
0
 def show_final_result(self, event, t4):
     ind = 0
     u = ""
     name = ""
     while ind < 16:
         if male_twicher_name[ind] == t4:
             u = male_url[ind]
             break
         elif female_twitcher_name[ind] == t4:
             u = female_url[ind]
             break
         else:
             ind += 1
     sss = " 感謝您,使用此功能,您最後的選擇是\n    =======        " + t4 + "        =======\n       再點擊一次照片會有返回的提示       "
     line_bot_api.reply_message(event.reply_token, [
         TextSendMessage(text=sss),
         TemplateSendMessage(
             alt_text='ImageCarousel template',
             template=ImageCarouselTemplate(columns=[
                 ImageCarouselColumn(
                     image_url=u,
                     action=PostbackTemplateAction(
                         label=t4, text=t4, data='action=buy&itemid=1'))
             ]))
     ])
     reply_token = event.reply_token
     send_text_message(reply_token, sss)
Пример #19
0
def send_southeast_divition_team(reply_token):
    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url='https://i.imgur.com/JlSkgo1.png',
                action=PostbackTemplateAction(
                    label='熱火', text='heats', data='action=buy&itemid=1')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/ofJ4VgI.png',
                action=PostbackTemplateAction(
                    label='魔術', text='magic', data='action=buy&itemid=2')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/qerCfYv.png',
                action=PostbackTemplateAction(
                    label='黃蜂', text='hornets', data='action=buy&itemid=3')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/BE37OBk.png',
                action=PostbackTemplateAction(
                    label='巫師', text='wizards', data='action=buy&itemid=4')),
            ImageCarouselColumn(
                image_url='https://i.imgur.com/QxmRbDF.png',
                action=PostbackTemplateAction(
                    label='老鷹', text='hawks', data='action=buy&itemid=5'))
        ]))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)

    return "OK"
Пример #20
0
def sendCarouselImg2(event):
	#try:
		message = TemplateSendMessage(
			alt_text='各式花禮作品',
			template=ImageCarouselTemplate(
				columns=[
					ImageCarouselColumn(
						image_url='https://i.imgur.com/i8M7sme.jpg',
						action=URITemplateAction(
								label='提籃花',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
					ImageCarouselColumn(
						image_url='https://imgur.com/DJ1Buef.jpg',
						action=URITemplateAction(
								label='花束',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
					ImageCarouselColumn(
						image_url='https://imgur.com/wGCAsMH.jpg',
						action=URITemplateAction(
								label='永生花',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
					ImageCarouselColumn(
						image_url='https://imgur.com/FQaXKug.jpg',
						action=URITemplateAction(
								label='蘭花',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
					ImageCarouselColumn(
						image_url='https://imgur.com/ag3ubZN.jpg',
						action=URITemplateAction(
								label='提籃花',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
					ImageCarouselColumn(
						image_url='https://imgur.com/5Yro8Ym.jpg',
						action=URITemplateAction(
								label='盆花',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
					ImageCarouselColumn(
						image_url='https://i.imgur.com/PquESwg.jpg',
						action=URITemplateAction(
								label='提籃花',
								uri='https://www.facebook.com/%E7%B4%AB%E7%9B%92%E5%AD%90%E8%8A%B1%E7%A6%AE%E8%A8%AD%E8%A8%88-193614007383467/'
						)
					),
				]
			)
		)
		line_bot_api.reply_message(event.reply_token,message)
Пример #21
0
def send_image_carousel(id, imglinks, labels, texts):
    line_bot_api = LineBotApi(access_token)
    cols = []
    for i, url in enumerate(imglinks):
        cols.append(
            ImageCarouselColumn(image_url=url,
                                action=MessageTemplateAction(label=labels[i],
                                                             text=texts[i])))
    message = TemplateSendMessage(alt_text='ImageCarousel template',
                                  template=ImageCarouselTemplate(columns=cols))
    line_bot_api.push_message(id, message)
    return "OK"
Пример #22
0
def handle_postback(event):
    if event.postback.data == 'Intro-DS':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.ds))
    elif event.postback.data == 'Intro-MDA':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.mda))
    elif event.postback.data == 'Intro-WeatherMood':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.wm))
    elif event.postback.data == 'Intro-Doodle':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.dj))
    elif event.postback.data == 'Triats-Resp':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.traits_resp))
    elif event.postback.data == 'Triats-Open':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.traits_open))
    elif event.postback.data == 'More-Info':
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text='選擇想了解的項目',
                            quick_reply=quick_reply_tepmplate))
    elif event.postback.data == 'Music':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text="Chvrches-Forever"))
        image_carousel_template = ImageCarouselTemplate(columns=[
            ImageCarouselColumn(
                image_url='https://i.imgur.com/7w0cpRn.jpg',
                action=URIAction(
                    label='Listen!',
                    uri='https://www.youtube.com/watch?v=CRDruiv08_4')),
        ])
        template_message = TemplateSendMessage(
            alt_text='Image-music', template=image_carousel_template)
        line_bot_api.push_message(event.source.user_id, template_message)

        time.sleep(1)

        line_bot_api.push_message(
            event.source.user_id,
            TextSendMessage(text="A song that get you out of depression."))
    elif event.postback.data == 'Location':
        line_bot_api.reply_message(
            event.reply_token,
            LocationSendMessage(title='清華大學 梅園',
                                address='新竹市東區光復路二段101號',
                                latitude=24.7928700,
                                longitude=120.9908193))
    elif event.postback.data == 'Poke':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text=Intro.poke))
Пример #23
0
def image_carousel_view(image_list):
    columns_list = []
    for image, label in image_list:
        columns_list.append(
            ImageCarouselColumn(image_url=image,
                                action=URITemplateAction(label=label,
                                                         uri=image)))

    view = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=columns_list))
    return view
Пример #24
0
def send_carousel_image_message(reply_token, message_image, message_text):
    columns = []
    for index in range(len(message_image)):
        columns.append(
            ImageCarouselColumn(image_url=message_image[index],
                                action=URITemplateAction(
                                    label=message_text[index],
                                    uri=message_image[index])))
    message = TemplateSendMessage(
        alt_text="漫畫內文", template=ImageCarouselTemplate(columns=columns))
    line_bot_api = LineBotApi(channel_access_token)
    line_bot_api.reply_message(reply_token, message)
    return "OK"
Пример #25
0
def image_carousel_generater(image_action_list):
    image_action_list = np.array(image_action_list)
    action_list = [
        PostbackAction(label=action, data=action, text=action)
        for action in image_action_list[:, 0]
    ]
    image_url_list = image_action_list[:, 1]
    columns = [
        ImageCarouselColumn(action, image_url)
        for image_url, action in zip(action_list, image_url_list)
    ]
    image_carousel_template = ImageCarouselTemplate(columns=columns)
    return image_carousel_template
Пример #26
0
def get_pic_message(title, href, img, imghref, showinTilte):
    ImgList = []
    for i in range(len(img)):
        item = ImageCarouselColumn(image_url=img[i],
                                   action=URIAction(
                                       uri=imghref[i],
                                       label='Image News' + str(i + 1),
                                   ))
        ImgList.append(item)

    message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(columns=ImgList))
    return message
Пример #27
0
def getBeauty(page, keyword):
    if page:
        url = 'https://www.ptt.cc/bbs/Beauty/index%d.html' % page
    else:
        url = 'https://www.ptt.cc/bbs/Beauty/index.html'

    response = requests.get(url, headers={'Cookie': 'over18=1;'}).text
    soup = BeautifulSoup(response, 'html.parser')

    try:
        previousPage = soup.find_all('a', class_='btn wide')[1].get('href')
    except:
        return '前面沒東西了!! Σ(*゚д゚ノ)ノ'

    nowPage = int(previousPage.lstrip('/bbs/Beauty/index').rstrip('.html')) + 1

    titleWithUrl = soup.select('div .title')

    result = ''
    statusUrl = 0
    for row in titleWithUrl:
        if row.find('a') is not None and ('正妹' in row.find('a').text
                                          or '帥哥' in row.find('a').text):
            title = row.find('a').text
            articleUrl = 'https://www.ptt.cc' + row.find('a').get('href')

            if keyword in title:
                statusUrl = articleUrl

            result += title + '\n' + articleUrl + '\n'

    # 更新頁面結果及頁數
    updateCrawlerBeauty(nowPage, result)

    if statusUrl:
        articleResponse = requests.get(statusUrl,
                                       headers={
                                           'Cookie': 'over18=1;'
                                       }).text
        articleSoup = BeautifulSoup(articleResponse, 'html.parser')
        images = articleSoup.select('a[rel="nofollow"]')
        columns = imageCarouselColumn(images)

        imageCarousel = TemplateSendMessage(
            alt_text='目錄 template',
            template=ImageCarouselTemplate(columns=columns))

        return imageCarousel

    return str(page) + '/' + str(nowPage) + result
Пример #28
0
def more_blackman_questions_photo() -> TemplateSendMessage:
    return TemplateSendMessage(
        alt_text='blackman_pic_url',
        template=ImageCarouselTemplate(columns=[
            ImageCarouselColumn(image_url=blackman_pic_url,
                                action=PostbackTemplateAction(
                                    label='postback1',
                                    text='postback text1',
                                    data='action=buy&itemid=1')),
            ImageCarouselColumn(image_url=blackman_pic_url,
                                action=PostbackTemplateAction(
                                    label='postback2',
                                    text='postback text2',
                                    data='action=buy&itemid=2'))
        ]))
Пример #29
0
def get_hot_movie_list(user_name):
    col = []
    for movie_id in hot_movie_list:
        col.append(
            ImageCarouselColumn(image_url=movie_dict[movie_id][1],
                                action=PostbackTemplateAction(
                                    label='Learn More',
                                    data='movie=%s&action=5&' % (movie_id))))
    imagecarousel = ImageCarouselTemplate(type='image_carousel', columns=col)
    message = TemplateSendMessage(type='template',
                                  alt_text='Hot Movie List',
                                  template=imagecarousel)
    return [
        TextSendMessage(text='哈囉 %s! 這是本週熱門電影喔!可以參考看看~' % (user_name)), message
    ]
Пример #30
0
def imgur_bot_template(self):
    carousel_template_message = TemplateSendMessage(
        alt_text='ImageCarousel template',
        template=ImageCarouselTemplate(
            columns=[
                ImageCarouselColumn(
                    image_url='https://i.imgur.com/g8zAYMq.jpg',
                    action=URIAction(
                        label='加我好友試玩',
                        uri='https://line.me/R/ti/p/%40gmy1077x'
                    ),
                ),
            ]
        )
    )
    self.reply_message(carousel_template_message)