Toggle navigation
Toggle navigation
This project
Loading...
Sign in
정윤지
/
Word_Chain_Chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
EC2 Default User
2021-12-04 10:34:29 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4c29db85e30f2473f3f538b28447f143b7f6a230
4c29db85
1 parent
6e5aa00d
Implement reply function
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
9 deletions
app.js
app.js
View file @
4c29db8
const
express
=
require
(
'express'
);
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
TOKEN
=
'P5+e9JkPRckzKu1Fv7ghZl1MfP0wrYwYcgBVzHWe1OHO4Gtv1PIa9BARYqxoAThaXPSf8MyVKcpDE88V5jOnoS4o2xCNcgH9Ne4wcrPuNX6AT4gsfYEz0Y7n/A4+rT4vXHYARK34YPbkzzQbiXiyiQdB04t89/1O/w1cDnyilFU='
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"2020105659.osschatbot.cf"
const
sslport
=
23023
;
//Configure webhook
//Webhook
const
bodyParser
=
require
(
'body-parser'
);
const
app
=
express
();
var
app
=
express
();
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
uest
,
response
)
{
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
uest
.
body
.
events
[
0
];
var
eventObj
=
req
.
body
.
events
[
0
];
var
source
=
eventObj
.
source
;
var
message
=
eventObj
.
message
;
// request log
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
(
'[request]'
,
req
uest
.
body
);
console
.
log
(
'[request]'
,
req
.
body
);
console
.
log
(
'[request source] '
,
eventObj
.
source
);
console
.
log
(
'[request message]'
,
eventObj
.
message
);
response
.
sendStatus
(
200
);
//Reply
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"안녕하세요"
},
{
"type"
:
"text"
,
"text"
:
"끝말잇기봇입니다"
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
res
.
sendStatus
(
200
);
});
//S
et S
SL
//SSL
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
...
...
Please
register
or
login
to post a comment