Showing
1 changed file
with
19 additions
and
8 deletions
... | @@ -13,7 +13,7 @@ const sslport = 23023; | ... | @@ -13,7 +13,7 @@ const sslport = 23023; |
13 | const bodyParser = require('body-parser'); | 13 | 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 | +var cmd = ""; |
17 | app.post('/hook', function (req, res) { | 17 | app.post('/hook', function (req, res) { |
18 | 18 | ||
19 | var eventObj = req.body.events[0]; | 19 | var eventObj = req.body.events[0]; |
... | @@ -26,19 +26,30 @@ app.post('/hook', function (req, res) { | ... | @@ -26,19 +26,30 @@ app.post('/hook', function (req, res) { |
26 | console.log('[request source] ', eventObj.source); | 26 | console.log('[request source] ', eventObj.source); |
27 | console.log('[request message]', eventObj.message); | 27 | console.log('[request message]', eventObj.message); |
28 | 28 | ||
29 | - var cmd = message.text; | 29 | + cmd = message.text; |
30 | + | ||
31 | + res.sendStatus(200); | ||
32 | +}); | ||
33 | +app.post('/hook', function (req, res) { | ||
34 | + | ||
35 | + var eventObj = req.body.events[0]; | ||
36 | + var source = eventObj.source; | ||
37 | + var message = eventObj.message; | ||
38 | + | ||
39 | + // request log | ||
40 | + console.log('======================', new Date() ,'======================'); | ||
41 | + console.log('[request]', req.body); | ||
42 | + console.log('[request source] ', eventObj.source); | ||
43 | + console.log('[request message]', eventObj.message); | ||
30 | 44 | ||
31 | if(cmd == "영어"){ | 45 | if(cmd == "영어"){ |
32 | - var input = message.text; | 46 | + trans(eventObj.replyToken, eventObj.message.text); |
33 | - transen(eventObj.replyToken, input); | ||
34 | } | 47 | } |
35 | else if(cmd == "프랑스어"){ | 48 | else if(cmd == "프랑스어"){ |
36 | - var input = message.text; | 49 | + trans(eventObj.replyToken, eventObj.message.text); |
37 | - transfr(eventObj.replyToken, input); | ||
38 | } | 50 | } |
39 | else if(cmd == "일본어"){ | 51 | else if(cmd == "일본어"){ |
40 | - var input = message.text; | 52 | + trans(eventObj.replyToken, eventObj.message.text); |
41 | - transja(eventObj.replyToken, input); | ||
42 | } | 53 | } |
43 | 54 | ||
44 | res.sendStatus(200); | 55 | res.sendStatus(200); | ... | ... |
-
Please register or login to post a comment