Esempio n. 1
0
 def make_messsage(self, text):
     if "オッケー藍染" == text or "オッケーあいぜん" == text:
         carousel_template_message = TemplateSendMessage(
             alt_text='Carousel template',
             template=CarouselTemplate(columns=[
                 CarouselColumn(
                     thumbnail_image_url=
                     'https://shota-imazeki.herokuapp.com/static/あつもり_魚.jpg',
                     title='あつもり魚検索機能',
                     text='北 or 南半球、対象月を選択することでその時期に取れる魚の種類と値段が分かります。',
                     actions=[
                         URITemplateAction(
                             label='ダッシュボードへ',
                             uri=
                             'https://public.tableau.com/profile/.43986973#!/vizhome/bugs/fish_1?publish=yes'
                         )
                     ]),
                 CarouselColumn(
                     thumbnail_image_url=
                     'https://shota-imazeki.herokuapp.com/static/あつもり_虫.jpg',
                     title='あつもり昆虫検索機能',
                     text='北 or 南半球、対象月を選択することでその時期に取れる虫の種類と値段が分かります。',
                     actions=[
                         URITemplateAction(
                             label='ダッシュボードへ',
                             uri=
                             'https://public.tableau.com/profile/.43986973#!/vizhome/bugs/bugs_1?publish=yes'
                         )
                     ])
             ]))
         return carousel_template_message, True
     else:
         return None, False
Esempio n. 2
0
def handout():

    handout_carouse = CarouselTemplate(columns=[
        CarouselColumn(thumbnail_image_url=handout_icon1,
                       title='課程講義 page 1',
                       text='請選擇您要的講義',
                       actions=[
                           URITemplateAction(label='網頁概論', uri=html_url),
                           URITemplateAction(label='Python 基礎',
                                             uri=python_basic_url),
                           URITemplateAction(label='Linux', uri=linux_url),
                       ]),
        CarouselColumn(thumbnail_image_url=handout_icon2,
                       title='課程講義 page 2',
                       text=' ',
                       actions=[
                           URITemplateAction(label='PyETL', uri=pyetl_url),
                           URITemplateAction(label='PyAI', uri=pyai_url),
                           URITemplateAction(label='Data Mining(含R語言)',
                                             uri=data_mining_url),
                       ]),
        CarouselColumn(thumbnail_image_url=handout_icon3,
                       title='課程講義 page 3',
                       text=' ',
                       actions=[
                           URITemplateAction(label='NoSQL', uri=nosql_url),
                           URITemplateAction(label='Text Mining + NLU',
                                             uri=text_mining_nlu_url),
                           URITemplateAction(label='Kafka', uri=kafka_url),
                       ])
    ])

    return handout_carouse
Esempio n. 3
0
def corousel():
    carousel_template_message = TemplateSendMessage(
        alt_text='Carousel template',
        template=CarouselTemplate(columns=[
            CarouselColumn(
                thumbnail_image_url='https://example.com/item1.jpg',
                title='this is menu1',
                text='description1',
                actions=[
                    PostbackAction(label='postback1',
                                   display_text='postback text1',
                                   data='action=buy&itemid=1'),
                    MessageAction(label='message1', text='message text1'),
                    URIAction(label='uri1', uri='http://example.com/1')
                ]),
            CarouselColumn(
                thumbnail_image_url='https://example.com/item2.jpg',
                title='this is menu2',
                text='description2',
                actions=[
                    PostbackAction(label='postback2',
                                   display_text='postback text2',
                                   data='action=buy&itemid=2'),
                    MessageAction(label='message2', text='message text2'),
                    URIAction(label='uri2', uri='http://example.com/2')
                ])
        ]))
Esempio n. 4
0
def reply_template_carousel(reply_token, text, alt_text, id):
    line_bot_api = LineBotApi(setting.ACCESS_TOKEN)
    line_bot_api.reply_message(reply_token, [
        TemplateSendMessage(
            alt_text=alt_text,
            template=CarouselTemplate([
                CarouselColumn(text='星5',
                               actions=[
                                   PostbackTemplateAction(label='星5',
                                                          data='5 ' + str(id))
                               ]),
                CarouselColumn(text='星4',
                               actions=[
                                   PostbackTemplateAction(label='星4',
                                                          data='4 ' + str(id))
                               ]),
                CarouselColumn(text='星3',
                               actions=[
                                   PostbackTemplateAction(label='星3',
                                                          data='3 ' + str(id))
                               ]),
                CarouselColumn(text='星2',
                               actions=[
                                   PostbackTemplateAction(label='星2',
                                                          data='2 ' + str(id))
                               ]),
                CarouselColumn(text='星1',
                               actions=[
                                   PostbackTemplateAction(label='星1',
                                                          data='1 ' + str(id))
                               ]),
            ]))
    ])
 def __init__(self):
     self.content = TemplateSendMessage(
         # 如果顯示不出模版時的替代文字
         alt_text='Carousel template',
         # Carousel是卡片,有上限,三或四張,超過無法顯示
         template=CarouselTemplate(columns=[
             # CarouselColumn(),
             # CarouselColumn(),
             CarouselColumn(
                 thumbnail_image_url=
                 'https://picsum.photos/1200/600?image=684',
                 title='匯率選單',
                 text='點選你要查詢的貨幣',
                 actions=[
                     # action也有上限,最多三個
                     MessageAction(label='查詢美金', text='美金'),
                     MessageAction(label='查詢日圓', text='日圓'),
                     MessageAction(label='查詢歐元', text='歐元'),
                     # URIAction(
                     #     label='Google',
                     #     uri='https://google.com'
                     # )
                 ]),
             CarouselColumn(thumbnail_image_url=
                            'https://picsum.photos/1200/600?image=701',
                            title='匯率選單',
                            text='點選你要查詢的貨幣',
                            actions=[
                                MessageAction(label='查詢港幣', text='港幣'),
                                MessageAction(label='查詢英鎊', text='英鎊'),
                                MessageAction(label='查詢人民幣', text='人民幣')
                            ])
         ]))
Esempio n. 6
0
def getCarouselColumn(name, minkabu, ipokiso):
    urlCols = [
        CarouselColumn(
            thumbnail_image_url=
            'https://assets.minkabu.jp/images/icon/home-icon.png',
            title='みんかぶ',
            text='「みんかぶ」に載っている' + name + 'の情報です。',
            actions=[URITemplateAction(
                uri=minkabu,
                label='みんかぶをみる',
            )]),
        CarouselColumn(
            thumbnail_image_url=
            'https://www.ipokiso.com/common/images/apple-touch-icon-precomposed.png',
            title='やさしいIPO株のはじめ方',
            text='「やさしいIPO株のはじめ方」に載っている' + name + 'の情報です。',
            actions=[
                URITemplateAction(
                    uri=ipokiso,
                    label='やさしいIPO株のはじめ方をみる',
                )
            ]),
    ]

    return urlCols
Esempio n. 7
0
 def test_carousel_template(self):
     arg = {
         'image_aspect_ratio': 'rectangle',
         'image_size': 'cover',
         'columns': [
             CarouselColumn(
                 thumbnail_image_url='https://example.com/bot/images/item1.jpg',
                 image_background_color='#FFFFFF',
                 title='this is menu',
                 text='description',
                 default_action=URIAction(label='View detail',
                                          uri='http://example.com/page/123'),
                 actions=[
                     PostbackAction(label='Buy', data='action=buy&itemid=155'),
                     URIAction(label='View detail', uri='http://example.com/page/155'),
                 ]
             ),
             CarouselColumn(
                 thumbnail_image_url='https://example.com/bot/images/item2.jpg',
                 image_background_color='#000000',
                 title='this is menu',
                 text='description',
                 default_action=URIAction(label='View detail',
                                          uri='http://example.com/page/222'),
                 actions=[
                     PostbackAction(label='Buy', data='action=buy&itemid=555'),
                     URIAction(label='View detail', uri='http://example.com/page/555'),
                 ]
             )
         ]
     }
     self.assertEqual(
         self.serialize_as_dict(arg, type=self.CAROUSEL),
         CarouselTemplate(**arg).as_json_dict()
     )
Esempio n. 8
0
 def show(self):
     return TemplateSendMessage(
         alt_text="account help button message",
         template=CarouselTemplate(columns=[
             CarouselColumn(
                 title=self.title,
                 text=self.text,
                 actions=[
                     MessageTemplateAction(label='line帳號綁定學號',
                                           text='account/register'),
                     MessageTemplateAction(label='帳號喜好',
                                           text='account/hobby'),
                     MessageTemplateAction(label='帳號喜好設定',
                                           text='account/hobby/time')
                 ]),
             CarouselColumn(
                 title=self.title,
                 text=self.text,
                 actions=[
                     MessageTemplateAction(label='喜好快速查詢',
                                           text='account/hobby/search'),
                     MessageTemplateAction(label='喜好快速預約',
                                           text='account/hobby/booking'),
                     MessageTemplateAction(label='帳號預約紀錄',
                                           text='account/booking')
                 ]),
         ]))
    def __getCarouselColumns(self):
        carouselColumns = []

        if (self.__isMember == 1):
            outFrameCarouselColum = CarouselColumn(
                thumbnail_image_url=self.__outFrame['imageUrl'],
                title='離去影像',
                text='時間:{}'.format(
                    datetime.fromtimestamp(
                        int(self.__outFrame['timestamp'] + 28800))),
                actions=[PostbackAction(label=' ', data='doNothing')])
            carouselColumns.append(outFrameCarouselColum)

            if (self.__inFrame != None):
                inFrameCarouselColum = CarouselColumn(
                    thumbnail_image_url=self.__inFrame['imageUrl'],
                    title='進入影像',
                    text='時間:{}'.format(
                        datetime.fromtimestamp(
                            int(self.__inFrame['timestamp'] + 28800))),
                    actions=[PostbackAction(label=' ', data='doNothing')])
                carouselColumns.append(inFrameCarouselColum)

        else:
            liveFrameCarouselColum = CarouselColumn(
                thumbnail_image_url=self.__inFrame['imageUrl'],
                title='現場影像',
                text='時間:{}'.format(
                    datetime.fromtimestamp(
                        int(self.__inFrame['timestamp'] + 28800))),
                actions=[PostbackAction(label=' ', data='doNothing')])

            carouselColumns.append(liveFrameCarouselColum)

        return carouselColumns
Esempio n. 10
0
def push_test():

    carousel_template = CarouselTemplate(columns=[
        CarouselColumn(
            text='忘れずに服用できていますか?',
            title='服薬状況',
            actions=[
                #                    URIAction(label='Go to line.me', uri='https://line.me'),
                PostbackAction(label='はい', data='はい', text='はい'),
                PostbackAction(label='いいえ', data='いいえ', text='いいえ')
            ]),
        CarouselColumn(
            text='副作用と疑われる症状は出ていませんか?',
            title='副作用について',
            actions=[
                PostbackAction(
                    label='はい、出ていません', data='はい、出ていません', text='はい、出ていません'),
                PostbackAction(
                    label='いいえ、出ています', data='いいえ、出ています', text='いいえ、出ています')
            ]),
    ])
    template_message = TemplateSendMessage(alt_text='Confirm alt text',
                                           template=carousel_template)
    line_bot_api.broadcast(
        TemplateSendMessage(alt_text='服薬状況の確認', template=carousel_template))
    return "have sent"
Esempio n. 11
0
def sendCarousel(event):  #轉盤樣板
    try:
        message = TemplateSendMessage(
            alt_text='轉盤樣板',
            template=CarouselTemplate(columns=[
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/4QfKuz1.png',
                    title='這是樣板一',
                    text='第一個轉盤樣板',
                    actions=[
                        MessageTemplateAction(label='文字訊息一', text='賣披薩'),
                        URITemplateAction(label='連結文淵閣網頁',
                                          uri='http://www.e-happy.com.tw'),
                        PostbackTemplateAction(label='回傳訊息一',
                                               data='action=sell&item=披薩'),
                    ]),
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/qaAdBkR.png',
                    title='這是樣板二',
                    text='第二個轉盤樣板',
                    actions=[
                        MessageTemplateAction(label='文字訊息二', text='賣飲料'),
                        URITemplateAction(label='連結台大網頁',
                                          uri='http://www.ntu.edu.tw'),
                        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='發生錯誤!'))
Esempio n. 12
0
def createCarouselMessage2():
    carousel_template = CarouselTemplate(columns=[
        CarouselColumn(
            text='予定1に関するメッセージです.',
            title='予定1',
            thumbnail_image_url=
            'https://dnavi.drwallet.jp/wp-content/uploads/2015/10/401428927e7866f2a637820429da114d.jpg',
            actions=[
                PostbackTemplateAction(
                    label='postback1', text='postback text1', data='text1'),
                MessageTemplateAction(label='message1', text='message text1'),
                URITemplateAction(label='Go to Google',
                                  uri='http://www.google.co.jp')
            ]),
        CarouselColumn(
            text='予定2に関するメッセージです.',
            title='予定2',
            thumbnail_image_url=
            'https://c.o16.co/1/gift/image/sc1-3145-300-2.jpg',
            actions=[
                PostbackTemplateAction(
                    label='postback2', text='postback text2', data='text2'),
                MessageTemplateAction(label='message2', text='message text2'),
                URITemplateAction(label='Go to Yahoo',
                                  uri='http://www.yahoo.co.jp')
            ])
    ])
    template_message = TemplateSendMessage(alt_text='これはテストカルーセルです.',
                                           template=carousel_template)
    return template_message
Esempio n. 13
0
def createCarouselMessage():
    carousel_template = CarouselTemplate(columns=[
        CarouselColumn(
            text='予定1',
            title='予定1に関するメッセージです',
            #thumbnail_image_url = 'https://c.o16.co/1/gift/image/sc1-3145-300-2.jpg',
            actions=[
                PostbackTemplateAction(
                    label='postback1', text='postback text1', data='text1'),
                MessageTemplateAction(label='message1', text='message text1'),
                URITemplateAction(label='Go to Google',
                                  uri='http://www.google.co.jp')
            ]),
        CarouselColumn(
            text='予定2',
            title='予定2に関するメッセージです',
            #thumbnail_image_url = 'https://c.o16.co/1/gift/image/sc1-3145-300-2.jpg',
            actions=[
                PostbackTemplateAction(
                    label='postback2', text='postback text2', data='text2'),
                MessageTemplateAction(label='message2', text='message text2'),
                URITemplateAction(label='Go to Yahoo',
                                  uri='http://www.yahoo.co.jp')
            ])
    ])
    template_message = TemplateSendMessage(alt_text='これはテストカルーセルです.',
                                           template=carousel_template)
    return template_message
Esempio n. 14
0
def sendCarousel4(event):  #轉盤樣板
    try:
        message = TemplateSendMessage(
            alt_text='linebot',
            template=CarouselTemplate(columns=[
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/QFyEi4h.jpg',
                    title='LINE Chatbot將會是下一個世代的App',
                    text='與App相比之下,Chatbot不占手機儲存空間,以投資成本來說,也很適合中小企業主投入。',
                    actions=[
                        URITemplateAction(
                            label='科技防疫機器人媒體報導',
                            uri='https://liff.line.me/1654140247-0LZB6qkj'),
                        URITemplateAction(
                            label='聊天機器人成功案例',
                            uri='https://liff.line.me/1654140247-QO7r5X2e'),
                        URITemplateAction(
                            label='聊天機器人媒體報導',
                            uri='https://liff.line.me/1654140247-9BQeydjX')
                    ]),
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/AdQIFR7.png',
                    title='聊天機器人再進化!不只搞定客服,更在互動時勾住消費者的心!',
                    text=
                    'LINE在台灣擁有2100萬用戶,對台灣的企業主而言,有90%的使用者不需要額外下載新的App,就可以與其溝通互動。',
                    actions=[
                        URITemplateAction(label='免費體驗多國語言翻譯機器人',
                                          uri='https://lin.ee/4FAdjAYoC'),
                        URITemplateAction(label='免費使用統一發票兌獎機器人',
                                          uri='https://lin.ee/3CKJGe75V'),
                        URITemplateAction(label='公司網站',
                                          uri='https://www.chatbizz.biz')
                    ]),
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/QFyEi4h.jpg',
                    title='各行各業的聊天機器人陸續開發中',
                    text='開發中:\n團購訂單推播機器人\n建商仲介買房族查詢房地產資訊機器人\n早餐店/攤商 外帶專用機器人',
                    actions=[
                        MessageTemplateAction(
                            label='公司介紹',
                            text=
                            '*瑋士科技由跨領域的團隊組成,一同打造不同功能的聊天機器人,致力將機器人建模模組化,協助企業積極掌握顧客足跡的數據,幫助企業快速與陌生人展開深度談話並建立信任關係。聊天機器人與微軟的人工智慧引擎結合透過語意分析及深度學習技術,對話式廣告模式協助廣告主與顧客互動。我們的團隊成員多元活潑、激勵創新、樂於挑戰為公司文化。'
                        ),
                        MessageTemplateAction(
                            label='本公司機器人功能說明',
                            text=
                            '*我們可以在您的手機通訊軟體 LINE Messenger上面新增加附有:24H自動接收預約, 訂房, 訂位, 外帶的功能。24H自動回覆客服, 客戶訂單紀錄, 訊息廣告推播, 紀錄客戶資料足跡的功能。24H自動查詢股價, 天氣, 交通.........等功能的小網站。24H讓機器人代替您在 LINE Messenger上面做生意, 回覆客戶問題, 完全不漏接任何一筆訂單。最重要的是:您甚麼都不用做, 就可以直接在您的手機上使用, 我們會把所有的事都做好做滿。'
                        ),
                        MessageTemplateAction(
                            label='留言/e-mail/TEL',
                            text=
                            '*留言:請輸入您的留言!\n*Email:[email protected]\n*TEL:0936587188'
                        )
                    ])
            ]))
        line_bot_api.reply_message(event.reply_token, message)
    except:
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text='發生錯誤!'))
Esempio n. 15
0
def make_carousel_column(title, text, actions, thumbnail_image_url):
    if thumbnail_image_url:
        return CarouselColumn(title=title,
                              text=text,
                              actions=actions,
                              thumbnail_image_url=thumbnail_image_url)
    else:
        return CarouselColumn(title=title, text=text, actions=actions)
Esempio n. 16
0
def handle_message(event):

        if event.message.text == 'รูป':
            image_message = ImageSendMessage(
                original_content_url='https://imagemovie.herokuapp.com/pic1.jpg',
                preview_image_url='https://imagemovie.herokuapp.com/pic1.jpg'
            )
            line_bot_api.push_message('U7183997e3e85a10d8c5f1f3925825016', image_message)

        if event.message.text=='ปุ่ม':
            message = TemplateSendMessage(
                alt_text='Carousel template',
                template=CarouselTemplate(
                    columns=[
                        CarouselColumn(
                            thumbnail_image_url='https://imagemovie.herokuapp.com/tt3501632.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://mandm.plearnjai.com/'
                                )
                            ]
                        ),
                        CarouselColumn(
                            thumbnail_image_url='https://imagemovie.herokuapp.com/tt3501632.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://mandm.plearnjai.com/'
                                )
                            ]
                        )
                    ]
                )
            )
            line_bot_api.reply_message(event.reply_token, message)
Esempio n. 17
0
def power_carousel_template_message(start="2017-01-01", end="2017-12-31"):
    power_data = []
    for politician_name in power_politician_dict:
        power_data.append(db(politician_name, start, end)[0])
    power_carousel_template_message = TemplateSendMessage(
        alt_text='Carousel template',
        template=CarouselTemplate(columns=[
            CarouselColumn(thumbnail_image_url=Webhook_URL +
                           '/static/images/{}'.format(power_data[0][5]),
                           title='{}'.format(power_data[0][0]),
                           text='想了解更多資訊\n請點擊『更多』 ',
                           actions=[
                               PostbackTemplateAction(label='臉書粉絲回應',
                                                      data="{} 則回應數".format(
                                                          power_data[0][1])),
                               PostbackTemplateAction(
                                   label='情緒正負向',
                                   data="正向:{}% \n中立:{}% \n負向:{}%".format(
                                       power_data[0][2], power_data[0][3],
                                       power_data[0][4])),
                               URITemplateAction(label='更多',
                                                 uri=Ourweb + power_data[0][5])
                           ]),
            CarouselColumn(thumbnail_image_url=Webhook_URL +
                           '/static/images/{}'.format(power_data[1][5]),
                           title='{}'.format(power_data[1][0]),
                           text='想了解更多資訊\n請點擊『更多』 ',
                           actions=[
                               PostbackTemplateAction(label='臉書粉絲回應',
                                                      data="{} 則回應數".format(
                                                          power_data[1][1])),
                               PostbackTemplateAction(
                                   label='情緒正負向',
                                   data="正向:{}% \n中立:{}% \n負向:{}%".format(
                                       power_data[1][2], power_data[1][3],
                                       power_data[1][4])),
                               URITemplateAction(label='更多',
                                                 uri=Ourweb + power_data[1][5])
                           ]),
            CarouselColumn(thumbnail_image_url=Webhook_URL +
                           '/static/images/{}'.format(power_data[2][5]),
                           title='{}'.format(power_data[2][0]),
                           text='想了解更多資訊\n請點擊『更多』 ',
                           actions=[
                               PostbackTemplateAction(label='臉書粉絲回應',
                                                      data="{} 則回應數".format(
                                                          power_data[2][1])),
                               PostbackTemplateAction(
                                   label='情緒正負向',
                                   data="正向:{}% \n中立:{}% \n負向:{}%".format(
                                       power_data[2][2], power_data[2][3],
                                       power_data[2][4])),
                               URITemplateAction(label='更多',
                                                 uri=Ourweb + power_data[2][5])
                           ]),
        ]))
    return power_carousel_template_message
    def __getCarouselColumns(self):
        if (self.__isMember == 1):
            if (self.__inFrame == None):
                outFrameCarouselColum = CarouselColumn(
                                            thumbnail_image_url=self.__outFrame['imageUrl'],
                                            title='離去影像',
                                            text='時間:{}\n' \
                                                 '在外時間:{}秒'.format(datetime.fromtimestamp(int(self.__outFrame['timestamp'] + 28800)), self.__outFrame['stayTime']),
                                            actions=[
                                                PostbackAction(
                                                    label=' ',
                                                    data='doNothing'
                                                )
                                            ]
                                        )
                carouselColumns = [outFrameCarouselColum]

            else:
                outFrameCarouselColum = CarouselColumn(
                    thumbnail_image_url=self.__outFrame['imageUrl'],
                    title='離去影像',
                    text='時間:{}\n'.format(
                        datetime.fromtimestamp(
                            int(self.__outFrame['timestamp'] + 28800))),
                    actions=[PostbackAction(label=' ', data='doNothing')])

                inFrameCarouselColum = CarouselColumn(
                                            thumbnail_image_url=self.__inFrame['imageUrl'],
                                            title='進入影像',
                                            text='時間:{}\n' \
                                                 '在外時間:{}秒'.format(datetime.fromtimestamp(int(self.__inFrame['timestamp'] + 28800)), self.__inFrame['stayTime']),
                                            actions=[
                                                PostbackAction(
                                                    label=' ',
                                                    data='doNothing'
                                                )
                                            ]
                                        )
                carouselColumns = [outFrameCarouselColum, inFrameCarouselColum]

        else:
            liveFrameCarouselColum = CarouselColumn(
                                        thumbnail_image_url=self.__inFrame['imageUrl'],
                                        title='現場影像',
                                        text='時間:{}\n' \
                                             '停留時間:{}秒'.format(datetime.fromtimestamp(int(self.__inFrame['timestamp'] + 28800)), self.__inFrame['stayTime']),
                                        actions=[
                                            PostbackAction(
                                                label=' ',
                                                data='doNothing'
                                            )
                                        ]
                                    )

            carouselColumns = [liveFrameCarouselColum]

        return carouselColumns
    def _generate_dist_venues(self, dist_venues):

        actions = []
        columns = []

        if (len(dist_venues) / 4) <= 1.0:

            for venue in dist_venues:

                actions.append(
                    MessageAction(label=venue['title'], text=venue['title']))

            template_message = TemplateSendMessage(
                alt_text='請問你是要問' + dist_venues[0]['dist'] + '的哪個館呢?',
                template=ButtonsTemplate(title=dist_venues[0]['dist'],
                                         text='以下是' + dist_venues[0]['dist'] +
                                         '有提供資訊的展館',
                                         actions=actions))

            return template_message

        else:

            empty_action = PostbackAction(label='空白按鈕', data='empty')

            for venue in dist_venues:

                actions.append(
                    MessageAction(label=venue['title'], text=venue['title']))

                if (len(actions) % 3 == 0):
                    column = CarouselColumn(title=venue['dist'],
                                            text='以下是' + venue['dist'] +
                                            '有提供資訊的展館',
                                            actions=actions)

                    columns.append(column)
                    actions = []

            while len(actions) % 3 != 0:

                actions.append(empty_action)

            column = CarouselColumn(title=venue['dist'],
                                    text='以下是' + venue['dist'] + '有提供資訊的展館',
                                    actions=actions)

            columns.append(column)

            carousel_template = CarouselTemplate(columns=columns)

            template_message = TemplateSendMessage(
                alt_text='請問你是要問' + dist_venues[0]['dist'] + '的哪個館呢?',
                template=carousel_template)

            return template_message
Esempio n. 20
0
def handle_TextMessage(event):
    # createby: LI Yufan
    # 调用获取最新新闻的接口获取新闻
    hot_news = get_hotNews()
    label1=langTrans('View Detail')
    message = TemplateSendMessage(
        alt_text='Hot news about the coronavirus',
        template=CarouselTemplate(
            columns=[
                CarouselColumn(
                    thumbnail_image_url=str(hot_news[1][0],encoding='utf-8'),
                    title=str(hot_news[2][0],encoding='utf-8'),
                    text=str(hot_news[3][0],encoding='utf-8'),
                    actions=[
                        URIAction(uri=str(hot_news[0][0],encoding='utf-8'), label=label1)
                    ]
                ),
                CarouselColumn(
                    thumbnail_image_url=str(hot_news[1][1],encoding='utf-8'),
                    title=str(hot_news[2][1], encoding='utf-8'),
                    text=str(hot_news[3][1], encoding='utf-8'),
                    actions=[
                        URIAction(uri=str(hot_news[0][1], encoding='utf-8'), label=label1)
                    ]
                ),
                CarouselColumn(
                    thumbnail_image_url=str(hot_news[1][2], encoding='utf-8'),
                    title=str(hot_news[2][2], encoding='utf-8'),
                    text=str(hot_news[3][2], encoding='utf-8'),
                    actions=[
                        URIAction(uri=str(hot_news[0][2], encoding='utf-8'), label=label1)
                    ]
                ),
                CarouselColumn(
                    thumbnail_image_url=str(hot_news[1][3], encoding='utf-8'),
                    title=str(hot_news[2][3], encoding='utf-8'),
                    text=str(hot_news[3][3], encoding='utf-8'),
                    actions=[
                        URIAction(uri=str(hot_news[0][3], encoding='utf-8'), label=label1)
                    ]
                ),
                CarouselColumn(
                    thumbnail_image_url=str(hot_news[1][4], encoding='utf-8'),
                    title=str(hot_news[2][4], encoding='utf-8'),
                    text=str(hot_news[3][4], encoding='utf-8'),
                    actions=[
                        URIAction(uri=str(hot_news[0][4], encoding='utf-8'), label=label1)
                    ]
                )
            ]
        )
    )
    line_bot_api.reply_message(
        event.reply_token,
        message
    )
Esempio n. 21
0
def send_button_carousel(id):
    line_bot_api = LineBotApi(channel_access_token)
    message = TemplateSendMessage(
        alt_text='Carousel template',
        template=CarouselTemplate(columns=[
            CarouselColumn(
                thumbnail_image_url=
                'https://cdn.thewirecutter.com/wp-content/uploads/2020/04/laptops-lowres-2x1--1024x512.jpg',
                title='Laptop',
                text='What would you like to do?',
                actions=[
                    MessageTemplateAction(label='Search for a laptop',
                                          text='search laptop'),
                    MessageTemplateAction(label='Budget', text='budget'),
                    MessageTemplateAction(label='FSM', text='fsm')
                ]),
            CarouselColumn(
                thumbnail_image_url=
                'https://www.howtogeek.com/wp-content/uploads/2018/10/cpu_lede.png',
                title='CPU',
                text='What would you like to do?',
                actions=[
                    MessageTemplateAction(label='Top 5 Laptop CPU',
                                          text='top laptop cpu'),
                    MessageTemplateAction(label='Top 7 Laptop GPU',
                                          text='top gpu for laptop'),
                    MessageTemplateAction(label='Latest V.Review',
                                          text='cgpu_review'),
                ]),
            CarouselColumn(
                thumbnail_image_url=
                'https://www.reviewsontop.com/wp-content/uploads/2020/03/X5TyA8uvkGXoNyjFzxcowS-1200-80.jpg',
                title='New to buying your own laptop?',
                text='click here to find the right one',
                actions=[
                    MessageTemplateAction(label='High Tier Gaming',
                                          text='high game'),
                    MessageTemplateAction(label='Mid Tier Gaming',
                                          text='mid game'),
                    MessageTemplateAction(label='Programming', text='program')
                ]),
            CarouselColumn(
                thumbnail_image_url=
                'https://www.reviewsontop.com/wp-content/uploads/2020/03/X5TyA8uvkGXoNyjFzxcowS-1200-80.jpg',
                title='Shopping for Laptop',
                text='Choose a Site to begin',
                actions=[
                    MessageTemplateAction(label='Pchome', text='pchome_link'),
                    MessageTemplateAction(label='CoolPc', text='coolpc_link'),
                    MessageTemplateAction(label='Apple', text='apple_link')
                ])
        ]))
    line_bot_api.push_message(id, message)

    return "OK"
Esempio n. 22
0
def handle_location_message(event):

    if isinstance(event.source, SourceUser) or isinstance(event.source, SourceGroup) or isinstance(event.source, SourceRoom):
        profile = line_bot_api.get_profile(event.source.user_id)
        USER_ID = profile.user_id
        USER_NAME = profile.display_name

    longitude = str(event.message.longitude)
    latitude = str(event.message.latitude)
    # line_bot_api.reply_message(
    #     event.reply_token,
    #     LocationSendMessage(
    #         title=event.message.title, address=event.message.address,
    #         latitude=event.message.latitude, longitude=event.message.longitude
    #     )
    # )
    #line_single_push(USER_ID, str(event.message.longitude))
    

    line_single_push(USER_ID, '查詢中 請稍候...')   
    res = gym_search(longitude, latitude)

    if bool(res["isOk"]):
        res = res["response"]

        #web url
        '''web_res = []
        for i in range(0, 3):
            result = gym_detail(res[i]['GymID'])
            web_res.append(result["web"])'''

        carousel_template = CarouselTemplate(columns=[
                CarouselColumn(thumbnail_image_url=res[0]['Photo1'],text='約 '+str(res[0]['Distance'])+' 公里', title=res[0]['Name'], actions=[
                    MessageAction(label='查詢即時資訊', text=res[0]['Name'])
                    #URIAction(label='官方網站', uri=web_res[0])
                ]),
                CarouselColumn(thumbnail_image_url=res[1]['Photo1'],text='約 '+str(res[1]['Distance'])+' 公里', title=res[1]['Name'], actions=[
                    MessageAction(label='查詢即時資訊', text=res[1]['Name'])
                    #URIAction(label='官方網站', uri=web_res[1])
                ]),
                CarouselColumn(thumbnail_image_url=res[2]['Photo1'],text='約 '+str(res[2]['Distance'])+' 公里', title=res[2]['Name'], actions=[
                    MessageAction(label='查詢即時資訊', text=res[2]['Name'])
                    #URIAction(label='官方網站', uri=web_res[2])
                ])
            ])
        template_message = TemplateSendMessage(
                alt_text='附近的運動中心', template=carousel_template)
        line_bot_api.reply_message(event.reply_token, template_message)
    else:
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text='附近暫無運動中心'))
def XBPM_Carousel():
    Image = '%s/static/XBPM.jpg' % Webhook_URL
    template = CarouselTemplate(columns=[
        CarouselColumn(thumbnail_image_url=Image,
                       title='TPS FE XBPM',
                       text='FE05 - FE21',
                       actions=XBPM_Actions('05', '09', '21')),
        CarouselColumn(thumbnail_image_url=Image,
                       title='TPS FE XBPM',
                       text='FE23 - FE41',
                       actions=XBPM_Actions('23', '25', '41'))
    ])
    return template
Esempio n. 24
0
def handle_message(event):
    text = event.message.text
    if text == 'confirm':
        carousel_template = CarouselTemplate(columns=[
            CarouselColumn(
                text='忘れずに服用できていますか?',
                title='服薬状況',
                actions=[
                    #                    URIAction(label='Go to line.me', uri='https://line.me'),
                    PostbackAction(label='はい', data='はい', text='はい'),
                    PostbackAction(label='いいえ', data='いいえ', text='いいえ')
                ]),
            CarouselColumn(
                text='副作用と疑われる症状は出ていませんか?',
                title='副作用について',
                actions=[
                    PostbackAction(
                        label='はい、出ていません', data='はい、出ていません', text='はい、出ていません'),
                    PostbackAction(
                        label='いいえ、出ています', data='いいえ、出ています', text='いいえ、出ています')
                ]),
        ])
        template_message = TemplateSendMessage(alt_text='Confirm alt text',
                                               template=carousel_template)
        line_bot_api.reply_message(event.reply_token, template_message)

    elif text == 'confirm2':
        confirm_template = ConfirmTemplate(text='病状はいかがですか?',
                                           actions=[
                                               PostbackAction(label='軽快している',
                                                              data='軽快している',
                                                              text='軽快している'),
                                               PostbackAction(label='改善してない',
                                                              data='改善してない',
                                                              text='改善してない')
                                           ])
        template_message = TemplateSendMessage(alt_text='Confirm alt text',
                                               template=confirm_template)
        line_bot_api.reply_message(event.reply_token, template_message)

    elif text == 'confirm3':
        confirm_template = ConfirmTemplate(text='Do it?',
                                           actions=[
                                               MessageAction(label='Yes',
                                                             text='Yes!'),
                                               MessageAction(label='No',
                                                             text='No!'),
                                           ])
        template_message = TemplateSendMessage(alt_text='Confirm alt text',
                                               template=confirm_template)
        line_bot_api.reply_message(event.reply_token, template_message)
Esempio n. 25
0
def send_button_carousel(id):
    line_bot_api = LineBotApi(channel_access_token)
    message = TemplateSendMessage(
        alt_text='Carousel template',
        template=CarouselTemplate(
            columns=[
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/M5qC6xd.jpg',
                    title='餐廳推薦',
                    text='想吃什麼種類?',
                    actions=[
                        MessageTemplateAction(
                            label='美式',
                            text='diner'
                        ),
                        MessageTemplateAction(
                            label='泰式',
                            text='thai cuisine'
                        ),
                        MessageTemplateAction(
                            label='韓式',
                            text='korean cuisine'
                        ),
                    ]
                ),
                CarouselColumn(
                    thumbnail_image_url='https://i.imgur.com/TU6ESPm.jpg',
                    title='餐廳推薦',
                    text='想吃什麼種類?',
                    actions=[
                        MessageTemplateAction(
                            label='日式',
                            text='japanese cuisine'
                        ),
                        MessageTemplateAction(
                            label='火鍋',
                            text='hotpot'
                        ),
                        MessageTemplateAction(
                            label='排隊美食',
                            text='tainan'
                        ),
                    ]
                )
            ]
        )
    )
    line_bot_api.push_message(id, message)

    return "OK"
Esempio n. 26
0
def handle_postback(event):
    if event.postback.data == 'ping':
        line_bot_api.reply_message(event.reply_token,
                                   TextSendMessage(text='pong'))
    elif event.postback.data == 'datetime_postback':
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text=event.postback.params['datetime']))
    elif event.postback.data == 'date_postback':
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text=event.postback.params['date']))
    elif event.postback.data == 'getNearbyLocation':
        data = apiApp.getNearbyAddress()
        text_message_list = [
            TextSendMessage(text='Line Id : ' + row[0] + ' Address : ' +
                            row[1]) for row in data
        ]
        line_bot_api.reply_message(event.reply_token, text_message_list)
    elif event.postback.data == 'location':
        line_bot_api.reply_message(
            event.reply_token,
            TextSendMessage(text='Please enter your location'))
    elif event.postback.data == 'getridch':
        carousel_template = CarouselTemplate(columns=[
            CarouselColumn(
                text='What you can do',
                title='Seller',
                actions=[
                    CameraAction(label='Take a photo'),
                    # PostbackAction(label='ping', data='ping')
                ]),
            CarouselColumn(
                text='What you can do',
                title='Buyer',
                actions=[
                    PostbackAction(label='Get near by trash',
                                   data='getNearbyLocation',
                                   text='Show location'),
                    # MessageAction(label='Translate Rice', text='米')
                ]),
        ])
        template_message = TemplateSendMessage(alt_text='Carousel alt text',
                                               template=carousel_template)
        line_bot_api.reply_message(event.reply_token, template_message)
    elif event.postback.data == 'cfaddress':
        # apiApp.setSellerAddress('KBTG', 'well', '0970909591', 'KBTG')
        line_bot_api.reply_message(
            event.reply_token, TextSendMessage(text='Your order in queue!!'))
    def __getCarouselColumns(self, person):
        carouselColumns = []

        # (1) append source image in carouselColumns
        sourceImageCarouselColumn = CarouselColumn(
                                        thumbnail_image_url=self.__sourceImage['imageUrl'],
                                        title='來源影像',
                                        text='來源人數:{}\n' \
                                             '時間:{}'.format(self.__sourceImage['personCount'], datetime.fromtimestamp(int(self.__sourceImage['timestamp']+ 28800))),
                                        actions=[
                                            PostbackAction(
                                                label=' ',
                                                data='doNothing'
                                            )
                                        ]
                                    )

        carouselColumns.append(sourceImageCarouselColumn)

        # (2) append source face image in carouselColumns
        sourceFaceImageCarouselColumn = CarouselColumn(
            thumbnail_image_url=person['sourceFaceImage']['imageUrl'],
            title='來源人臉',
            text='平均相似度:{}%'.format(
                round(person['sourceFaceImage']['averageSimilarity'], 2)),
            actions=[PostbackAction(label=' ', data='doNothing')])

        carouselColumns.append(sourceFaceImageCarouselColumn)

        # (3) append registration images in carouselColumns
        for index, registrationImage in enumerate(
                person['registrationImageList'], start=1):
            carouselColumn = CarouselColumn(
                                thumbnail_image_url=registrationImage['imageUrl'],
                                title='註冊影像{}'.format(index),
                                text='faceId:{}\n' \
                                     '相似度:{}%\n' \
                                     '時間:{}'.format(registrationImage['faceId'][0:13], round(registrationImage['similarity'], 2), datetime.fromtimestamp(int(registrationImage['timestamp']+ 28800))),
                                actions=[
                                    PostbackAction(
                                        label=' ',
                                        data='doNothing'
                                    )
                                ]
                            )
            carouselColumns.append(carouselColumn)

        return carouselColumns
Esempio n. 28
0
    def list(self, event, params):
        limit = settings.MAX_CAROUSEL_COLUMNS - 1
        offset = params['offset'] if 'offset' in params else 0
        limit = int(limit)
        offset = int(offset)

        carousel_columns = []
        for post in ClosetPost.objects.all().order_by('code')[offset:offset +
                                                              limit]:
            description = post.description
            date_time = post.date.astimezone(
                get_localzone()).strftime("%H:%M:%S")
            for image in ClosetImages.objects.filter(
                    code=post.code, thumbnail=True).order_by('-name')[:1]:
                action = PostbackAction(
                    label="ดูรายละเอียด",
                    data="action=view&code={}".format(post.code),
                )
                image_url = "{}{}?_={}".format(settings.BASE_URL, image.src,
                                               datetime.now().timestamp())
                cc = CarouselColumn(
                    thumbnail_image_url=image_url,
                    title="{} {}".format(post.code, date_time),
                    text=post.description[:settings.MAX_CAROUSEL_TEXT],
                    actions=[action],
                )
                carousel_columns.append(cc)
        if len(carousel_columns) == limit:
            cc = CarouselColumn(
                thumbnail_image_url=settings.BASE_URL,
                title="See more",
                text="ดูรายการต่อไป",
                actions=[
                    PostbackAction(
                        label="ดูรายการต่อไป",
                        data="action=list&offset={}".format(offset + limit),
                    ),
                ],
            )
            carousel_columns.append(cc)
        template_message = TemplateSendMessage(
            alt_text='Carousel alt text',
            template=CarouselTemplate(columns=carousel_columns),
        )
        try:
            line_bot_api.reply_message(event.reply_token, template_message)
        except Exception as e:
            print(e)
Esempio n. 29
0
def sendCarousel(event):  #轉盤樣板
    try:
        message = TemplateSendMessage(
            alt_text='其他',
            template=CarouselTemplate(
                columns=[
                    CarouselColumn(
                        thumbnail_image_url='https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcT4NQBoplbhOoo3bc_Zgj37mraOw88ddrWP7LTZfpfnY7FcDr5m&usqp=CAU',
                        title=' ',
                        text='其他資訊',
                        actions=[
                            URITemplateAction(
                                label='洗錢型態例子',
                                uri='https://www.mjib.gov.tw/EditPage?PageID=564dcbaf-1d4e-45a9-bf1e-a26ea488bd76'
                            ),
                            MessageTemplateAction(
                                label='國際防制洗錢標準',
                                text='1.處罰洗錢及資恐行為2.沒收不法所得及進行目標制裁3.國際合作4.建立防治機制'
                            ),
		          
                             URITemplateAction(
                                label='最新資訊',
                                uri='https://www.amlo.moj.gov.tw/1461/1467/Lpsimplelist'
                            ),
                            
                        ]
                    ),

                ]
            )
        )
        line_bot_api.reply_message(event.reply_token,message)
    except:
        line_bot_api.reply_message(event.reply_token,TextSendMessage(text='發生錯誤!'))
Esempio n. 30
0
def generate_message_for_question(question):
    choices = [question.answer, *question.wrong_choices]
    random.shuffle(choices)
    choices = [
        *filter(lambda s: '皆' not in s, choices),
        *filter(lambda s: '皆' in s, choices)
    ]

    if len(choices) > 4 or any(len(s) > 20 for s in choices):
        template = CarouselTemplate(columns=[
            CarouselColumn(title=f'選項 {option}',
                           text=choice[:60],
                           actions=[
                               MessageTemplateAction(label='選擇',
                                                     text=f'答案:{choice}')
                           ]) for option, choice in zip('ABCDE', choices)
            if choice != ''
        ])
        return [
            TextSendMessage(text=f'Q: {question.message}'),
            TemplateSendMessage(alt_text='請作答:', template=template)
        ]

    else:
        return [
            TemplateSendMessage(alt_text='請作答:',
                                template=ButtonsTemplate(
                                    text=f'Q: {question.message}',
                                    actions=[
                                        MessageTemplateAction(
                                            label=choice,
                                            text=f'答案:{choice}',
                                        ) for choice in choices if choice != ''
                                    ]))
        ]