Showing
1 changed file
with
22 additions
and
1 deletions
... | @@ -16,6 +16,10 @@ var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt'; | ... | @@ -16,6 +16,10 @@ var translate_api_url = 'https://openapi.naver.com/v1/papago/n2mt'; |
16 | 16 | ||
17 | //언어감지 api_url | 17 | //언어감지 api_url |
18 | var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs'; | 18 | var languagedetect_api_url = 'https://openapi.naver.com/v1/papago/detectLangs'; |
19 | + | ||
20 | +// 검색 기능 api_url | ||
21 | +var search_api_url = 'https://openapi.naver.com/v1/search/encyc.json'; | ||
22 | + | ||
19 | //polly | 23 | //polly |
20 | const Polly =new AWS.Polly({ | 24 | const Polly =new AWS.Polly({ |
21 | signatureVersion: 'v4', | 25 | signatureVersion: 'v4', |
... | @@ -62,8 +66,25 @@ function handleEvent(event) { | ... | @@ -62,8 +66,25 @@ function handleEvent(event) { |
62 | // ignore non-text-message event | 66 | // ignore non-text-message event |
63 | return Promise.resolve(null); | 67 | return Promise.resolve(null); |
64 | } | 68 | } |
65 | - return new Promise(function(resolve, reject) { | ||
66 | 69 | ||
70 | + // 검색 기능 | ||
71 | + else if(event.message.text.substr(0,4) == "!검색 "){ | ||
72 | + return new Promise(function(resolve, reject) { | ||
73 | + var text_len = event.message.text; | ||
74 | + | ||
75 | + var search_options = { | ||
76 | + url : search_api_url, | ||
77 | + form : {'query': event.message.text.substr(4, text_len - 4), 'display': 1}, | ||
78 | + headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret} | ||
79 | + }; | ||
80 | + request.get(search_options, function(error, response, body){ | ||
81 | + console.log(response); | ||
82 | + }) | ||
83 | + }) | ||
84 | + } | ||
85 | + | ||
86 | + // 번역 기능 & 음성 기능 | ||
87 | + return new Promise(function(resolve, reject) { | ||
67 | //언어 감지 option | 88 | //언어 감지 option |
68 | var detect_options = { | 89 | var detect_options = { |
69 | url : languagedetect_api_url, | 90 | url : languagedetect_api_url, | ... | ... |
-
Please register or login to post a comment