엄성진

Remove Unused js

1 var express = require('express'); 1 var express = require('express');
2 +var Info = require('./Info');
2 const request = require('request'); 3 const request = require('request');
3 const fs = require('fs'); 4 const fs = require('fs');
4 const path = require('path'); 5 const path = require('path');
5 const HTTPS = require('https'); 6 const HTTPS = require('https');
6 -const domain = "2020105631.oss2021.tk"
7 const sslport = 23023; 7 const sslport = 23023;
8 const bodyParser = require('body-parser'); 8 const bodyParser = require('body-parser');
9 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' 9 const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
...@@ -38,9 +38,9 @@ function send(replyToken, message,userId) { ...@@ -38,9 +38,9 @@ function send(replyToken, message,userId) {
38 } 38 }
39 try { 39 try {
40 const option = { 40 const option = {
41 - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'), 41 + ca: fs.readFileSync('/etc/letsencrypt/live/' + Info.domain + '/fullchain.pem'),
42 - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/privkey.pem'), 'utf8').toString(), 42 + key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + Info.domain + '/privkey.pem'), 'utf8').toString(),
43 - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/cert.pem'), 'utf8').toString(), 43 + cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + Info.domain + '/cert.pem'), 'utf8').toString(),
44 }; 44 };
45 45
46 HTTPS.createServer(option, app).listen(sslport, () => { 46 HTTPS.createServer(option, app).listen(sslport, () => {
......
1 -var Info = require('./Info');
2 -
3 -exports.check = function(message,replyToken){
4 -
5 - const rand_0to9 = Math.floor(Math.random() * 10); // 0~9까지 난수생성
6 - var ids = ['p5iu1V30myk', 'i-SBnhaZSSU', 'Etfgb6A7hSI', 'IN2mml9xs_s', // 모든 동영상 id를 관리하는 배열
7 - 'tp1uoFAfgHE', 'Qx22TnVVIfU', '3y1QIqR115A', 'VXBI1wt8XII', 'aWMBn2--E0Q', 'HyTbgBlnLCo'];
8 -
9 - const request = require('request');
10 - const fs = require('fs');
11 - const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
12 -
13 -
14 - var { google } = require('googleapis');
15 -
16 - var service = google.youtube('v3');
17 - service.videos.list
18 - (
19 - {
20 - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
21 - part: 'snippet',
22 - id: ids[rand_0to9], // 동영상 Id random input
23 - fields: 'items(snippet(title))'
24 - },
25 - function (err, response)
26 - {
27 - if (err)
28 - {
29 - console.log('The API returned an error: ', err);
30 - return;
31 - }
32 -
33 - var video = response.data.items;
34 -
35 - if (video.length == 0)
36 - {
37 - console.log('검색된 동영상이 없습니다.');
38 - }
39 - else
40 - {
41 - sendMessage = JSON.stringify(response.data.items[0].snippet.title);
42 - console.log(sendMessage);
43 - request.post(
44 - {
45 - url: TARGET_URL,
46 - headers:
47 - {
48 - 'Authorization': `Bearer ${Info.TOKEN}`
49 - },
50 - json:
51 - {
52 - "replyToken": replyToken,
53 - "messages":
54 - [
55 - {
56 - "type": "image",
57 - "originalContentUrl": "https://img.youtube.com/vi/"+ids[rand_0to9]+"/hqdefault.jpg",
58 - "previewImageUrl": "https://img.youtube.com/vi/"+ids[rand_0to9]+"/hqdefault.jpg"
59 - },
60 - {
61 - "type": "text",
62 - "text": sendMessage
63 - }
64 - ]
65 - }
66 - }
67 - );
68 - }
69 - }
70 - )
71 -
72 -
73 -
74 -
75 -
76 -}