Showing
1 changed file
with
20 additions
and
19 deletions
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | const request = require('request'); | 2 | const request = require('request'); |
3 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 3 | const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' |
4 | -const TOKEN = '채널 토큰으로 변경' | 4 | +const TOKEN = 'zVAczqoJ+L9oykqhEj7HoP7f6Nyb+R3T1TntHXQhYihI+KIxH4SZDGpKu0jKsMXMHKBVXpmbybA+oaV8u/dfLppKe3NHXU9AdBVypy9NgfWiFPLlcwm3GdkVPAZGoS4nvOCXWDKUb+ixPKWjlbnChAdB04t89/1O/w1cDnyilFU=' |
5 | const fs = require('fs'); | 5 | const fs = require('fs'); |
6 | const path = require('path'); | 6 | const path = require('path'); |
7 | const HTTPS = require('https'); | 7 | const HTTPS = require('https'); |
8 | -const domain = "도메인 변경" | 8 | +const domain = "2019102226.osschatbot2022.ml" |
9 | const sslport = 23023; | 9 | const sslport = 23023; |
10 | +// this is added. | ||
10 | 11 | ||
11 | const bodyParser = require('body-parser'); | 12 | const bodyParser = require('body-parser'); |
12 | var app = express(); | 13 | var app = express(); |
... | @@ -18,7 +19,7 @@ app.post('/hook', function (req, res) { | ... | @@ -18,7 +19,7 @@ app.post('/hook', function (req, res) { |
18 | var message = eventObj.message; | 19 | var message = eventObj.message; |
19 | 20 | ||
20 | // request log | 21 | // request log |
21 | - console.log('======================', new Date() ,'======================'); | 22 | + console.log('======================', new Date(), '======================'); |
22 | console.log('[request]', req.body); | 23 | console.log('[request]', req.body); |
23 | console.log('[request source] ', eventObj.source); | 24 | console.log('[request source] ', eventObj.source); |
24 | console.log('[request message]', eventObj.message); | 25 | console.log('[request message]', eventObj.message); |
... | @@ -30,38 +31,38 @@ app.post('/hook', function (req, res) { | ... | @@ -30,38 +31,38 @@ app.post('/hook', function (req, res) { |
30 | 'Authorization': `Bearer ${TOKEN}` | 31 | 'Authorization': `Bearer ${TOKEN}` |
31 | }, | 32 | }, |
32 | json: { | 33 | json: { |
33 | - "replyToken":eventObj.replyToken, | 34 | + "replyToken": eventObj.replyToken, |
34 | - "messages":[ | 35 | + "messages": [ |
35 | { | 36 | { |
36 | - "type":"text", | 37 | + "type": "text", |
37 | - "text":"Hello, user" | 38 | + "text": "Hello, user" |
38 | }, | 39 | }, |
39 | { | 40 | { |
40 | - "type":"text", | 41 | + "type": "text", |
41 | - "text":"May I help you?" | 42 | + "text": "May I help you?" |
42 | } | 43 | } |
43 | ] | 44 | ] |
44 | } | 45 | } |
45 | - },(error, response, body) => { | 46 | + }, (error, response, body) => { |
46 | console.log(body) | 47 | console.log(body) |
47 | }); | 48 | }); |
48 | - | 49 | + |
49 | 50 | ||
50 | res.sendStatus(200); | 51 | res.sendStatus(200); |
51 | }); | 52 | }); |
52 | 53 | ||
53 | try { | 54 | try { |
54 | const option = { | 55 | const option = { |
55 | - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | 56 | + ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'), |
56 | - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | 57 | + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/privkey.pem'), 'utf8').toString(), |
57 | - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | 58 | + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/cert.pem'), 'utf8').toString(), |
58 | }; | 59 | }; |
59 | - | 60 | + |
60 | HTTPS.createServer(option, app).listen(sslport, () => { | 61 | HTTPS.createServer(option, app).listen(sslport, () => { |
61 | - console.log(`[HTTPS] Server is started on port ${sslport}`); | 62 | + console.log(`[HTTPS] Server is started on port ${sslport}`); |
62 | }); | 63 | }); |
63 | - } catch (error) { | 64 | +} catch (error) { |
64 | console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | 65 | console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); |
65 | console.log(error); | 66 | console.log(error); |
66 | - } | 67 | +} |
67 | - | 68 | + | ... | ... |
-
Please register or login to post a comment