Showing
1 changed file
with
34 additions
and
3 deletions
| ... | @@ -36,6 +36,7 @@ app.post('/message', function(req,res){ | ... | @@ -36,6 +36,7 @@ app.post('/message', function(req,res){ |
| 36 | console.log('전달받은 메시지 : ' + msg); | 36 | console.log('전달받은 메시지 : ' + msg); |
| 37 | var send = {}; | 37 | var send = {}; |
| 38 | var task = [ | 38 | var task = [ |
| 39 | + // 앨범 정보를 읽어오는 함수 // | ||
| 39 | function(callback){ | 40 | function(callback){ |
| 40 | switch(msg){ | 41 | switch(msg){ |
| 41 | case 'Reol-Discography' : | 42 | case 'Reol-Discography' : |
| ... | @@ -78,6 +79,9 @@ app.post('/message', function(req,res){ | ... | @@ -78,6 +79,9 @@ app.post('/message', function(req,res){ |
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | }, | 81 | }, |
| 82 | + | ||
| 83 | + // 사용자의 msg를 받아 res를 보냄 // | ||
| 84 | + | ||
| 81 | function(discography, callback){ | 85 | function(discography, callback){ |
| 82 | var index = parseInt(msg[0])-1; | 86 | var index = parseInt(msg[0])-1; |
| 83 | switch (msg) { | 87 | switch (msg) { |
| ... | @@ -97,7 +101,7 @@ app.post('/message', function(req,res){ | ... | @@ -97,7 +101,7 @@ app.post('/message', function(req,res){ |
| 97 | case '한국': | 101 | case '한국': |
| 98 | send = { | 102 | send = { |
| 99 | 'message': { | 103 | 'message': { |
| 100 | - 'text': '등록된 가수 목록입니다.' | 104 | + 'text': '미구현' |
| 101 | }, | 105 | }, |
| 102 | keyboard: { | 106 | keyboard: { |
| 103 | 'type': 'buttons', | 107 | 'type': 'buttons', |
| ... | @@ -106,7 +110,9 @@ app.post('/message', function(req,res){ | ... | @@ -106,7 +110,9 @@ app.post('/message', function(req,res){ |
| 106 | }; | 110 | }; |
| 107 | break; | 111 | break; |
| 108 | // ---------- contents -------------- // | 112 | // ---------- contents -------------- // |
| 109 | - ///// Reol //// | 113 | + /////////////// |
| 114 | + ///// Reol //// | ||
| 115 | + /////////////// | ||
| 110 | case 'Reol' : | 116 | case 'Reol' : |
| 111 | send = { | 117 | send = { |
| 112 | 'message' : { | 118 | 'message' : { |
| ... | @@ -147,7 +153,9 @@ app.post('/message', function(req,res){ | ... | @@ -147,7 +153,9 @@ app.post('/message', function(req,res){ |
| 147 | } | 153 | } |
| 148 | } | 154 | } |
| 149 | break; | 155 | break; |
| 156 | + /////////////// | ||
| 150 | /// 米津玄師 /// | 157 | /// 米津玄師 /// |
| 158 | + /////////////// | ||
| 151 | case '米津玄師': | 159 | case '米津玄師': |
| 152 | send = { | 160 | send = { |
| 153 | 'message': { | 161 | 'message': { |
| ... | @@ -189,6 +197,9 @@ app.post('/message', function(req,res){ | ... | @@ -189,6 +197,9 @@ app.post('/message', function(req,res){ |
| 189 | 197 | ||
| 190 | }; | 198 | }; |
| 191 | break; | 199 | break; |
| 200 | + ////////////// | ||
| 201 | + // ヨルシカ // | ||
| 202 | + ///////////// | ||
| 192 | case 'ヨルシカ': | 203 | case 'ヨルシカ': |
| 193 | send = { | 204 | send = { |
| 194 | 'message': { | 205 | 'message': { |
| ... | @@ -230,7 +241,14 @@ app.post('/message', function(req,res){ | ... | @@ -230,7 +241,14 @@ app.post('/message', function(req,res){ |
| 230 | 241 | ||
| 231 | }; | 242 | }; |
| 232 | break; | 243 | break; |
| 244 | + | ||
| 245 | + ///////////// | ||
| 246 | + //// MOT //// | ||
| 247 | + ///////////// | ||
| 248 | + | ||
| 249 | + | ||
| 233 | // 앨범 정보 읽기 // | 250 | // 앨범 정보 읽기 // |
| 251 | + | ||
| 234 | case discography[0].json_album[index]: | 252 | case discography[0].json_album[index]: |
| 235 | var album = '앨범 : ' + discography[0].json_album[index].substr(3); | 253 | var album = '앨범 : ' + discography[0].json_album[index].substr(3); |
| 236 | if (singer == 'Reol') { | 254 | if (singer == 'Reol') { |
| ... | @@ -267,6 +285,9 @@ app.post('/message', function(req,res){ | ... | @@ -267,6 +285,9 @@ app.post('/message', function(req,res){ |
| 267 | } | 285 | } |
| 268 | } | 286 | } |
| 269 | break; | 287 | break; |
| 288 | + | ||
| 289 | + // 초기 설정으로 돌아가기 // | ||
| 290 | + | ||
| 270 | case '초기화면' : | 291 | case '초기화면' : |
| 271 | send = { | 292 | send = { |
| 272 | 'message' : { | 293 | 'message' : { |
| ... | @@ -279,14 +300,24 @@ app.post('/message', function(req,res){ | ... | @@ -279,14 +300,24 @@ app.post('/message', function(req,res){ |
| 279 | } | 300 | } |
| 280 | break; | 301 | break; |
| 281 | default: | 302 | default: |
| 303 | + send = { | ||
| 304 | + 'message': { | ||
| 305 | + 'text': '잘못된 입력입니다. \n초기화면으로 이동합니다.' | ||
| 306 | + }, | ||
| 307 | + keyboard: { | ||
| 308 | + 'type': 'buttons', | ||
| 309 | + 'buttons': ['일본', '한국'] | ||
| 310 | + } | ||
| 311 | + } | ||
| 282 | break; | 312 | break; |
| 283 | } | 313 | } |
| 284 | callback(null ,send); | 314 | callback(null ,send); |
| 285 | } | 315 | } |
| 286 | ]; | 316 | ]; |
| 317 | + | ||
| 318 | + // async의 waterfall을 통해 함수를 순차적으로 실행 // | ||
| 287 | async.waterfall(task, function(err,result){ | 319 | async.waterfall(task, function(err,result){ |
| 288 | console.log(send); | 320 | console.log(send); |
| 289 | res.json(send); | 321 | res.json(send); |
| 290 | }); | 322 | }); |
| 291 | - | ||
| 292 | }); | 323 | }); |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment