Toggle navigation
Toggle navigation
This project
Loading...
Sign in
박태권
/
menu_recommend_webpage
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
5
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
taegwon
2022-06-07 22:19:10 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
10de48e493d6e370fdfb9533026f12039593fa10
10de48e4
1 parent
83a270a1
fix app.js with error msg
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
107 additions
and
8 deletions
CHATBOT/app.js
CHATBOT/app.js
View file @
10de48e
var
end
=
false
;
var
count
=
0
;
var
choosen
=
new
Array
();
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'
라인
URL'
const
TOKEN
=
'
라인
토큰'
const
PAPAGO_URL
=
'파파고
API
URL'
const
TARGET_URL
=
'
타겟
URL'
const
TOKEN
=
'토큰'
const
PAPAGO_URL
=
'파파고 URL'
const
PAPAGO_ID
=
'파파고 ID'
const
PAPAGO_SECRET
=
'파파고 시크릿'
const
fs
=
require
(
'fs'
);
...
...
@@ -14,6 +15,8 @@ const domain = "도메인"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
const
res
=
require
(
'express/lib/response'
);
const
{
eventNames
}
=
require
(
'process'
);
const
req
=
require
(
'express/lib/request'
);
var
app
=
express
();
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
...
...
@@ -59,13 +62,21 @@ app.post('/hook', function (req, res) {
{
choosen
.
push
(
eventObj
.
message
.
text
);
count
++
;
Rmx_comment
(
eventObj
.
replyToken
);
}
else
if
(
count
==
6
&&
end
)
{
Rmx
(
eventObj
.
replyToken
);
count
++
;
}
else
if
(
count
==
7
&&
end
&&
eventObj
.
message
.
text
==
'y'
)
{
load_map
(
eventObj
.
replyToken
);
count
++
;
}
else
{
err
(
eventObj
.
replyToken
);
}
res
.
sendStatus
(
200
);
for
(
var
i
=
0
;
i
<
5
;
i
++
)
{
console
.
log
(
choosen
[
i
]);
}
});
async
function
start_msg
(
replyToken
,
message
)
{
...
...
@@ -288,8 +299,96 @@ async function opt_5(replyToken, message) {
});
}
});
end
=
true
;
}
async
function
Rmx_comment
(
replyToken
)
{
await
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"계속하려면 아무키나 입력하시오."
}
]
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
async
function
Rmx
(
replyToken
)
{
await
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"추천 음식은 ~~~~ 입니다.\n 음식점을 추천 받으시겠습니까? (y/n)"
}
]
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
async
function
load_map
(
replyToken
)
{
await
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"herf"
,
"href"
:
"file:///C:/Users/pnr02/Desktop/opensource_project/selectWestern.html"
}
]
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
async
function
err
(
replyToken
)
{
await
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"please enter a right thing"
}
]
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
try
{
const
option
=
{
...
...
@@ -304,4 +403,4 @@ try {
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
}
\ No newline at end of file
...
...
Please
register
or
login
to post a comment