Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신지원
/
LineMusicChatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
엄성진
2021-06-07 17:27:42 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e2ac2423c4587ba5f19ee8cc8f5e9074f2aab6d5
e2ac2423
1 parent
581ec038
Remove Unused js
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
80 deletions
index.js
video_sad.js
index.js
View file @
e2ac242
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
,
()
=>
{
...
...
video_sad.js
deleted
100644 → 0
View file @
581ec03
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
}
]
}
}
);
}
}
)
}
Please
register
or
login
to post a comment