최지민

search_option1

Showing 1 changed file with 21 additions and 0 deletions
......@@ -16,6 +16,10 @@ var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt';
//언어감지 api_url
var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs';
// 검색 기능 api_url
var search_api_url = 'https://openapi.naver.com/v1/search/encyc.json';
//polly
const Polly =new AWS.Polly({
signatureVersion: 'v4',
......@@ -62,8 +66,25 @@ function handleEvent(event) {
// ignore non-text-message event
return Promise.resolve(null);
}
// 검색 기능
else if(event.message.text.substr(0,4) == "!검색 "){
return new Promise(function(resolve, reject) {
var text_len = event.message.text;
var search_options = {
url : search_api_url,
form : {'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);
})
})
}
// 번역 기능 & 음성 기능
return new Promise(function(resolve, reject) {
//언어 감지 option
var detect_options = {
url : languagedetect_api_url,
......