Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최지민
/
LINEBOT
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
최지민
2019-11-23 21:07:31 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e389caf21f80e546d8c2d698ea7ca97fa67d4d80
e389caf2
1 parent
4364f8d2
search_option4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
app.js
app.js
View file @
e389caf
...
...
@@ -70,14 +70,25 @@ function handleEvent(event) {
// 검색 기능
else
if
(
event
.
message
.
text
.
substr
(
0
,
4
)
==
"!검색 "
){
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
text_len
=
event
.
message
.
text
;
search_api_url
+=
'?query='
+
String
(
event
.
message
.
text
.
substr
(
4
,
text_len
-
4
))
+
'&display=1'
;
var
text_len
=
event
.
message
.
text
.
length
;
var
search_options
=
{
url
:
search_api_url
,
uri
:
search_api_url
,
qs
:
{
query
:
event
.
message
.
text
.
substr
(
4
,
text_len
-
4
),
display
:
1
},
headers
:
{
'X-Naver-Client-Id'
:
client_id
,
'X-Naver-Client-Secret'
:
client_secret
}
};
request
.
get
(
search_options
,
function
(
error
,
response
,
body
){
console
.
log
(
response
);
if
(
!
error
&&
response
.
statusCode
==
200
){
var
title
=
JSON
.
parse
(
body
).
items
[
0
].
title
;
var
link
=
JSON
.
parse
(
body
).
items
[
0
].
link
;
var
description
=
JSON
.
parse
(
body
).
items
[
0
].
description
;
var
result
=
{
type
:
'text'
,
text
:
title
+
" : "
+
description
+
"/nlink : "
+
link
};
client
.
replyMessage
(
event
.
replyToken
,
result
).
then
(
resolve
).
catch
(
reject
);
}
})
})
}
...
...
Please
register
or
login
to post a comment