示例#1
0
def single(set1):
    for x in set1:
        mes = BubbleContainer(
            hero=ImageComponent(url=set1[x],
                                size='full',
                                align='center',
                                aspect_ratio='13:13',
                                aspect_mode='cover'),
            body=BoxComponent(layout='vertical',
                              contents=[
                                  TextComponent(margin='md',
                                                text=x,
                                                weight='bold',
                                                size='md',
                                                align='center'),
                                  SeparatorComponent(margin='xl',
                                                     color='#0000FF'),
                                  BoxComponent(margin='md',
                                               layout='horizontal',
                                               spacing='xs',
                                               contents=[
                                                   ButtonComponent(
                                                       style='link',
                                                       color='#84C1FF',
                                                       flex=1,
                                                       height='sm',
                                                       action=MessageAction(
                                                           label="我的最愛",
                                                           text='SeeMyLove'))
                                               ])
                              ]))
        return FlexSendMessage(alt_text="hello", contents=mes)
    else:
        return TextSendMessage(text="None img")
示例#2
0
def chain():
    mes = BubbleContainer(
        header=BoxComponent(layout='baseline',
                            contents=[
                                TextComponent(text='Q4:想購買的通路',
                                              weight='bold',
                                              size='xxl',
                                              flex=2,
                                              align='center')
                            ]),
        body=BoxComponent(
            layout='vertical',
            spacing='xs',
            contents=[
                ButtonComponent(style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='家樂福', text='家樂福')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='全聯', text='全聯')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='Costco',
                                                     text='Costco'))
            ]))
    message = FlexSendMessage(alt_text="hello", contents=mes)
    return message
示例#3
0
def price():
    mes = BubbleContainer(
        header=BoxComponent(layout='baseline',
                            contents=[
                                TextComponent(text='Q5:價格預算',
                                              weight='bold',
                                              size='xxl',
                                              flex=2,
                                              align='center')
                            ]),
        body=BoxComponent(
            layout='vertical',
            spacing='xs',
            contents=[
                ButtonComponent(style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='100~350元',
                                                     text='100~350元')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='351~600元',
                                                     text='351~600元')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='600元以上',
                                                     text='600元以上'))
            ]))
    message = FlexSendMessage(alt_text="hello", contents=mes)
    return message
示例#4
0
def res_user_status(event):
	profile = line_bot_api.get_profile(event.source.user_id)
	status_msg = profile.status_message
	if status_msg != "None":
		# LINEに登録されているstatus_messageが空の場合は、"なし"という文字列を代わりの値とする
		status_msg = "なし"
	message=FlexSendMessage(
		alt_text='ユーザー情報',
		contents=BubbleContainer(
			header=BoxComponent(
				layout="vertical",
				contents=[
					TextComponent(
						text='text',
						align='center',
						gravity='center',
						contents=[
							SpanComponent(text='ユーザー情報')
						]
					)
				]
			),#Header
			hero=ImageComponent(
				url=profile.picture_url,
				size="full",
				aspect_mode="fit",
				action=None
			),
			body=BoxComponent(
				layout="vertical",
				contents=[
					TextComponent(
						text='text',
						align='center',
						gravity='center',
						contents=[
							SpanComponent(text=f'User Id: {profile.user_id}')
						]
					),
					TextComponent(
						text='text',
						align='center',
						gravity='center',
						contents=[
							SpanComponent(text=f'Status Message: {status_msg}')
						]
					)
				]
			),#Body
			footer=BoxComponent(
				layout="vertical",
				contents=[
					ButtonComponent(
						action=MessageAction(label="成功", text="?")
					)
				]
			)#Footer
		)
	)
	line_bot_api.reply_message(event.reply_token, messages=message)
示例#5
0
def build_rabbit_adopt_content():
    container = BubbleContainer(
        direction='ltr',
        body=BoxComponent(
            layout='vertical',
            contents=[
                TextComponent(text='你還沒有兔子', weight='bold', size='xl'),
                SeparatorComponent(),
                BoxComponent(layout='horizontal',
                             spacing='sm',
                             contents=[
                                 ButtonComponent(
                                     style='primary',
                                     height='sm',
                                     color='#95B9B4',
                                     action=MessageAction(label='領養兔子',
                                                          text='領養兔子'),
                                 ),
                                 ButtonComponent(style='primary',
                                                 height='sm',
                                                 color='#95B9B4',
                                                 action=MessageAction(
                                                     label='沒事了', text='沒事了'))
                             ])
            ],
        ),
    )
    return container
示例#6
0
    def intro(self, name):

        bubble = BubbleContainer(

            # body
            body=BoxComponent(
                layout='vertical',
                spacing='md',
                contents=[
                    TextComponent(text='Hello {0},\n\n'.format(name), weight='bold', size='lg'),

                    # main info
                    TextComponent(text='我是呂明聲,現在就讀中央資管所碩一,熱愛開發、嘗試新技術,喜歡透過資訊科技解決問題 !\n\n如履歷所述,我曾擔任過資源教室助教及銀行資訊部實習生,喜歡協助同學也喜歡團隊合作解決問題,相信是TechFRESH不可或缺的Hack, everything 精神 !\n\n很高興能在這相遇,期望這是我們認識的開始!\n\nRegards,\nMing-Sheng,Lyu', size='md', wrap=True, color='#272727'),

                    SeparatorComponent(margin='xl'),

                    BoxComponent(
                        layout = 'vertical',
                        contents = [
                        SpacerComponent(size='md'),
                        ButtonComponent(
                            style='primary',
                            height='sm',
                            action=MessageAction(label="SAM's Skill", text='你會什麼?'),
                            )                                                                  
                        ]
                    )
                ]
            )
        )
        message = FlexSendMessage(alt_text="SAM's Intro", contents=bubble)
        return message
示例#7
0
def construct_multiple_choice(data):
    actions = []
    for button in data.get("buttons"):
        actions.append(
            ButtonComponent(
                style="primary",
                height="sm",
                margin="md",
                action=MessageAction(label=button.get("title"),
                                     text=button.get("title")),
            ))

    bubble = BubbleContainer(
        direction="ltr",
        body=BoxComponent(
            layout="vertical",
            contents=construct_mc_header(data) + [
                TextComponent(
                    text=data.get("text"),
                    size="md",
                    margin="lg",
                    wrap=True,
                )
            ],
        ),
        footer=BoxComponent(layout="vertical", contents=actions),
    )

    return bubble
示例#8
0
def get_greeting_carousel(parts: list):
    buttons = []
    elements = []
    for i, part in enumerate(parts):
        elements.append(
            ButtonComponent(color='#097AC5',
                            action=MessageAction(label=part, text=part)))
        if i % 2 == 1:
            buttons.append(
                BoxComponent(layout="horizontal",
                             color='#097AC5',
                             contents=list(elements)))
            elements = []

    return CarouselContainer(contents=[
        BubbleContainer(
            size='mega',
            body=BoxComponent(
                layout="vertical",
                background_color='#f8f8f8',
                contents=[
                    TextComponent(
                        align='start',
                        color='#222E38',
                        text=
                        '😇If wanna know me more, please click your interested section below!',
                        size='md',
                        weight='regular',
                        wrap=True)
                ]),
            footer=BoxComponent(layout="vertical",
                                padding_all='none',
                                background_color='#F8F8F8',
                                contents=list(buttons)))
    ])
示例#9
0
文件: db.py 项目: changsuwi/Line-bot
def add_video(template, title, url, thumbnails):
    bubble = BubbleContainer(
        direction='ltr',
        hero=ImageComponent(url=thumbnails,
                            size='full',
                            aspect_ratio='20:13',
                            aspect_mode='cover',
                            gravity='center'),
        body=BoxComponent(
            layout='vertical',
            contents=[
                # title
                TextComponent(text=title,
                              wrap=True,
                              weight='bold',
                              size='xxl',
                              align='center')
            ]),
        footer=BoxComponent(layout='vertical',
                            spacing='sm',
                            contents=[
                                SpacerComponent(size='sm'),
                                ButtonComponent(
                                    style='link',
                                    height='sm',
                                    action=URIAction(label='點擊查看', uri=url),
                                )
                            ]),
    )
    template.contents.append(bubble)
    return template
 def test_bubble_container(self):
     arg = {
         'header':
         BoxComponent(layout='vertical',
                      contents=[TextComponent(text='Header text')]),
         'body':
         BoxComponent(layout='vertical',
                      contents=[TextComponent(text='Body text')]),
         'footer':
         BoxComponent(layout='vertical',
                      contents=[TextComponent(text='Footer text')]),
         'styles':
         BubbleStyle(header=BlockStyle(background_color='#00ffff'),
                     hero=BlockStyle(background_color='#00ffff',
                                     separator=True),
                     footer=BlockStyle(background_color='#00ffff',
                                       separator=True,
                                       separator_color='#00ffff'))
     }
     heros = [
         ImageComponent(uri='https://example.com/flex/images/image.jpg'),
         BoxComponent(layout='vertical',
                      contents=[TextComponent(text='Body text')]),
     ]
     for hero in heros:
         arg['hero'] = hero
         self.assertEqual(self.serialize_as_dict(arg, type=self.BUBBLE),
                          BubbleContainer(**arg).as_json_dict())
示例#11
0
def aroma():
    mes = BubbleContainer(
        header=BoxComponent(layout='baseline',
                            contents=[
                                TextComponent(text='Q2:喜歡的香氣',
                                              weight='bold',
                                              size='xxl',
                                              flex=2,
                                              align='center')
                            ]),
        body=BoxComponent(
            layout='vertical',
            spacing='xs',
            contents=[
                ButtonComponent(style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='花香 (ex:玫瑰花...)',
                                                     text='花香')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='漿果 (ex:櫻桃...)',
                                                     text='漿果')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='柑橘 (ex:檸檬...)',
                                                     text='柑橘')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='熱帶水果 (ex:鳳梨...)',
                                                     text='熱帶水果')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='淺色水果 (ex:杏桃...)',
                                                     text='淺色水果')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='香料 (ex:胡椒...)',
                                                     text='香料')),
                ButtonComponent(margin='xl',
                                style='secondary',
                                color='#FFEE99',
                                height='sm',
                                action=MessageAction(label='土木 (ex:橡木桶...)',
                                                     text='土木'))
            ]))
    message = FlexSendMessage(alt_text="hello", contents=mes)
    return message
示例#12
0
def FlexWeatherTemplate(city, url, w, aqiindex, uvi):
    return (FlexSendMessage(
        alt_text=city + "-天氣及空氣品質 Flex",
        contents=BubbleContainer(body=BoxComponent(
            layout="vertical",
            padding_all="0px",
            contents=[
                ImageComponent(url=url,
                               gravity="center",
                               margin="none",
                               size="full",
                               aspectRatio="1:1",
                               aspectMode="cover"),
                BoxComponent(
                    layout="vertical",
                    padding_all="20px",
                    position="absolute",
                    contents=[
                        TextComponent(text=city, size="xl"),
                        TextComponent(text=str(
                            datetime.datetime.now(pytz.timezone(
                                'Asia/Taipei')).strftime("%Y/%m/%d %H:%M")),
                                      size="xs"),
                        ImageComponent(url="https" +
                                       w.get_weather_icon_url()[4:],
                                       size="xxs",
                                       align="start"),
                        TextComponent(text=status2ct(w.get_status()),
                                      size="xxl",
                                      weight="bold"),
                        TextComponent(text=w.get_detailed_status(), size="xs"),
                        TextComponent(text="溫度: " + str(
                            round(
                                w.get_temperature(
                                    unit='celsius')['temp'], 1)) + "°C" +
                                      " 濕度: " + str(w.get_humidity()) + "%",
                                      size="xl"),
                        TextComponent(text="空氣品質: " + requests.get(
                            'https://data.epa.gov.tw/api/v1/aqx_p_432?api_key=9be7b239-557b-4c10-9775-78cadfc555e9&format=json&limit=1234'
                        ).json()['records'][aqiindex]['AQI'] + "(" + aqi2rate(
                            requests.get(
                                'https://data.epa.gov.tw/api/v1/aqx_p_432?api_key=9be7b239-557b-4c10-9775-78cadfc555e9&format=json&limit=100'
                            ).json()['records'][aqiindex]['AQI']) + ")"),
                        TextComponent(
                            text="紫外線: " +
                            str(round(float(uvi.json()['records'][0]
                                            ['UVI']))) + "(" +
                            uvi2rate(uvi.json()['records'][0]['UVI']) + ")"),
                        TextComponent(
                            text="風速: " +
                            str(round(w.get_wind()['speed'] * 18 / 5, 1)) +
                            "km/h")
                    ])
            ]))))
 def test_carousel_container(self):
     arg = {
         'contents': [
             BubbleContainer(body=BoxComponent(
                 layout='vertical', contents=[TextComponent(text='Hey')])),
             BubbleContainer(body=BoxComponent(
                 layout='vertical', contents=[TextComponent(text='Foo')])),
         ]
     }
     self.assertEqual(self.serialize_as_dict(arg, type=self.CAROUSEL),
                      CarouselContainer(**arg).as_json_dict())
示例#14
0
def get_total_flex(body_content,footer_content=[ButtonComponent(style='link',action=URIAction(label='My github', uri='https://github.com/kevin1061517?tab=repositories'))]):
    bubble = BubbleContainer(
            body=BoxComponent(
                layout='vertical',
                contents=body_content
            ),
            footer=BoxComponent(
                layout='vertical',
                spacing='sm',
                contents= footer_content
            )
        )
    return bubble
示例#15
0
 def show_single_result(self, imgurl, emotion, confidence):
     bubble = BubbleContainer(
         # header
         header=BoxComponent(layout='horizontal',
                             contents=[
                                 TextComponent(text='辨識結果',
                                               size='lg',
                                               color='#5b5b5b')
                             ]),
         #hero
         hero=ImageComponent(url='{0}'.format(imgurl),
                             size='3xl',
                             aspect_ratio='16:9',
                             aspect_mode='fit'),
         # body
         body=BoxComponent(
             layout='vertical',
             spacing='md',
             contents=[
                 SeparatorComponent(margin='md'),
                 BoxComponent(layout='horizontal',
                              spacing='md',
                              contents=[
                                  TextComponent(text='情緒 :',
                                                size='lg',
                                                color='#9d9d9d',
                                                align='center'),
                                  TextComponent(text='{0}'.format(emotion),
                                                size='lg',
                                                color='#00BE00',
                                                weight='bold')
                              ]),
                 BoxComponent(layout='horizontal',
                              spacing='md',
                              contents=[
                                  TextComponent(text='信心值 :',
                                                size='lg',
                                                color='#9d9d9d',
                                                align='center'),
                                  TextComponent(
                                      text='{0}%'.format(confidence),
                                      size='lg',
                                      color='#00BE00',
                                      weight='bold')
                              ])
             ]))
     message = FlexSendMessage(alt_text="辨識結果", contents=bubble)
     return message
示例#16
0
    def intro(self, user_name):
        bubble = BubbleContainer(
            # header
            header=BoxComponent(layout='horizontal',
                                contents=[
                                    TextComponent(
                                        text='Hi {0},'.format(user_name),
                                        size='lg',
                                        color='#000000')
                                ]),

            # hero
            hero=ImageComponent(url='https://i.imgur.com/xYgkKHe.png',
                                size='full',
                                aspect_ratio='16:9',
                                aspect_mode='cover'),

            # body
            body=BoxComponent(
                layout='vertical',
                spacing='md',
                contents=[
                    SeparatorComponent(margin='md'),
                    BoxComponent(
                        layout='horizontal',
                        spacing='md',
                        contents=[
                            TextComponent(
                                text='Hi 可以發一張圖片給我,\n我能識別出裡面的人臉情緒唷~\n\n',
                                size='md',
                                wrap=True,
                                color='#272727',
                                align='center')
                        ]),
                    BoxComponent(
                        layout='horizontal',
                        spacing='md',
                        contents=[
                            TextComponent(
                                text='聲明\n辨識完即刪除,不會以任何形式保存圖片、人像等敏感性資訊',
                                size='sm',
                                wrap=True,
                                color='#00BE00',
                                align='center')
                        ])
                ]))
        message = FlexSendMessage(alt_text="hello~", contents=bubble)
        return message
def handle_Patient_Introduce(event):

    textlist = ['See coronavirus pneumonia patients distribution (Update to 3.27)', \
                'Check the distribution of patients in China in some day (must choose a date, provided 1.22-3.27)', \
                'View patients distribution in a country (must choose a date, provided 1.22-3.27)', \
                'Look patients distributionis in a province or region']

    questionlist = ['I want to know coronavirus pneumonia patients distribution.', \
                'How\'s patients distributionis in China in 3.23?', \
                'How\'s patients condition about US in 2.24?', \
                'How\'s patients distributionis in Hubei?']

    cont = []
    for i in range(4):
        row = BoxComponent(
            layout='baseline',
            spacing='sm',
            contents=[
                TextComponent(
                    text=textlist[i],
                    color='#666666',
                    size='sm',
                    margin='md',
                    wrap=True,
                    action=MessageTemplateAction(text=questionlist[i]))
            ],
        )
        cont.append(row)
        cont.append(SeparatorComponent())
    del (cont[-1])

    title = 'You could ask following four type questions:'
    bubble = BubbleContainer(direction='ltr',
                             body=BoxComponent(layout='vertical',
                                               contents=[
                                                   TextComponent(text=title,
                                                                 weight='bold',
                                                                 wrap=True,
                                                                 size='md'),
                                                   BoxComponent(
                                                       layout='vertical',
                                                       margin='lg',
                                                       spacing='sm',
                                                       contents=cont)
                                               ]))

    message = FlexSendMessage(alt_text="hello", contents=bubble)
    line_bot_api.reply_message(event.reply_token, message)
示例#18
0
def generate_carousel_for_search(books):
    contents = []
    for book in books:
        content = BubbleContainer(
            action=URIAction(uri=book['url']),
            size='micro',
            hero=ImageComponent(url=book['photo_url'],
                                size='full',
                                aspect_mode='cover',
                                aspect_ratio='320:213'),
            body=BoxComponent(layout='vertical',
                              spacing='sm',
                              padding_all='13px',
                              contents=[
                                  TextComponent(text=book['name'],
                                                weight='bold',
                                                size='sm'),
                                  BoxComponent(
                                      layout='baseline',
                                      contents=[
                                          TextComponent(text=book['authors'],
                                                        size='xs',
                                                        color='#8c8c8c',
                                                        margin='md'),
                                          TextComponent(text=book['publisher'],
                                                        size='xs',
                                                        color='#8c8c8c',
                                                        margin='md')
                                      ]),
                                  SeparatorComponent(margin='md',
                                                     color='#a0a0a0'),
                                  TextComponent(text=book['summary'],
                                                color='#8c8c8c',
                                                size='xs',
                                                wrap=True)
                              ]),
            footer=BoxComponent(layout='vertical',
                                contents=[
                                    SeparatorComponent(margin='md',
                                                       color='#a0a0a0'),
                                    TextComponent(text=book['price'],
                                                  wrap=True,
                                                  size='sm',
                                                  flex=5,
                                                  align='center')
                                ]))
        contents.append(content)
    return CarouselContainer(contents=contents)
示例#19
0
    def create_response(self):
        trashinfo = self._context['trash_info'][0]
        contents = [
            TextComponent(text=self._context['text'], wrap=True, size='sm'),
            SeparatorComponent(),
        ]
        if trashinfo['name'] != '':
            contents.append(
                TextComponent(text='名前', color='#a0a0a0', size='sm'))
            contents.append(
                TextComponent(text=trashinfo['name'], wrap=True, size='sm'))
        if trashinfo['category'] != '':
            contents.append(
                TextComponent(text='種類', color='#a0a0a0', size='sm'))
            contents.append(
                TextComponent(text=trashinfo['category'], wrap=True,
                              size='sm'))
        if trashinfo['note'] != '':
            contents.append(
                TextComponent(text='メモ', color='#a0a0a0', size='sm'))
            contents.append(
                TextComponent(text=trashinfo['note'], wrap=True, size='sm'))

        return FlexSendMessage(
            alt_text=self._context['text'],
            contents=BubbleContainer(body=BoxComponent(
                layout='vertical', contents=contents, spacing='md')))
示例#20
0
def feedback(event):
    bubble = BubbleContainer(direction='ltr',
    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
                                ),
                            ],
                        )
                    ],
                    )
        ],),
    footer=BoxComponent(layout='vertical', spacing='sm',
        contents=[
            # callAction
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='好笑', text= '好笑'),
            ),
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='有點好笑', text= '有點好笑'),
            ),
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='不好笑', text= '不好笑'),
            ),

        ]
    ),
    )
    message = FlexSendMessage(alt_text="笑話回饋", contents=bubble)
    return message
示例#21
0
def test_template():
    conn = model.Conn()

    # get all subject by class_id
    query_select_subject = 'SELECT * FROM subject WHERE id = %s'
    conn.query(query_select_subject, '2')
    row_subject = conn.cursor.fetchone()

    # get all topic by subject_id
    query_select_topic = 'SELECT * FROM topic WHERE subject_id = %s'
    conn.query(query_select_topic, '1')
    rows_topic = conn.cursor.fetchall()
    if len(rows_topic) == 0:  # topic is empty
        line_bot_api.reply_message(event.reply_token,
                                   [TextMessage(text=constant.TOPIC_EMPTY)])
    else:  # topic exist
        contents = []
        for row in rows_topic:
            contents.append(
                BubbleContainer(
                    direction='ltr',
                    body=BoxComponent(
                        layout='vertical',
                        contents=[
                            TextComponent(text=str(row['name']),
                                          margin='md',
                                          size='xl',
                                          align='center',
                                          gravity='center',
                                          weight='bold'),
                            ButtonComponent(action=PostbackAction(
                                label='Belajar',
                                text='Belajar',
                                data='action=material_learn&subject_id=' +
                                str(row_subject['id']) + '&topic_id=' +
                                str(row['id']))),
                            ButtonComponent(action=PostbackAction(
                                label='Diskusi',
                                text='Diskusi',
                                data='action=material_discussion&subject_id=' +
                                str(row_subject['id']) + '&topic_id=' +
                                str(row['id']))),
                            ButtonComponent(action=PostbackAction(
                                label='Latihan Soal',
                                text='Latihan Soal',
                                data='action=material_quiz&subject_id=' +
                                str(row_subject['id']) + '&topic_id=' +
                                str(row['id'])))
                        ])))

        flex_message = FlexSendMessage(
            alt_text='Carousel Topik',
            contents=CarouselContainer(contents=contents))

        print('HERE, contents:', contents)
        print('HERE, flex_message:', flex_message)

        return 'OK'
示例#22
0
def taste():
    mes = BubbleContainer(
        header=BoxComponent(layout='baseline',
                            contents=[
                                TextComponent(text='Q3:想要的口感',
                                              weight='bold',
                                              size='xxl',
                                              flex=2,
                                              align='center')
                            ]),
        body=BoxComponent(layout='vertical',
                          spacing='xs',
                          contents=[
                              ButtonComponent(style='secondary',
                                              color='#FFEE99',
                                              height='sm',
                                              action=MessageAction(label='清香',
                                                                   text='清香')),
                              ButtonComponent(margin='xl',
                                              style='secondary',
                                              color='#FFEE99',
                                              height='sm',
                                              action=MessageAction(label='甜',
                                                                   text='甜')),
                              ButtonComponent(margin='xl',
                                              style='secondary',
                                              color='#FFEE99',
                                              height='sm',
                                              action=MessageAction(label='圓潤',
                                                                   text='圓潤')),
                              ButtonComponent(margin='xl',
                                              style='secondary',
                                              color='#FFEE99',
                                              height='sm',
                                              action=MessageAction(label='酸',
                                                                   text='酸')),
                              ButtonComponent(margin='xl',
                                              style='secondary',
                                              color='#FFEE99',
                                              height='sm',
                                              action=MessageAction(label='濃厚',
                                                                   text='濃厚'))
                          ]))
    message = FlexSendMessage(alt_text="hello", contents=mes)
    return message
def get_news_message(title, href, img, imghref, showinTilte):
    cont = []
    for i in range(len(title)):
        row = BoxComponent(
            layout='baseline',
            spacing='sm',
            contents=[
                TextComponent(text=title[i],
                              color='#666666',
                              size='sm',
                              margin='md',
                              wrap=True,
                              action=URIAction(label='WEBSITE', uri=href[i]))
            ],
        )
        cont.append(row)
        cont.append(SeparatorComponent())
    del (cont[-1])

    title = 'Top News' + showinTilte
    bubble = BubbleContainer(
        direction='ltr',
        hero=ImageComponent(url=img[0],
                            size='full',
                            aspect_ratio='20:13',
                            aspect_mode='cover',
                            action=URIAction(uri=imghref[0], label='label')),
        body=BoxComponent(
            layout='vertical',
            contents=[
                # title
                TextComponent(text=title, weight='bold', size='xl'),
                # info
                BoxComponent(
                    layout='vertical',
                    margin='lg',
                    spacing='sm',
                    contents=cont,
                )
            ],
        ))

    message = FlexSendMessage(alt_text="hello", contents=bubble)
    return message
示例#24
0
def get_tests_for_concern(req):
    diseases = req.get('queryResult').get('parameters').get('diseases', '')
    print('disease is {}'.format(diseases))
    if not diseases:
        return None
    tests = []
    q = prepareQuery(
        ('SELECT ?testname ?tcode WHERE { ?a rdfs:label ?disease .'
         '?test lab:screenFor ?a .'
         '?test lab:code ?tcode .'
         '?test rdfs:label ?testname .}'),
        initNs={
            'lab': labn,
            'foaf': FOAF,
            'rdfs': RDFS
        })
    for row in graph.query(q, initBindings={'disease': diseases}):
        print(row.testname)
        tests.append({'name': row.testname, 'code': row.tcode})
    instruction = 'กรุณาพิมพ์รหัสในวงเล็บสำหรับรายละเอียดของรายการตรวจ'
    message = 'ควรตรวจ {} {}'.format(
        join_and([t['name'] for t in tests], sep=" "), instruction)
    bubbles = []
    for t in tests:
        bubbles.append(
            BubbleContainer(
                body=BoxComponent(layout='vertical',
                                  contents=[
                                      TextComponent(
                                          text=u'{}'.format(t['name']),
                                          weight='bold',
                                          size='xl',
                                          gravity='center',
                                          align='center',
                                      )
                                  ]),
                footer=BoxComponent(
                    layout='vertical',
                    contents=[
                        ButtonComponent(action=MessageAction(
                            label='detail', text=u'{}'.format(t['code'])))
                    ])))

    return bubbles
示例#25
0
    def welcome(self):

        bubble = BubbleContainer(

            # header
            header=BoxComponent(
                layout='horizontal',
                contents=[
                    TextComponent(text='哆哆歡迎您', weight='bold', size='lg', color='#00BE00')
                ]
            ),

            #hero
            hero=ImageComponent(url='https://i.imgur.com/onXQU46.png', size='full', aspect_ratio='16:9', aspect_mode='cover'),
                

            # body
            body=BoxComponent(
                layout='vertical',
                spacing='md',
                contents=[
                    
                    # main info
                    TextComponent(text='嗨,我是哆哆,感謝您加我為好友,我會回答您的問題讓您更進一步了解明聲。讓我們開始吧!\n\n您可以直接輸入:\n\n可以介紹一下嗎?\n你會什麼?\n你有什麼作品?\n有拿過什麼認證嗎?\n\n當不知道如何使用時,請輸入help\n我會出來為您引導。', size='md', wrap=True, color='#6c6c6c'),

                    SeparatorComponent(margin='xl'),

                    BoxComponent(
                        layout = 'vertical',
                        contents = [
                        SpacerComponent(size='md'),
                        ButtonComponent(
                            style='primary',
                            height='sm',
                            action=MessageAction(label="Let's Start", text='可以介紹一下嗎?'),
                            )                                                                  
                        ]
                    )
                ]
            )
        )
        message = FlexSendMessage(alt_text="Welcome", contents=bubble)
        return message
示例#26
0
def generate_search_bubble_from_key(key):
    search_bubble = BubbleContainer(body=BoxComponent(
        layout='vertical',
        contents=[
            TextComponent(
                text='更多 {} 的搜尋結果'.format(key),
                action=URIAction(
                    uri='https://search.books.com.tw/search/query/key/{}/cat/BKA'
                    .format(key)))
        ]))
    return search_bubble
def member_text(arrival_date):
    return FlexSendMessage("参加者入力", BubbleContainer(
        size="mega",
        header=BoxComponent(
            layout="vertical",
            separator="true",
            contents=[
                TextComponent(
                    text=arrival_date.strftime("%m月%d日 %H時%M分"),
                    align="center",
                    size="lg"
                ),
            ]),
        body=BoxComponent(
            layout="vertical",
            contents=[
                TextComponent(
                    text="あなた以外の参加者を,",
                    align="center",
                    size="md"
                ),
                TextComponent(
                    text="@john @michael ...",
                    align="center",
                    color="#888822",
                    size="sm"
                ),
                TextComponent(
                    text="という形で入力してください.",
                    align="center",
                    size="md"
                ),
            ]
        ),
        action=PostbackAction(
            label="到着",
            display_text="到着",
            data="data not served"
        ),
        styles=BubbleStyle(body=BlockStyle(background_color="#ffffff"))
    ))
def button_container_1x(choice, button_color):
    choice = choice
    button_container = BoxComponent(
        layout='horizontal',
        spacing='sm',
        contents=[
            # callAction, separator, websiteAction
            SpacerComponent(size='sm'),
            # callAction
            button(choice, button_color),
        ])
    return button_container
示例#29
0
def ask(txt, event):
    bubble  = BubbleContainer(direction='ltr',
    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
                                ),
                            ],
                        )
                    ],
                    )
        ],),
    footer=BoxComponent(layout='vertical', spacing='sm',
        contents=[
            # callAction
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='有', text= '有達到破冰效果'),
            ),
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='沒有', text= '沒有達到破冰效果'),
            ),
        ]
    ),
    )
    message = FlexSendMessage(alt_text="是否破冰", contents=bubble)
    return message   
示例#30
0
def more(txt, event, userID):
    bubble  = BubbleContainer(direction='ltr',
    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
                                ),
                            ],
                        )
                    ],
                    )
        ],),
    footer=BoxComponent(layout='vertical', spacing='sm',
        contents=[
            # callAction
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='再來一個', text= intxt[userID]),
            ),
            ButtonComponent(
                style='link',
                height='sm',
                action=MessageAction(label='不用', text= '不用'),
            ),
        ]
    ),
    )
    message = FlexSendMessage(alt_text="再來一個", contents=bubble)
    return message