Showing
1 changed file
with
7 additions
and
47 deletions
1 | +//============================================================= | ||
1 | var express = require('express'); | 2 | var express = require('express'); |
2 | const request = require('request'); | 3 | const request = require('request'); |
3 | -var config = require('./config.json'); | 4 | +const config = require('./config.json'); |
4 | -const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 5 | +//============================================================= |
6 | +const LINE_URL = 'https://api.line.me/v2/bot/message/reply' | ||
5 | const TOKEN = config.TOKEN; | 7 | const TOKEN = config.TOKEN; |
6 | -const KOFIC_URL = 'http://www.kobis.or.kr/kobisopenapi/webservice/rest/movie/searchMovieInfo.json' | 8 | +const BOXOFFICE_URL = 'http://www.kobis.or.kr/kobisopenapi/webservice/rest/boxoffice/searchDailyBoxOfficeList.json' |
7 | const KOFIC_KEY = config.KOFIC_KEY; | 9 | const KOFIC_KEY = config.KOFIC_KEY; |
10 | +//============================================================= | ||
8 | 11 | ||
9 | -const fs = require('fs'); | 12 | +export function MovieInfo(replyToken, message) { |
10 | -const path = require('path'); | ||
11 | -const HTTPS = require('https'); | ||
12 | -const domain = config.domain; | ||
13 | -const sslport = 23023; | ||
14 | -const bodyParser = require('body-parser'); | ||
15 | -var app = express(); | ||
16 | -var translang = 'en'; | ||
17 | -app.use(bodyParser.json()); | ||
18 | -app.post('/hook', function (req, res) { | ||
19 | - | ||
20 | - var eventObj = req.body.events[0]; | ||
21 | - var source = eventObj.source; | ||
22 | - var message = eventObj.message; | ||
23 | - | ||
24 | - // request log | ||
25 | - console.log('======================', new Date() ,'======================'); | ||
26 | - console.log('[request]', req.body); | ||
27 | - console.log('[request source] ', eventObj.source); | ||
28 | - console.log('[request message]', eventObj.message); | ||
29 | - | ||
30 | - MovieInfo(eventObj.replyToken, eventObj.message.text); | ||
31 | - | ||
32 | - | ||
33 | - res.sendStatus(200); | ||
34 | -}); | ||
35 | - | ||
36 | -function MovieInfo(replyToken, message) { | ||
37 | 13 | ||
38 | request.get( | 14 | request.get( |
39 | { | 15 | { |
... | @@ -65,19 +41,3 @@ function MovieInfo(replyToken, message) { | ... | @@ -65,19 +41,3 @@ function MovieInfo(replyToken, message) { |
65 | }); | 41 | }); |
66 | 42 | ||
67 | } | 43 | } |
68 | - | ||
69 | -try { | ||
70 | - const option = { | ||
71 | - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'), | ||
72 | - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(), | ||
73 | - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(), | ||
74 | - }; | ||
75 | - | ||
76 | - HTTPS.createServer(option, app).listen(sslport, () => { | ||
77 | - console.log(`[HTTPS] Server is started on port ${sslport}`); | ||
78 | - }); | ||
79 | - } catch (error) { | ||
80 | - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | ||
81 | - console.log(error); | ||
82 | - } | ||
83 | - | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment