김대욱

제발14

Showing 1 changed file with 20 additions and 4 deletions
......@@ -14,6 +14,7 @@ const bodyParser = require('body-parser');
var app = express();
app.use(bodyParser.json());
var cmd = "";
app.post('/hook', function (req, res) {
var eventObj = req.body.events[0];
......@@ -25,17 +26,32 @@ app.post('/hook', function (req, res) {
console.log('[request]', req.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
cmd = eventObj.message.text;
var cmd = eventObj.message.text;
res.sendStatus(200);
});
app.post('/hook', function (req, res) {
var eventObj = req.body.events[0];
var source = eventObj.source;
var message = eventObj.message;
// request log
console.log('======================', new Date() ,'======================');
console.log('[request]', req.body);
console.log('[request source] ', eventObj.source);
console.log('[request message]', eventObj.message);
if(cmd == "영어"){
trans(eventObj.replyToken, eventObj.message.text);
transen(eventObj.replyToken, eventObj.message.text);
}
else if(cmd == "프랑스어"){
trans(eventObj.replyToken, eventObj.message.text);
transfr(eventObj.replyToken, eventObj.message.text);
}
else if(cmd == "일본어"){
trans(eventObj.replyToken, eventObj.message.text);
transja(eventObj.replyToken, eventObj.message.text);
}
res.sendStatus(200);
......