Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김시환
/
emergency_room_ChatBot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
root
2022-11-28 16:14:18 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d1b55b9539205db870f2c88e0fd3f1d6befdb801
d1b55b95
1 parent
e8e6d8e9
update app.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
30 deletions
app.js
app.js
View file @
d1b55b9
...
...
@@ -10,35 +10,24 @@ const domain = "2019102158.oss2022chatbot.tk"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
const
app
=
express
();
var
event_time
=
1
function
main
(
eventObj
,
res
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
'Authorization'
:
`Bearer
${
TOKEN
}
`
,
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
// ①
"text"
:
"응급 상황인가요?"
,
"quickReply"
:
{
// ②
"items"
:
[
{
"type"
:
"action"
,
// ③
"action"
:
{
"type"
:
"postback"
,
"label"
:
"네"
,
"data"
:
"action=two"
,
"displayText"
:
"네"
,
"inputOption"
:
"openKeyboard"
,
}
},
]
}
}
"text"
:
"응급 상황인가요?"
},
{
"type"
:
"text"
,
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
},
],
}
},(
error
,
response
,
body
)
=>
{
...
...
@@ -49,22 +38,23 @@ res.sendStatus(200);
}
function
find_current
(
eventObj
,
res
){
//Two
console
.
log
(
Address
.
getAddress
(
eventObj
.
message
.
text
))
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
'Authorization'
:
`Bearer
${
TOKEN
}
`
,
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
//eventObj.replyToken
"messages"
:[
{
"type"
:
"text"
,
// ①
"text"
:
"응급 상황인가요?"
,
"type"
:
"text"
,
// ①
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
,
"text"
:
"응급 상황인가요?"
},
{
"type"
:
"text"
,
"text"
:
"현재있는 위치의 주소나 보이는 곳을 입력하세요."
},
}
],
}
},(
error
,
response
,
body
)
=>
{
...
...
@@ -78,15 +68,13 @@ res.sendStatus(200);
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
var
headers
=
req
.
headers
;
console
.
log
(
'======================'
,
new
Date
()
,
'======================'
);
console
.
log
(
eventObj
)
if
(
eventObj
.
postback
){
find_current
(
eventObj
,
res
)
if
(
event_time
==
1
){
main
(
eventObj
,
res
)
event_time
=
2
}
else
{
else
if
(
event_time
==
2
)
{
find_current
(
eventObj
,
res
)
}
...
...
Please
register
or
login
to post a comment