Showing
2 changed files
with
61 additions
and
29 deletions
... | @@ -3,6 +3,13 @@ let request = require('request'), | ... | @@ -3,6 +3,13 @@ let request = require('request'), |
3 | 3 | ||
4 | // Handles message events | 4 | // Handles message events |
5 | exports.handleMessage = (sender_psid, received_message) => { | 5 | exports.handleMessage = (sender_psid, received_message) => { |
6 | + let response; | ||
7 | + if(received_message.text === "처음으로"){ | ||
8 | + response = template.goToGreetTemplate(received_message); | ||
9 | + }else{ | ||
10 | + response = template.choiceLectProfTemplate(received_message); | ||
11 | + } | ||
12 | + callSendAPI(sender_psid, response); | ||
6 | } | 13 | } |
7 | 14 | ||
8 | exports.handlePostback = (sender_psid, received_postback) => { | 15 | exports.handlePostback = (sender_psid, received_postback) => { |
... | @@ -21,19 +28,22 @@ exports.handlePostback = (sender_psid, received_postback) => { | ... | @@ -21,19 +28,22 @@ exports.handlePostback = (sender_psid, received_postback) => { |
21 | handlePostback_choiceByLect(sender_psid, recieved_postback); | 28 | handlePostback_choiceByLect(sender_psid, recieved_postback); |
22 | }else if(payload.substr(0,14) ==='CHOICE_BY_HELP'){ | 29 | }else if(payload.substr(0,14) ==='CHOICE_BY_HELP'){ |
23 | handlePostback_help(sender_psid, recieved_postback); | 30 | handlePostback_help(sender_psid, recieved_postback); |
31 | + }else if(payload.substr(0,8) === 'MoreRate'){ | ||
32 | + response = template.moreRageTemplate(received_postback); | ||
33 | + callSendAPI(sender_psid, response); | ||
24 | } | 34 | } |
25 | } | 35 | } |
26 | 36 | ||
27 | const handlePostback_choiceByProf = (sender_psid, received) => { | 37 | const handlePostback_choiceByProf = (sender_psid, received) => { |
28 | let response; | 38 | let response; |
29 | 39 | ||
30 | - let stat = received.payload.substr(14); | 40 | + let stat = received.payload.substr(14,6); |
31 | 41 | ||
32 | if(stat === 'stat_0'){ | 42 | if(stat === 'stat_0'){ |
33 | response = template.getProfNameTemplate(received); | 43 | response = template.getProfNameTemplate(received); |
34 | - }else if(stat === 'stat_1'){ | ||
35 | - response = template.choiceLectOfProfTemplate(received); | ||
36 | }else if(stat === 'stat_2'){ | 44 | }else if(stat === 'stat_2'){ |
45 | + response = template.moreProfTemplate(received); | ||
46 | + }else if(stat === 'stat_3'){ | ||
37 | response = template.rateTemplate(received); | 47 | response = template.rateTemplate(received); |
38 | } | 48 | } |
39 | callSendAPI(sender_psid, response); | 49 | callSendAPI(sender_psid, response); |
... | @@ -42,18 +52,14 @@ const handlePostback_choiceByProf = (sender_psid, received) => { | ... | @@ -42,18 +52,14 @@ const handlePostback_choiceByProf = (sender_psid, received) => { |
42 | const handlePostback_choiceByLect = (sender_psid, recieved) => { | 52 | const handlePostback_choiceByLect = (sender_psid, recieved) => { |
43 | let response; | 53 | let response; |
44 | 54 | ||
45 | - let stat = recieved.payload.substr(14); | 55 | + let stat = recieved.payload.substr(14,6); |
46 | 56 | ||
47 | if(stat === 'stat_0'){ | 57 | if(stat === 'stat_0'){ |
48 | response = template.getLectNameTemplate(received); | 58 | response = template.getLectNameTemplate(received); |
49 | - }else if(stat === 'stat_1'){ | ||
50 | - response = template.choiceLectTemplate(received); | ||
51 | }else if(stat === 'stat_2'){ | 59 | }else if(stat === 'stat_2'){ |
52 | - response = template.choiceProfOfLectTemplate(received); | 60 | + response = template.moreLectTemplate(received); |
53 | }else if(stat === 'stat_3'){ | 61 | }else if(stat === 'stat_3'){ |
54 | response = template.rateTemplate(received); | 62 | response = template.rateTemplate(received); |
55 | - }else if(stat === 'stat_4'){ | ||
56 | - response = template.goToChoiceByProfTemplate(received); | ||
57 | } | 63 | } |
58 | callSendAPI(sender_psid, response); | 64 | callSendAPI(sender_psid, response); |
59 | } | 65 | } |
... | @@ -65,8 +71,6 @@ const handlePostback_help = (sender_psid, received) => { | ... | @@ -65,8 +71,6 @@ const handlePostback_help = (sender_psid, received) => { |
65 | 71 | ||
66 | if(stat === 'stat_0'){ | 72 | if(stat === 'stat_0'){ |
67 | response = template.howToTemplate(received); | 73 | response = template.howToTemplate(received); |
68 | - }else if(stat === 'stat_1'){ | ||
69 | - response = template.goToGreetTemplate(received); | ||
70 | } | 74 | } |
71 | callSendAPI(sender_psid, response); | 75 | callSendAPI(sender_psid, response); |
72 | } | 76 | } | ... | ... |
... | @@ -31,7 +31,7 @@ exports.greetingTemplate = () => { | ... | @@ -31,7 +31,7 @@ exports.greetingTemplate = () => { |
31 | } | 31 | } |
32 | } | 32 | } |
33 | 33 | ||
34 | -//payload === 'CHOICE_BY_PROF' | 34 | +//stat_0 |
35 | exports.getProfNameTemplate = (received) => { | 35 | exports.getProfNameTemplate = (received) => { |
36 | return { | 36 | return { |
37 | "attachment":{ | 37 | "attachment":{ |
... | @@ -44,11 +44,6 @@ exports.getProfNameTemplate = (received) => { | ... | @@ -44,11 +44,6 @@ exports.getProfNameTemplate = (received) => { |
44 | "type":"postback", | 44 | "type":"postback", |
45 | "title":"처음으로", | 45 | "title":"처음으로", |
46 | "payload":'Greeting' | 46 | "payload":'Greeting' |
47 | - }, | ||
48 | - { | ||
49 | - "type":"postback", | ||
50 | - "title":"stat_1로", | ||
51 | - "payload":"CHOICE_BY_PROFstat_1" | ||
52 | } | 47 | } |
53 | ] | 48 | ] |
54 | } | 49 | } |
... | @@ -56,39 +51,72 @@ exports.getProfNameTemplate = (received) => { | ... | @@ -56,39 +51,72 @@ exports.getProfNameTemplate = (received) => { |
56 | } | 51 | } |
57 | } | 52 | } |
58 | 53 | ||
59 | -exports.choiceLectOfProfTemplate = (received) => { | 54 | +exports.getLectNameTemplate = (received) => { |
60 | //메세지 | 55 | //메세지 |
61 | return{text: "성공"} | 56 | return{text: "성공"} |
62 | 57 | ||
63 | -} | 58 | + //텍스트 메세지를 필드로 디비에서 수업/교수명 찾아서 목록 제공 |
64 | 59 | ||
65 | -exports.rateTemplate = (received) => { | ||
66 | -//버튼 | ||
67 | } | 60 | } |
68 | 61 | ||
69 | -//payload === 'CHOICE_BY_LECT' | 62 | +//stat_1 |
70 | -exports.getLectNameTemplate = (received) => { | 63 | +exports.choiceLectProfTemplate = (received) => { |
71 | //버튼 | 64 | //버튼 |
72 | } | 65 | } |
73 | 66 | ||
74 | -exports.choiceLectTemplate= (received) => { | 67 | +//stat_2 |
75 | -//메세지 | 68 | +exports.moreProfTemplate = (received) => { |
69 | +//버튼 | ||
76 | } | 70 | } |
77 | 71 | ||
78 | -exports.choiceProfOfLectTemplate= (received) => { | 72 | +exports.moreLectTemplate= (received) => { |
79 | //버튼 | 73 | //버튼 |
80 | } | 74 | } |
81 | 75 | ||
82 | -exports.goToChoiceByProfTemplate= (received) => { | 76 | +//stat_3 |
77 | +exports.rateTemplate= (received) => { | ||
83 | //버튼 | 78 | //버튼 |
84 | } | 79 | } |
85 | 80 | ||
86 | //payload === 'HELP' | 81 | //payload === 'HELP' |
87 | exports.howToTemplate= (received) => { | 82 | exports.howToTemplate= (received) => { |
88 | -//버튼 | 83 | +return { |
84 | + "attachment":{ | ||
85 | + "type":"template", | ||
86 | + "payload":{ | ||
87 | + "template_type":"button", | ||
88 | + "text": "안녕하세요. 경희대학교 컴공/소융 강의평가봇입니다. \n 자세한 사용방법은 아래를 참고하세요. \n\n 1. [교수명으로 검색], [강의명으로 검색] 중 하나를 선택한다. \n 2. 찾고자하는 강의의 교수명/강의명을 입력한다. \n 3. 입력하신 정보에 일치하는 강의/교수 목록 버튼 중 하나를 선택한다. \n 4. 강의/교수 버튼을 선택하면 해당 강의의 강의평가가 제공된다. \n 4-1. 더보기 버튼을 선택하면 해당 조건의 강의를 더 볼 수 있다. \n 5. [자세한 평보기] 버튼을 눌러 학우들의 생생한 강의평가를 자세히 본다. \n\n *언제든지 \"처음으로\"를 입력하면 첫 화면으로 돌아갑니다. \n 그럼 아래 버튼을 눌러 강의평가를 조회해보세요.", | ||
89 | + "buttons":[ | ||
90 | + { | ||
91 | + "type":"postback", | ||
92 | + "title":"처음으로", | ||
93 | + "payload":'Greeting' | ||
94 | + } | ||
95 | + ] | ||
96 | + } | ||
97 | + } | ||
98 | + } | ||
89 | } | 99 | } |
90 | 100 | ||
91 | exports.goToGreetTemplate = (received) => { | 101 | exports.goToGreetTemplate = (received) => { |
92 | -//버튼 | 102 | +return { |
103 | + "attachment":{ | ||
104 | + "type":"template", | ||
105 | + "payload":{ | ||
106 | + "template_type":"button", | ||
107 | + "text": "", | ||
108 | + "buttons":[ | ||
109 | + { | ||
110 | + "type":"postback", | ||
111 | + "title":"처음으로", | ||
112 | + "payload":'Greeting' | ||
113 | + } | ||
114 | + ] | ||
115 | + } | ||
116 | + } | ||
117 | + } | ||
93 | } | 118 | } |
94 | 119 | ||
120 | +exports.moreRageTemplate = (received) => { | ||
121 | + | ||
122 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment