엄성진

Remove Unused js

var express = require('express');
var Info = require('./Info');
const request = require('request');
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "2020105631.oss2021.tk"
const sslport = 23023;
const bodyParser = require('body-parser');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
......@@ -38,9 +38,9 @@ function send(replyToken, message,userId) {
}
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'),
key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/privkey.pem'), 'utf8').toString(),
cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain + '/cert.pem'), 'utf8').toString(),
ca: fs.readFileSync('/etc/letsencrypt/live/' + Info.domain + '/fullchain.pem'),
key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + Info.domain + '/privkey.pem'), 'utf8').toString(),
cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + Info.domain + '/cert.pem'), 'utf8').toString(),
};
HTTPS.createServer(option, app).listen(sslport, () => {
......
var Info = require('./Info');
exports.check = function(message,replyToken){
const rand_0to9 = Math.floor(Math.random() * 10); // 0~9까지 난수생성
var ids = ['p5iu1V30myk', 'i-SBnhaZSSU', 'Etfgb6A7hSI', 'IN2mml9xs_s', // 모든 동영상 id를 관리하는 배열
'tp1uoFAfgHE', 'Qx22TnVVIfU', '3y1QIqR115A', 'VXBI1wt8XII', 'aWMBn2--E0Q', 'HyTbgBlnLCo'];
const request = require('request');
const fs = require('fs');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
var { google } = require('googleapis');
var service = google.youtube('v3');
service.videos.list
(
{
key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
part: 'snippet',
id: ids[rand_0to9], // 동영상 Id random input
fields: 'items(snippet(title))'
},
function (err, response)
{
if (err)
{
console.log('The API returned an error: ', err);
return;
}
var video = response.data.items;
if (video.length == 0)
{
console.log('검색된 동영상이 없습니다.');
}
else
{
sendMessage = JSON.stringify(response.data.items[0].snippet.title);
console.log(sendMessage);
request.post(
{
url: TARGET_URL,
headers:
{
'Authorization': `Bearer ${Info.TOKEN}`
},
json:
{
"replyToken": replyToken,
"messages":
[
{
"type": "image",
"originalContentUrl": "https://img.youtube.com/vi/"+ids[rand_0to9]+"/hqdefault.jpg",
"previewImageUrl": "https://img.youtube.com/vi/"+ids[rand_0to9]+"/hqdefault.jpg"
},
{
"type": "text",
"text": sendMessage
}
]
}
}
);
}
}
)
}