김대욱

제발14

Showing 1 changed file with 20 additions and 4 deletions
...@@ -14,6 +14,7 @@ const bodyParser = require('body-parser'); ...@@ -14,6 +14,7 @@ const bodyParser = require('body-parser');
14 var app = express(); 14 var app = express();
15 app.use(bodyParser.json()); 15 app.use(bodyParser.json());
16 16
17 +var cmd = "";
17 app.post('/hook', function (req, res) { 18 app.post('/hook', function (req, res) {
18 19
19 var eventObj = req.body.events[0]; 20 var eventObj = req.body.events[0];
...@@ -25,17 +26,32 @@ app.post('/hook', function (req, res) { ...@@ -25,17 +26,32 @@ app.post('/hook', function (req, res) {
25 console.log('[request]', req.body); 26 console.log('[request]', req.body);
26 console.log('[request source] ', eventObj.source); 27 console.log('[request source] ', eventObj.source);
27 console.log('[request message]', eventObj.message); 28 console.log('[request message]', eventObj.message);
29 +
30 + cmd = eventObj.message.text;
28 31
29 - var cmd = eventObj.message.text; 32 + res.sendStatus(200);
33 +});
34 +
35 +app.post('/hook', function (req, res) {
36 +
37 + var eventObj = req.body.events[0];
38 + var source = eventObj.source;
39 + var message = eventObj.message;
40 +
41 + // request log
42 + console.log('======================', new Date() ,'======================');
43 + console.log('[request]', req.body);
44 + console.log('[request source] ', eventObj.source);
45 + console.log('[request message]', eventObj.message);
30 46
31 if(cmd == "영어"){ 47 if(cmd == "영어"){
32 - trans(eventObj.replyToken, eventObj.message.text); 48 + transen(eventObj.replyToken, eventObj.message.text);
33 } 49 }
34 else if(cmd == "프랑스어"){ 50 else if(cmd == "프랑스어"){
35 - trans(eventObj.replyToken, eventObj.message.text); 51 + transfr(eventObj.replyToken, eventObj.message.text);
36 } 52 }
37 else if(cmd == "일본어"){ 53 else if(cmd == "일본어"){
38 - trans(eventObj.replyToken, eventObj.message.text); 54 + transja(eventObj.replyToken, eventObj.message.text);
39 } 55 }
40 56
41 res.sendStatus(200); 57 res.sendStatus(200);
......