def PatternCon(userid,event,findm,ques,user): if findquestion(userid) == 'ต้องการอ่านเนื้อหาหนังเรื่องนี้ไหมครับ': question ='อยากอ่านเรื่องย่อ' if 'ต้องการ' == event.message.text : detail = movie_detail(event, findm, question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) user.insert({"UserId": userid, "NameMovie": findm, "Cate": '5', "Question": question, "Answer": detail, "Time": datetime.now()}) elif 'ไม่' in event.message.text: detail ='แล้วต้องการอ่าน บทรีวิว ไหมล่ะ' line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) user.insert({"UserId": userid, "NameMovie": findm, "Cate": '12', "Question": event.message.text, "Answer": detail, "Time": datetime.now()}) else: return ques elif findquestion(userid) =="แล้วต้องการอ่าน บทรีวิว ไหมล่ะ": question = 'รีวิวหน่อย' if 'ต้องการ'== event.message.text: detail = movie_review(event, findm, question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) user.insert({"UserId": userid, "NameMovie": findm, "Cate": '3', "Question": question, "Answer": detail, "Time": datetime.now()}) elif 'ไม่' in event.message.text: detail = 'แล้วอยากอ่านอะไรละเรามีข้อมูล เรื่องย่อ บทรีวิว นักแสดง ชื่อนักแสดง ชื่อผู้กำกับ และ สปอย' line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) user.insert({"UserId": userid, "NameMovie":findm, "Cate": '12', "Question": event.message.text, "Answer": detail, "Time": datetime.now()}) else: return ques else: return ques
def Type(q, event, movie_name, userid, user, question, name): if q == 0: #actor if name != '' and q != 9 and q != 8: detail = movie_actor(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_actor(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_actor(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": 'Actor', "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": 'Actor', "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": 'Actor', "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": 'Actor', "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 1: #"director" if name != '' and q != 9 and q != 8: detail = movie_director(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_director(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_director(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "director", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "director", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "director", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "director", "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 2: #"image" if name != '' and q != 9 and q != 8: detail = movie_image(event, question, userid) image_message = ImageSendMessage(original_content_url=detail, preview_image_url=detail) line_bot_api.push_message(userid, image_message) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_image(event, question, userid) image_message = ImageSendMessage(original_content_url=detail, preview_image_url=detail) line_bot_api.push_message(userid, image_message) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_image(event, question, userid) image_message = ImageSendMessage(original_content_url=detail, preview_image_url=detail) line_bot_api.push_message(userid, image_message) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "image", "Question": question, "Answer": 'รูปภาพ' + movie_name, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "image", "Question": question, "Answer": 'รูปภาพ' + name, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "image", "Question": question, "Answer": 'รูปภาพ' + movie_name, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "image", "Question": question, "Answer": 'รูปภาพ' + findmovie(userid), "Time": datetime.now() }) if q == 3: #"review" if name != '' and q != 9 and q != 8: detail = movie_review(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_review(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_review(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "review", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "review", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "review", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "review", "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 4: #"spoil" if name != '' and q != 9 and q != 8: detail = movie_spoil(event, question, userid) print(detail) if len(detail) > 1999 and len(detail) < 4000: line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[0:1998])) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[1999:])) elif len(detail) >= 4000: line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[0:1998])) line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[1999:3998])) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[3999:])) elif len(detail) < 2000: line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_spoil(event, question, userid) if len(detail) > 1999 and len(detail) < 4000: line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[0:1998])) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[1999:])) elif len(detail) >= 4000: line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[0:1998])) line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[1999:3998])) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[3999:])) elif len(detail) < 2000: line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_spoil(event, question, userid) if len(detail) > 1999 and len(detail) < 4000: line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[0:1998])) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[1999:])) elif len(detail) >= 4000: line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[0:1998])) line_bot_api.reply_message( event.reply_token, TextSendMessage(text=detail[1999:3998])) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[3999:])) elif len(detail) < 2000: line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "spoil", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "spoil", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "spoil", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "spoil", "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 5: #"detail" if name != '' and q != 9 and q != 8: detail = movie_detail(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_detail(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_detail(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "detail", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "detail", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "detail", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "detail", "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 6: #"date" if name != '' and q != 9 and q != 8: detail = movie_date(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_date(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_date(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "date", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "date", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "date", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "date", "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 7: #"type" if name != '' and q != 9 and q != 8: detail = movie_type(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9 and q != 8: detail = movie_type(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9 and q != 8: detail = movie_type(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) if q == 8: # if 'สนุก' in question: if name != '' and q != 9: detail = movie_enjoy(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name != '') and q != 9: detail = movie_enjoy(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (movie_name == '') and q != 9: detail = movie_enjoy(event, question, userid) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name == '') and (movie_name != ''): user.insert({ "UserId": userid, "NameMovie": movie_name, "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name == '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) elif (movie_name != '') and (name != ''): user.insert({ "UserId": userid, "NameMovie": name, "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) else: user.insert({ "UserId": userid, "NameMovie": findmovie(userid), "Cate": "type", "Question": question, "Answer": detail, "Time": datetime.now() }) elif 'แนะนำหนัง' in question: 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)
def Type(clas, event, chec, userid, user, question,name,findm): moviename = searchMovie(chec) if clas == '0' : #actor if name != '' : detail = movie_actor(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != '') : detail = movie_actor(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == ''): detail = movie_actor(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!='') : user.insert( {"UserId": userid, "NameMovie": moviename, "Cate": '0', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert( {"UserId": userid, "NameMovie": name, "Cate": '0', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec != '') and (name != ''): user.insert( {"UserId": userid, "NameMovie": moviename, "Cate": '0', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert( {"UserId": userid, "NameMovie": findm, "Cate": '0', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '1':#"director" if name != '' : detail = movie_director(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != ''): detail = movie_director(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == '') : detail = movie_director(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!=''): user.insert( {"UserId": userid, "NameMovie": moviename, "Cate": '1', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert( {"UserId": userid, "NameMovie": name, "Cate": '1', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec != '') and (name != ''): user.insert( {"UserId": userid, "NameMovie": moviename, "Cate": '1', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert( {"UserId": userid, "NameMovie": findm, "Cate": '1', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '2':#"image" try: if name != '' : detail = movie_image(event,findm,question) image_message = ImageSendMessage( original_content_url=detail, preview_image_url=detail ) line_bot_api.push_message(userid,image_message) elif (name == '') and (chec != '') : detail = movie_image(event,findm,question) image_message = ImageSendMessage( original_content_url=detail, preview_image_url=detail ) line_bot_api.push_message(userid, image_message) elif (name == '') and (chec == '') : detail = movie_image(event,findm,question) image_message = ImageSendMessage( original_content_url=detail, preview_image_url=detail ) line_bot_api.push_message(userid, image_message) except: detail = movie_image(event, findm, question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '2', "Question": question, "Answer": 'รูปภาพ'+chec, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '2', "Question": question, "Answer": 'รูปภาพ'+name, "Time": datetime.now()}) elif (chec !='')and(name !=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '2', "Question": question, "Answer": 'รูปภาพ'+chec, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie":findm, "Cate": '2', "Question": question, "Answer": 'รูปภาพ'+findm, "Time": datetime.now()}) if clas == '3':#"review" if name != '': detail = movie_review(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != '') : detail = movie_review(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == '') : detail = movie_review(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '3', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '3', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec !='')and(name !=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '3', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie":findm, '3': "review", "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '4': #"spoil" if name != '' : detail = movie_spoil(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[0:1998])) elif (name == '') and (chec != '') : detail = movie_spoil(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[0:1998])) elif (name == '') and (chec == '') : detail = movie_spoil(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[0:1998])) if (name =='')and (chec!=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '4', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '4', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec !='')and(name !=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '4', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie":findm, "Cate": '4', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '5': #"detail" if name != '': detail = movie_detail(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != '') : detail = movie_detail(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == '') : detail = movie_detail(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '5', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '5', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec !='')and(name !=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '5', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie": findm, "Cate": '5', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '6': #"date" if name != '' : detail = movie_date(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != '') : detail = movie_date(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == '') : detail = movie_date(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '6', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '6', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec !='')and(name !=''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '6', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie": findm, "Cate":'6', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '7': #"type" if name != '' : detail = movie_type(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != '') : detail = movie_type(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == '') : detail = movie_type(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!='') : user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '7', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (clas =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '7', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec != '') and (name != ''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '7', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie": findm, "Cate": '7', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '8': line_bot_api.reply_message(event.reply_token, TextSendMessage(text='เราสามารถถาม เกี่ยวกับ ผู้กำกับ นักแสดง รีวิว สปอย แนะนำหนัง รูปภาพ เวลาฉาย ประเภท ของหนังแต่ละเรื่องได้นะได้นะ')) if clas == '9': message = TemplateSendMessage( alt_text='Carousel template', template=CarouselTemplate( columns=[ CarouselColumn( title='ตัวอย่างการสนทนาในแต่ละประเภท', text='ถามเกี่ยวกับ', actions=[ MessageTemplateAction( label='นักแสดง', text='ใครเป็นนักแสดง wonderwoman' ), MessageTemplateAction( label='ผู้กำกับ', text='ใครเป็นผู้กำกับวันเดอวูแมน' ), MessageTemplateAction( label='รูปภาพ', text='อยากดูรูปภาพwonderwoman' ) ] ), CarouselColumn( title='ตัวอย่างการสนทนาในแต่ละประเภท', text='ถามเกี่ยวกับ', actions=[ MessageTemplateAction( label='รีวิว', text='อยากอ่านรีวิวwonderwoman' ), MessageTemplateAction( label='สปอย', text='อยากดูสปอยwonderwoman' ), MessageTemplateAction( label='เรื่องย่อภาพยนตร์', text='อยากอ่านเรื่องย่อwonderwoman' ) ] ), CarouselColumn( title='ตัวอย่างการสนทนาในแต่ละประเภท', text='ถามเกี่ยวกับ', actions=[ MessageTemplateAction( label='ประเภทหนัง', text='wonderwonเป็นหนังประเภทอะไร' ), MessageTemplateAction( label='วันฉายภาพยนตร์', text='wonderwomanฉายวันไหน' ), MessageTemplateAction( label='ความสนุก', text='wonderwomanสนุกไหม' ) ] ), CarouselColumn( title='ตัวอย่างการสนทนาในแต่ละประเภท', text='ถามเกี่ยวกับ', actions=[ MessageTemplateAction( label='แนะนำภาพยนตร์', text='แนะนำหนังหน่อย' ), MessageTemplateAction( label='การทักทายทั่วไป', text='สบายดีไหม' ), MessageTemplateAction( label='-', text='-' ) ] ) ] ) ) line_bot_api.reply_message(event.reply_token, message) if clas =='10': a = [] d = [] f = [] for i in range(6): b = searchpic()[0] a.append(b) c = searchpic()[1] d.append(c) e = searchpic()[2] f.append(e) message = TemplateSendMessage( alt_text='Carousel template', template=CarouselTemplate( columns=[ CarouselColumn( thumbnail_image_url=a[0], title=d[0], text=f[0], actions=[ MessageTemplateAction( label='เรื่องย่อ', text='เรื่องย่อ'+(d[0]) ), MessageTemplateAction( label='บทรีวิว', text='บทรีวิว'+(d[0]) ), URITemplateAction( label='website', uri='http://mandm.plearnjai.com/' ) ] ), CarouselColumn( thumbnail_image_url=a[1], title=d[1], text=f[1], actions=[ MessageTemplateAction( label='เรื่องย่อ', text='เรื่องย่อ'+(d[1]) ), MessageTemplateAction( label='บทรีวิว', text='บทรีวิว'+(d[1]) ), URITemplateAction( label='website', uri='http://mandm.plearnjai.com/' ) ] ), CarouselColumn( thumbnail_image_url=a[2], title=d[2], text=f[2], actions=[ MessageTemplateAction( label='เรื่องย่อ', text='เรื่องย่อ'+(d[2]) ), MessageTemplateAction( label='บทรีวิว', text='บทรีวิว'+(d[2]) ), URITemplateAction( label='website', uri='http://mandm.plearnjai.com/' ) ] ), CarouselColumn( thumbnail_image_url=a[3], title=d[3], text=f[3], actions=[ MessageTemplateAction( label='เรื่องย่อ', text='เรื่องย่อ'+(d[3]) ), MessageTemplateAction( label='บทรีวิว', text='บทรีวิว'+(d[3]) ), URITemplateAction( label='website', uri='http://mandm.plearnjai.com/' ) ] ), CarouselColumn( thumbnail_image_url=a[4], title=d[4], text=f[4], actions=[ MessageTemplateAction( label='เรื่องย่อ', text='เรื่องย่อ'+(d[4]) ), MessageTemplateAction( label='บทรีวิว', text='บทรีวิว'+(d[4]) ), URITemplateAction( label='website', uri='http://mandm.plearnjai.com/' ) ] ) ] ) ) line_bot_api.reply_message(event.reply_token, message) return 0 if clas =='11': if name != '' and clas != 9 : detail = movie_enjoy(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec != '') : detail = movie_enjoy(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) elif (name == '') and (chec == '') : detail = movie_enjoy(event,findm,question) line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail)) if (name =='')and (chec!='') : user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '8', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec =='')and(name !=''): user.insert({"UserId": userid, "NameMovie": name, "Cate": '8', "Question": question, "Answer": detail, "Time": datetime.now()}) elif (chec != '') and (name != ''): user.insert({"UserId": userid, "NameMovie": moviename, "Cate": '8', "Question": question, "Answer": detail, "Time": datetime.now()}) else: user.insert({"UserId": userid, "NameMovie": findmovie(userid), "Cate": '8', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '13': line_bot_api.reply_message(event.reply_token, TextSendMessage(text='อย่าพิมพ์มั่วดิ')) if clas == '14': line_bot_api.reply_message(event.reply_token, TextSendMessage(text='พิมพ์มาใหม่')) if clas == '15': # detail = checkmoiveEn() line_bot_api.reply_message(event.reply_token, TextSendMessage(text=detail[0:1999])) user.insert( {"UserId": userid, "NameMovie": findm, "Cate": '15', "Question": question, "Answer": detail, "Time": datetime.now()}) if clas == '16': if findm!='': line_bot_api.reply_message(event.reply_token, TextSendMessage(text=findm)) user.insert( {"UserId": userid, "NameMovie": findm, "Cate": '16', "Question": question, "Answer": findm, "Time": datetime.now()}) else: detail ='ยังไม่ได้พูดถึงเรื่องไหนเลยนะ' line_bot_api.reply_message(event.reply_token, TextSendMessage(text='ยังไม่ได้พูดถึงเรื่องไหนเลยนะ')) user.insert( {"UserId": userid, "NameMovie": '', "Cate": '16', "Question": question, "Answer": detail, "Time": datetime.now()})