Package: pylinebot
pylinebotlinebot-sdk-python wrapper.InstallpipinstallpylinebotImport, InstancefrompylinebotimportLINE,Tracerbot=LINE(channel_access_token='XXXXXXXXXXXXXXXXXXX',channel_secret='XXXXXXXXX')Example (Echo-bot)importosfromtypingimportAnyfromdotenvimportload_dotenvfromflaskimportFlask,requestfrompylinebotimportLINE,Tracerfrompylinebot.types.eventimportEvent,TracerEventfrompylinebot.types.messageimportContentType,Messagedefreceive_message(bot:LINE,event:Event.MESSAGE)->None:message:Message=event.messagemessage_type=message.typeifmessage_type==ContentType.TEXT:bot.reply_text_message(message.text)load_dotenv(verbose=True)load_dotenv(".env")CHANNEL_ACCESS_TOKEN:str=os.environ["CHANNEL_ACCESS_TOKEN"]CHANNEL_SECRET:str=os.environ["CHANNEL_SECRET"]app=Flask(__name__)bot=LINE(channel_access_token=CHANNEL_ACCESS_TOKEN,channel_secret=CHANNEL_SECRET)tracer=Tracer(bot,debug=True)tracer.add_event(TracerEvent.MESSAGE,receive_message)@app.route("/",methods=["POST"])defhello()->Any:signature=request.headers["X-Line-Signature"]body=request.get_data(as_text=True)tracer.trace(body,signature)return"OK"if__name__=="__main__":app.run(host="0.0.0.0",port=3000,debug=True)Reply MessageRefer to this:sample_op.pytexttext='test'bot.reply_text_message(text)# > testbot.reply_text_message(text,text,text)# > test# > test# > testimageimg_url='https://xxx.xxxx/xxxx.jpg'bot.reply_image_message(img_url)# > imgvideovideo_message=VideoMessage(content_url='https://xxx.xxxx/xxxx.mp4',preview_url='https://xxx.xxxx/xxxx.jpg')bot.reply_message([video_message])audioaudio_message=AudioMessage(content_url="https://xxx.xxxx/xxxx.mp3",duration=1000,)bot.reply_message([audio_message])Quick replyaction_list=[{'type':'message','label':'aaaa','text':'これ送信'},{'type':'camera','label':'かめら',},{'type':'cameraRoll','label':'かめらろーる',},{'type':'location','label':'ろけーしょん',},{'type':'postback','label':'ぽすとばっく','data':'test_postback'},{'type':'datetimepicker','label':'でーとぴっく','data':'test_datepick','mode':'date','initial':'2020-05-15','max':'2020-05-31','min':'2020-05-01'}]bot.set_quick_reply(action_list)bot.reply_text_message('quick_reply')Send multiple messagesThe max count of messages that can be sent at one time is 5.# 2 text messagebot.reply_text_message('text','text')# 5 text messagebot.reply_text_message('text','text','text','text','text')# Errorbot.reply_text_message('text','text','text','text','text','text')Send various messages at once.video_message=VideoMessage(content_url="https://xxx.xxxx/xxxx.mp4",preview_url="https://xxx.xxxx/xxxx.png",)audio_message=AudioMessage(content_url="https://xxx.xxxx/xxxx.mp3",duration=1000,)image_message=ImageMessage(preview_url="https://xxx.xxxx/xxxx.png",content_url="https://xxx.xxxx/xxxx.png",)text_message=TextMessage("test")# メッセージを詰めるmessages:List[SEND_MESSAGE]=[]messages.append(video_message)messages.append(audio_message)messages.append(image_message)messages.append(text_message)bot.reply_message(messages)Save message contentSave image, video, and audio data sent by users.bot.save_content_from_message_id(message_id,file_name)How to usefrompylinebot.types.eventimportEventfrompylinebot.types.messageimportContentTypedefreceive_message(bot:LINE,event:Event.MESSAGE)->None:message=event.messagemessage_type=message.typeifmessage_type==ContentType.IMAGE:bot.save_content_from_message_id(message_id,f"{message_id}.jpg")bot.reply_text_message("その画像","保存したよ。")