최지민

search_option6

Showing 1 changed file with 2 additions and 2 deletions
...@@ -71,14 +71,14 @@ function handleEvent(event) { ...@@ -71,14 +71,14 @@ function handleEvent(event) {
71 else if(event.message.text.substr(0,4) == "!검색 "){ 71 else if(event.message.text.substr(0,4) == "!검색 "){
72 return new Promise(function(resolve, reject) { 72 return new Promise(function(resolve, reject) {
73 var text_len = event.message.text.length; 73 var text_len = event.message.text.length;
74 + var title = event.message.text.substr(4, text_len - 4);
74 var search_options = { 75 var search_options = {
75 uri : search_api_url, 76 uri : search_api_url,
76 - qs : {query : event.message.text.substr(4, text_len - 4), display : 1}, 77 + qs : {query : title, display : 1},
77 headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret} 78 headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret}
78 }; 79 };
79 request.get(search_options, function(error, response, body){ 80 request.get(search_options, function(error, response, body){
80 if (!error && response.statusCode == 200){ 81 if (!error && response.statusCode == 200){
81 - var title = JSON.parse(body).items[0].title;
82 var link = JSON.parse(body).items[0].link; 82 var link = JSON.parse(body).items[0].link;
83 var description = JSON.parse(body).items[0].description; 83 var description = JSON.parse(body).items[0].description;
84 84
......