Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이종상
/
OSS-2021-Project2015
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
이종상
2021-06-10 13:11:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5c90c28fc4969790b4e327e3c9b3f58e8c77fe22
5c90c28f
1 parent
e5181e76
Api added
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
4 deletions
Project/app.js
Project/app.js
View file @
5c90c28
...
...
@@ -8,10 +8,15 @@ const HTTPS = require('https');
const
domain
=
"2015104206.oss-2021.tk"
const
sslport
=
23023
;
const
SERACH_URL
=
'https://openapi.naver.com/v1/search/local.xml?query=%EC%A3%BC%EC%8B%9D&display=10&start=1&sort=random'
const
SEARCH_ID
=
'A9UHUOhOXDtai4Rszdjw'
const
SEARCH_SECRET
=
'ptmB9hKvCw'
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
var
stack
=
0
;
var
meal
,
country
,
cold
,
spicy
;
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
...
...
@@ -23,7 +28,6 @@ app.post('/hook', function (req, res) {
/*
아침 뭐먹지?
-> JSON에서 [아침]에 해당하는 meal 정보 가져옴
-> 한식, 중식, 일식, 양식 어떤게 좋으세요?(한,중,일,양,아무거나)
-> 따뜻한게 좋으세요, 차가운게 좋으세요?(따뜻한거, 차가운거, 아무거나)
-> 매운게 좋으세요, 안매운게 좋으세요?(매운거, 안매운거, 아무거나)
...
...
@@ -145,8 +149,37 @@ https://developers.naver.com/docs/search/local/
{
if
(
eventObj
.
message
.
text
.
indexOf
(
"찬"
)
!==
-
1
)
{
cold
=
"hot"
}
else
if
(
eventObj
.
message
.
text
.
indexOf
(
"뜨거운"
)
!==
-
1
)
{
cold
=
"cold"
}
stack
=
4
;
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
eventObj
.
replyToken
,
"messages"
:[
{
"type"
:
"text"
,
"text"
:
"잠시만 기다려주세요!"
// 결과 도출
}
]
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
}
);
console
.
log
(
'[request message]'
,
meal
);
console
.
log
(
'[request message]'
,
country
);
console
.
log
(
'[request message]'
,
cold
);
console
.
log
(
'[request message]'
,
spicy
);
}
}
else
if
(
stack
==
4
&&
(
eventObj
.
message
.
text
.
indexOf
(
"결과"
)
!==
-
1
))
{
{
stack
=
3
;
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -170,9 +203,19 @@ https://developers.naver.com/docs/search/local/
console
.
log
(
'[request message]'
,
country
);
console
.
log
(
'[request message]'
,
cold
);
console
.
log
(
'[request message]'
,
spicy
);
const
option
=
{
query
:
'순대'
,
start
:
1
,
display
:
3
,
sort
:
'sim'
,
filter
:
'small'
}
ImageSearch
(
option
);
}
}
else
if
(
eventObj
.
message
.
text
.
indexOf
(
"처음부터"
)
!==
-
1
)
else
if
(
eventObj
.
message
.
text
.
indexOf
(
"처음부터"
)
!==
-
1
)
// 초기화 알고리즘
{
stack
=
0
;
request
.
post
(
...
...
@@ -195,7 +238,8 @@ https://developers.naver.com/docs/search/local/
}
);
}
else
{
else
// 예외 파트
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -231,6 +275,25 @@ https://developers.naver.com/docs/search/local/
res
.
sendStatus
(
200
);
});
function
ImageSearch
(
option
)
{
request
.
get
({
uri
:
'https://openapi.naver.com/v1/search/image'
,
qs
:
option
,
headers
:{
'X-Naver-Client-Id'
:
SEARCH_ID
,
'X-Naver-Client-Secret'
:
SEARCH_SECRET
}
},
function
(
err
,
res
,
body
){
let
json
=
JSON
.
parse
(
body
)
console
.
log
(
json
)
})
}
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
...
...
Please
register
or
login
to post a comment