按照规律,使用AI生成一个架构图
直接上代码,为了方便学习,直接按照如下方式,复制到你的开发环境即可调试,运行代码。做学习参考。
代码注释多次说明这里,不在赘述。
"type": "carousel","contents": [{"type": "bubble","size": "micro","hero": {"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip10.jpg","size": "full","aspectMode": "cover","aspectRatio": "320:213"},"body": {"type": "box","layout": "vertical","contents": [{"type": "text","text": "Jason Cafe","weight": "bold","size": "sm","wrap": True},{"type": "box","layout": "baseline","contents": [{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gray_star_28.png"},{"type": "text","text": "4.0","size": "xs","color": "#8c8c8c","margin": "md","flex": 0}]},{"type": "box","layout": "vertical","contents": [{"type": "box","layout": "baseline","spacing": "sm","contents": [{"type": "text","text": "Jason's chat bot test1","wrap": True,"color": "#8c8c8c","size": "xs","flex": 5}]}]}],"spacing": "sm","paddingAll": "13px"}},{"type": "bubble","size": "micro","hero": {"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip11.jpg","size": "full","aspectMode": "cover","aspectRatio": "320:213"},"body": {"type": "box","layout": "vertical","contents": [{"type": "text","text": "Jason's chat bot 1","weight": "bold","size": "sm","wrap": True},{"type": "box","layout": "baseline","contents": [{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gold_star_28.png"},{"type": "icon","size": "xs","url": "https://developers-resource.landpress.line.me/fx/img/review_gray_star_28.png"},{"type": "text","text": "4.0","size": "sm","color": "#8c8c8c","margin": "md","flex": 0}
第二段:
"type": "bubble","body": {"type": "box","layout": "vertical","contents": [{"type": "box","layout": "horizontal","contents": [{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip7.jpg","size": "5xl","aspectMode": "cover","aspectRatio": "150:196","gravity": "center","flex": 1},{"type": "box","layout": "vertical","contents": [{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip8.jpg","size": "full","aspectMode": "cover","aspectRatio": "150:98","gravity": "center"},{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip9.jpg","size": "full","aspectMode": "cover","aspectRatio": "150:98","gravity": "center"}],"flex": 1}]},{"type": "box","layout": "horizontal","contents": [{"type": "box","layout": "vertical","contents": [{"type": "image","url": "https://developers-resource.landpress.line.me/fx/clip/clip13.jpg","aspectMode": "cover","size": "full"}],"cornerRadius": "100px","width": "72px","height": "72px"},{"type": "box","layout": "vertical","contents": [{"type": "text","contents": [{"type": "span","text": "My chat bot","weight": "bold","color": "#000000"},{"type": "span","text": " "},{"type": "span","text": "This is my first front end of chat bot test. The website was buit in flex message"}],"size": "sm","wrap": True},{"type": "box","layout": "baseline","contents": [{"type": "text","text": "1,140,753 Like","size": "sm","color": "#bcbcbc"}],"spacing": "sm","margin": "md"}]}],"spacing": "xl","paddingAll": "20px"}],"paddingAll": "0px"}
这里是核心 如何集成
@handler.add(MessageEvent, message=TextMessageContent)
def handle_message(event):text = event.message.textwith ApiClient(configuration) as api_client:line_bot_api = MessagingApi(api_client)# confirm templateif text=="flex-1": #url= request.url_root +'/MoreType/1.jpg'# 由于一直报错,我使用的博文中的图片。'''url= "https://i-blog.csdnimg.cn/direct/369fc618763c4e6088e5722ac5dfe340.png"app.logger.info('url='+ url)bubble= FlexBubble(direction='1tr'hero=FlexBubble(url =url,size='full',aspect_ratio='20:13',aspect_mode = 'cover',action=URIAction(uri='',label='label')),body=FlexBox(layout='vertical',contents=[#titleFlexText(text='Jasons chat bot',weight='bold',size='x1')#reviewFlexBox(layout='baseline',margin='md',content=[FlexIcon(size='sm',url="")])]))'''elif text == 'flex-2':line_flex_json={
}line_flex_str = json.dumps(line_flex_json)line_bot_api.reply_message(ReplyMessageRequest(reply_token= event.reply_token,messages=[FlexMessage(alt_text='More Detail',contents=FlexContainer.from_json(line_flex_str))]))else:line_bot_api.reply_message(ReplyMessageRequest(reply_token=event.reply_token,messages=[TextMessage(text=event.message.text)]))
执行效果:
第二段执行效果,