김예미

Edit Template, Controller 5

......@@ -3,6 +3,13 @@ let request = require('request'),
// Handles message events
exports.handleMessage = (sender_psid, received_message) => {
let response;
if(received_message.text === "처음으로"){
response = template.goToGreetTemplate(received_message);
}else{
response = template.choiceLectProfTemplate(received_message);
}
callSendAPI(sender_psid, response);
}
exports.handlePostback = (sender_psid, received_postback) => {
......@@ -21,20 +28,23 @@ exports.handlePostback = (sender_psid, received_postback) => {
handlePostback_choiceByLect(sender_psid, recieved_postback);
}else if(payload.substr(0,14) ==='CHOICE_BY_HELP'){
handlePostback_help(sender_psid, recieved_postback);
}else if(payload.substr(0,8) === 'MoreRate'){
response = template.moreRageTemplate(received_postback);
callSendAPI(sender_psid, response);
}
}
const handlePostback_choiceByProf = (sender_psid, received) => {
let response;
let stat = received.payload.substr(14);
let stat = received.payload.substr(14,6);
if(stat === 'stat_0'){
response = template.getProfNameTemplate(received);
}else if(stat === 'stat_1'){
response = template.choiceLectOfProfTemplate(received);
}else if(stat === 'stat_2'){
response = template.rateTemplate(received);
response = template.moreProfTemplate(received);
}else if(stat === 'stat_3'){
response = template.rateTemplate(received);
}
callSendAPI(sender_psid, response);
}
......@@ -42,18 +52,14 @@ const handlePostback_choiceByProf = (sender_psid, received) => {
const handlePostback_choiceByLect = (sender_psid, recieved) => {
let response;
let stat = recieved.payload.substr(14);
let stat = recieved.payload.substr(14,6);
if(stat === 'stat_0'){
response = template.getLectNameTemplate(received);
}else if(stat === 'stat_1'){
response = template.choiceLectTemplate(received);
}else if(stat === 'stat_2'){
response = template.choiceProfOfLectTemplate(received);
response = template.moreLectTemplate(received);
}else if(stat === 'stat_3'){
response = template.rateTemplate(received);
}else if(stat === 'stat_4'){
response = template.goToChoiceByProfTemplate(received);
}
callSendAPI(sender_psid, response);
}
......@@ -65,8 +71,6 @@ const handlePostback_help = (sender_psid, received) => {
if(stat === 'stat_0'){
response = template.howToTemplate(received);
}else if(stat === 'stat_1'){
response = template.goToGreetTemplate(received);
}
callSendAPI(sender_psid, response);
}
......
......@@ -31,7 +31,7 @@ exports.greetingTemplate = () => {
}
}
//payload === 'CHOICE_BY_PROF'
//stat_0
exports.getProfNameTemplate = (received) => {
return {
"attachment":{
......@@ -44,11 +44,6 @@ exports.getProfNameTemplate = (received) => {
"type":"postback",
"title":"처음으로",
"payload":'Greeting'
},
{
"type":"postback",
"title":"stat_1로",
"payload":"CHOICE_BY_PROFstat_1"
}
]
}
......@@ -56,39 +51,72 @@ exports.getProfNameTemplate = (received) => {
}
}
exports.choiceLectOfProfTemplate = (received) => {
exports.getLectNameTemplate = (received) => {
//메세지
return{text: "성공"}
}
//텍스트 메세지를 필드로 디비에서 수업/교수명 찾아서 목록 제공
exports.rateTemplate = (received) => {
//버튼
}
//payload === 'CHOICE_BY_LECT'
exports.getLectNameTemplate = (received) => {
//stat_1
exports.choiceLectProfTemplate = (received) => {
//버튼
}
exports.choiceLectTemplate= (received) => {
//메세지
//stat_2
exports.moreProfTemplate = (received) => {
//버튼
}
exports.choiceProfOfLectTemplate= (received) => {
exports.moreLectTemplate= (received) => {
//버튼
}
exports.goToChoiceByProfTemplate= (received) => {
//stat_3
exports.rateTemplate= (received) => {
//버튼
}
//payload === 'HELP'
exports.howToTemplate= (received) => {
//버튼
return {
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text": "안녕하세요. 경희대학교 컴공/소융 강의평가봇입니다. \n 자세한 사용방법은 아래를 참고하세요. \n\n 1. [교수명으로 검색], [강의명으로 검색] 중 하나를 선택한다. \n 2. 찾고자하는 강의의 교수명/강의명을 입력한다. \n 3. 입력하신 정보에 일치하는 강의/교수 목록 버튼 중 하나를 선택한다. \n 4. 강의/교수 버튼을 선택하면 해당 강의의 강의평가가 제공된다. \n 4-1. 더보기 버튼을 선택하면 해당 조건의 강의를 더 볼 수 있다. \n 5. [자세한 평보기] 버튼을 눌러 학우들의 생생한 강의평가를 자세히 본다. \n\n *언제든지 \"처음으로\"를 입력하면 첫 화면으로 돌아갑니다. \n 그럼 아래 버튼을 눌러 강의평가를 조회해보세요.",
"buttons":[
{
"type":"postback",
"title":"처음으로",
"payload":'Greeting'
}
]
}
}
}
}
exports.goToGreetTemplate = (received) => {
//버튼
return {
"attachment":{
"type":"template",
"payload":{
"template_type":"button",
"text": "",
"buttons":[
{
"type":"postback",
"title":"처음으로",
"payload":'Greeting'
}
]
}
}
}
}
exports.moreRageTemplate = (received) => {
}
\ No newline at end of file
......