김예미

Edit Template

......@@ -5,14 +5,15 @@ let request = require('request'),
// Handles message events
exports.handleMessage = (sender_psid, received_message) => {
let response;
let payload = recieved_message.payload;
if(received_message.text){
response = template.messageTemplate();
if(payload === 'CHOICE_BY_PROF'){
handlePostback_choiceByProf(sender_psid, received_message);
}else if(payload === 'CHOICE_BY_LECT'){
handlePostback_choiceByLect(sender_psid, recieved_message);
}else if(payload === 'HELP'){
handlePostback_help(sender_psid, recieved_message);
}
// Sends the reponse message
callSendAPI(sender_psid, response);
}
exports.handlePostback = (sender_psid, received_postback) => {
......@@ -26,20 +27,60 @@ exports.handlePostback = (sender_psid, received_postback) => {
response = template.greetingTemplate();
callSendAPI(sender_psid, response);
}else if(payload === 'CHOICE_BY_PROF'){
response = template.choicebyprofTemplate();
callSendAPI(sender_psid, response);
handlePostback_choiceByProf(sender_psid, received_postback);
}else if(payload === 'CHOICE_BY_LECT'){
response = template.choicebylectTemplate();
callSendAPI(sender_psid, response);
handlePostback_choiceByLect(sender_psid, recieved_postback);
}else if(payload === 'HELP'){
response = template.help();
callSendAPI(sender_psid, response);
}else if(payload.match('rate')){
response = template.rate(payload);
callSendAPI(sender_psid, response);
handlePostback_help(sender_psid, recieved_postback);
}
}
const handlePostback_choiceByProf = (sender_psid, received) => {
let response;
let stat = received.stat;
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);
}
callSendAPI(sender_psid, response);
}
const handlePostback_choiceByLect = (sender_psid, recieved) => {
let response;
let stat = recieved.stat;
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);
}else if(stat === 'stat_3'){
response = template.rateTemplate(received);
}else if(stat === 'stat_4'){
response = template.goToChoiceByProfTemplate(received);
}
callSendAPI(sender_psid, response);
}
const handlePostback_help = (sender_psid, received) => {
let response;
let stat = received.stat;
if(stat === 'stat_0'){
response = template.howToTemplate(received);
}else if(stat ==== 'stat_1'){
response = template.goToGreetTemplate(received);
}
callSendAPI(sender_psid, response);
}
// Sends response messages via the Send API
const callSendAPI = (sender_psid, response, cb = null) => {
......
let images = require("./pics");
exports.messageTemplate = (text) => {
//메세지
}
let greetingText = "안녕하세요! 컴공/소융 강의평가 봇이에요. 아래에 버튼 3개를 눌러주세요."; // 인사말
let greetingTitle = ["교수명으로 검색", "강의명으로 검색", "HELP"];
......@@ -19,17 +13,23 @@ exports.greetingTemplate = () => {
{
"type":"postback",
"title":greetingTitle[0],
"payload":"CHOICE_BY_PROF"
"payload":"CHOICE_BY_PROF",
"stat":"stat_0",
"rate":{};
},
{
"type":"postback",
"title":greetingTitle[1],
"payload":"CHOICE_BY_LECT"
"stat":"stat_0",
"rate":{};
},
{
"type":"postback",
"title":greetingTitle[2],
"payload":"HELP"
"stat":"stat_0",
"rate":{};
}
]
}
......@@ -37,70 +37,46 @@ exports.greetingTemplate = () => {
}
}
exports.choicebyprofTemplate = () => {
return {text: "교수명을 입력하세요."};
//교수님 성함 사용자 입력 받기
//교수님 목록 띄우기_버튼
//강의명 목록 띄우기_버튼
//->강의평가 띄우기
}
//payload === 'CHOICE_BY_PROF'
exports.getProfNameTemplate = (received) => {
exports.choicebylectTemplate = () => {
//강의명 사용자 입력 받기
//일치하는 강의 없으면 추측 강의 목록 띄우기_버튼
//max n개 강의 목록 띄우기_버튼
//->그 중에 없으면 교수명 입력으로
//->있으면 강의평가 띄우기
}
exports.help = () => {
//소개, 뒤로가기
}
exports.choiceLectOfProfTemplate = (received) => {
exports.rate = (payload) => {
return {text:"강의평가입니다."};
//강의평가
}
exports.rateTemplate = (received) => {
}
//payload === 'CHOICE_BY_LECT'
exports.getLectNameTemplate = (received) => {
}
exports.choiceLectTemplate= (received) => {
}
exports.choiceProfOfLectTemplate= (received) => {
}
exports.rateTemplate= (received) => {
}
exports.goToChoiceByProfTemplate= (received) => {
}
let users = {};
const getImage= (type, sender_id) => {
// create user if doesn't exist
if(users[sender_id] === undefined){
users = Object.assign({
[sender_id] : {
'cats_count' : 0,
'dogs_count' : 0
}
}, users);
}
let count = images[type].length, // total available images by type
user = users[sender_id], // // user requesting image
user_type_count = user[type+'_count'];
//payload === 'HELP'
exports.howToTemplate= (received) => {
}
// update user before returning image
let updated_user = {
[sender_id] : Object.assign(user, {
[type+'_count'] : count === user_type_count + 1 ? 0 : user_type_count + 1
})
};
// update users
users = Object.assign(users, updated_user);
exports.goToGreetTemplate = (received) => {
console.log(users);
return images[type][user_type_count];
}
......