이혜인

add link

...@@ -31,6 +31,7 @@ exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL; ...@@ -31,6 +31,7 @@ exports.MEGA_PlayingMovieURL = MEGA_PlayingMovieURL;
31 31
32 let MEGA_flag = 0; 32 let MEGA_flag = 0;
33 33
34 +
34 function SendMessage(eventObj, text1, text2 = ""){ 35 function SendMessage(eventObj, text1, text2 = ""){
35 request.post( 36 request.post(
36 { 37 {
...@@ -81,6 +82,113 @@ request.post( ...@@ -81,6 +82,113 @@ request.post(
81 }); 82 });
82 } 83 }
83 84
85 +function PusbuttonhMessage(final_URL){
86 + request.post(
87 + {
88 + url: PUSH_TARGET_URL,
89 + headers: {
90 + 'Authorization': `Bearer ${TOKEN}`
91 + },
92 + json:
93 +
94 + { "to": `${USER_ID}`,
95 + "type": "template",
96 + "altText": "this is a carousel template",
97 + "template": {
98 + "type": "carousel",
99 + "columns": [
100 + {
101 + "thumbnailImageUrl": "https://megabox.co.kr/SharedImg/2022/05/16/WApIttC9CrStYU7j7jzFRlc2HsIXBQtY_150.jpg",
102 + "imageBackgroundColor": "#FFFFFF",
103 + "title": "this is menu",
104 + "text": "description",
105 + "defaultAction": {
106 + "type": "uri",
107 + "label": "View detail",
108 + "uri": "https://megabox.co.kr/"
109 + },
110 + "actions": [
111 + {
112 + "type":"message",
113 + "label":"Yes",
114 + "text":"Yes"
115 + },
116 + {
117 + "type":"message",
118 + "label":"Yes",
119 + "text":"Yes"
120 + },
121 + {
122 + "type": "uri",
123 + "label": "View detail",
124 + "uri": "https://megabox.co.kr/"
125 + }
126 + ]
127 + },
128 +
129 + {
130 + "thumbnailImageUrl": "https://example.com/bot/images/item2.jpg",
131 + "imageBackgroundColor": "#000000",
132 + "title": "this is menu",
133 + "text": "description",
134 + "defaultAction": {
135 + "type": "uri",
136 + "label": "View detail",
137 + "uri": "http://example.com/page/222"
138 + },
139 + "actions": [
140 + {
141 + "type":"message",
142 + "label":"Yes",
143 + "text":"Yes"
144 +
145 + },
146 + {
147 + "type":"message",
148 + "label":"Yes",
149 + "text":"Yes"
150 +
151 + },
152 + {
153 + "type": "uri",
154 + "label": "View detail",
155 + "uri": "https://megabox.co.kr/"
156 + }
157 + ]
158 + }
159 + ],
160 + "imageAspectRatio": "rectangle",
161 + "imageSize": "cover"
162 + }
163 + }
164 + // {
165 + // "type": "template",
166 + // //"altText": "This is a buttons template",
167 + // "template": {
168 + // "type": "buttons",
169 + // "thumbnailImageUrl": "https://megabox.co.kr/SharedImg/2022/05/16/WApIttC9CrStYU7j7jzFRlc2HsIXBQtY_150.jpg",
170 + // "imageAspectRatio": "rectangle",
171 + // "imageSize": "cover",
172 + // "imageBackgroundColor": "#FFFFFF",
173 + // "title": "Menu",
174 + // "text": "Please select",
175 + // "actions": [
176 + // {
177 + // "type": "message",
178 + // "label": "Yes",
179 + // "text": "yes"
180 + // },
181 + // {
182 + // "type": "uri",
183 + // "label": "View detail",
184 + // "uri": final_URL
185 + // }
186 + // ]
187 + // }
188 + //}
189 + }
190 + )}
191 +
84 app.post('/hook', (req, res) => { 192 app.post('/hook', (req, res) => {
85 193
86 var eventObj = req.body.events[0]; 194 var eventObj = req.body.events[0];
...@@ -93,11 +201,13 @@ app.post('/hook', (req, res) => { ...@@ -93,11 +201,13 @@ app.post('/hook', (req, res) => {
93 console.log('[request source] ', eventObj.source); 201 console.log('[request source] ', eventObj.source);
94 console.log('[request message]', eventObj.message); 202 console.log('[request message]', eventObj.message);
95 203
204 +
96 if(eventObj.message.text == 3 && MEGA_flag === 0){ 205 if(eventObj.message.text == 3 && MEGA_flag === 0){
97 const text1 = "영화관 위치를 입력해주세요"; 206 const text1 = "영화관 위치를 입력해주세요";
98 const text2 = "ex1)강남"; 207 const text2 = "ex1)강남";
99 SendMessage(eventObj, text1, text2); 208 SendMessage(eventObj, text1, text2);
100 MEGA_flag++; 209 MEGA_flag++;
210 + PusbuttonhMessage("https://developers.line.biz/en/reference/messaging-api/#message-common-properties");
101 console.log(MEGA_flag) 211 console.log(MEGA_flag)
102 } 212 }
103 213
...@@ -138,22 +248,24 @@ app.post('/hook', (req, res) => { ...@@ -138,22 +248,24 @@ app.post('/hook', (req, res) => {
138 } 248 }
139 249
140 if(MEGA_flag===4){ 250 if(MEGA_flag===4){
141 - let index = 0; 251 +
252 + let obj = {};
142 let n; 253 let n;
143 let PlayingMovie = "-현재 상영작-\n\n"; 254 let PlayingMovie = "-현재 상영작-\n\n";
144 const text1 = "현재상영작을 가져오는 중입니다."; 255 const text1 = "현재상영작을 가져오는 중입니다.";
145 const text2 = "잠시만 기다려주세요."; 256 const text2 = "잠시만 기다려주세요.";
146 PushMessage(eventObj, text1, text2); 257 PushMessage(eventObj, text1, text2);
147 setTimeout(function() { 258 setTimeout(function() {
148 - 259 + let movietitle;
149 console.log(megabox.movie_data); 260 console.log(megabox.movie_data);
150 for(n = 0; n<Object.keys(megabox.movie_data).length; n++){ 261 for(n = 0; n<Object.keys(megabox.movie_data).length; n++){
151 if(megabox.movie_data[n].running==='Y'){ 262 if(megabox.movie_data[n].running==='Y'){
152 console.log(megabox.movie_data[n]); 263 console.log(megabox.movie_data[n]);
153 - MEGA_PlayingMovieList[index++] = megabox.movie_data[n].title; 264 + movietitle = megabox.movie_data[n].title;
265 + MEGA_PlayingMovieList[movietitle] = megabox.movie_data[n].movie_num;
154 } 266 }
155 - n++;
156 } 267 }
268 + console.log(MEGA_PlayingMovieList);
157 269
158 if(MEGA_PlayingMovieList.length == 0){ 270 if(MEGA_PlayingMovieList.length == 0){
159 SendMessage(eventObj, "현재상영작이 없습니다.",""); 271 SendMessage(eventObj, "현재상영작이 없습니다.","");
...@@ -162,10 +274,10 @@ app.post('/hook', (req, res) => { ...@@ -162,10 +274,10 @@ app.post('/hook', (req, res) => {
162 SendMessage(eventObj, MEGA_PlayingMovieList[0],""); 274 SendMessage(eventObj, MEGA_PlayingMovieList[0],"");
163 } 275 }
164 else{ 276 else{
165 - index = 0; 277 + let index = 0;
166 - for(let playingmovie = 0; playingmovie < MEGA_PlayingMovieList.length; playingmovie++) 278 + for(let playingmovie = 0; playingmovie < Object.keys(MEGA_PlayingMovieList).length; playingmovie++)
167 { 279 {
168 - PlayingMovie += (playingmovie+1).toString()+'. ' + MEGA_PlayingMovieList[playingmovie]; 280 + PlayingMovie += (playingmovie+1).toString()+'. ' + Object.keys(MEGA_PlayingMovieList)[index++];
169 PlayingMovie +="\n"; 281 PlayingMovie +="\n";
170 } 282 }
171 283
...@@ -179,7 +291,13 @@ app.post('/hook', (req, res) => { ...@@ -179,7 +291,13 @@ app.post('/hook', (req, res) => {
179 } 291 }
180 if(MEGA_flag===5){ 292 if(MEGA_flag===5){
181 const index = parseInt(message.text) -1; 293 const index = parseInt(message.text) -1;
182 - //MEGA_title = 294 + MEGA_title= MEGA_PlayingMovieList[Object.keys(MEGA_PlayingMovieList)[index]]
295 + const final_URL = "https://www.megabox.co.kr/booking?rpstMovieNo="+ MEGA_title+"&brchNo1="+MEGA_TheaterLocation+'&playDe='+MEGA_date;
296 + console.log(final_URL)
297 +
298 + PushMessage(eventObj, final_URL, "예매창으로 바로 이동합니다.");
299 +
300 +
183 301
184 } 302 }
185 303
......