김시환

Merge branch 'sihwan' of http://khuhub.khu.ac.kr/2019102158/emergency_room_ChatBot into sihwan

Showing 1 changed file with 15 additions and 11 deletions
...@@ -6,24 +6,21 @@ const TOKEN = 'YK56BfHFgpILrxRk1FZrdcouFguf5CBA5qxM3zfDH6N9jR/cfPxVdK1P9vZHAk69m ...@@ -6,24 +6,21 @@ const TOKEN = 'YK56BfHFgpILrxRk1FZrdcouFguf5CBA5qxM3zfDH6N9jR/cfPxVdK1P9vZHAk69m
6 const fs = require('fs'); 6 const fs = require('fs');
7 const path = require('path'); 7 const path = require('path');
8 const HTTPS = require('https'); 8 const HTTPS = require('https');
9 -const domain = "ec2-18-215-162-16.compute-1.amazonaws.com" 9 +const domain = "2019102158.oss2022chatbot.tk"
10 const sslport = 23023; 10 const sslport = 23023;
11 const bodyParser = require('body-parser'); 11 const bodyParser = require('body-parser');
12 const app = express(); 12 const app = express();
13 13
14 14
15 -console.log(Address.getAddress('석수동길'));
16 15
17 app.use(bodyParser.json()); 16 app.use(bodyParser.json());
18 app.post('/hook', function (req, res) { 17 app.post('/hook', function (req, res) {
19 var eventObj = req.body.events[0]; 18 var eventObj = req.body.events[0];
20 - var source = eventObj.source; 19 + //var source = eventObj.source;
21 - var message = eventObj.message; 20 + //var message = eventObj.message;
22 // request log 21 // request log
23 console.log('======================', new Date() ,'======================'); 22 console.log('======================', new Date() ,'======================');
24 - console.log('[request]', req.body); 23 + console.log((Address.getAddress('석수동길')).road_address.address_name)
25 - console.log('[request source] ', eventObj.source);
26 - console.log('[request message]', eventObj.message);
27 request.post( 24 request.post(
28 { 25 {
29 url: TARGET_URL, 26 url: TARGET_URL,
...@@ -31,17 +28,18 @@ app.post('/hook', function (req, res) { ...@@ -31,17 +28,18 @@ app.post('/hook', function (req, res) {
31 'Authorization': `Bearer ${TOKEN}` 28 'Authorization': `Bearer ${TOKEN}`
32 }, 29 },
33 json: { 30 json: {
34 - "replyToken":eventObj.replyToken, 31 + "replyToken":eventObj.replyToken, //eventObj.replyToken
35 "messages":[ 32 "messages":[
36 { 33 {
37 "type":"text", 34 "type":"text",
38 - "text":"Hello, user" 35 + "text":address
39 }, 36 },
40 { 37 {
41 "type":"text", 38 "type":"text",
42 - "text":"May I help you?" 39 + "text":"맞나요?"
43 } 40 }
44 - ] 41 + ],
42 + "status" : 1
45 } 43 }
46 },(error, response, body) => { 44 },(error, response, body) => {
47 console.log(body) 45 console.log(body)
...@@ -49,6 +47,12 @@ app.post('/hook', function (req, res) { ...@@ -49,6 +47,12 @@ app.post('/hook', function (req, res) {
49 47
50 res.sendStatus(200); 48 res.sendStatus(200);
51 }); 49 });
50 +
51 +
52 +
53 +
54 +
55 +
52 try { 56 try {
53 const option = { 57 const option = {
54 ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), 58 ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
......