이유혁

slicing error fixed

7.33 KB

......@@ -83,6 +83,7 @@ const option_maker = (api_connector, event) => {
// 8.th : 태국어
// 9.id : 인도네시아어
let target = '';
let checker = true;
if (detect_body.langCode == 'ko') {
target = 'en';
switch (event.message.text.slice(-3)) {
......@@ -108,17 +109,30 @@ const option_maker = (api_connector, event) => {
target = 'id';
break;
default:
checker = false;
break;
}
} else {
checker = false;
target = 'ko';
}
var options = {
url: translate_api_url,
form: {'source':detect_body.langCode, 'target': target, 'text':event.message.text.slice(0,-3)},
headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret}
};
let options = {}
if (checker)
{
options = {
url: translate_api_url,
form: {'source':detect_body.langCode, 'target': target, 'text':event.message.text.slice(0,-3)},
headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret}
};
}
else{
options = {
url: translate_api_url,
form: {'source':detect_body.langCode, 'target': target, 'text':event.message.text},
headers: {'X-Naver-Client-Id': client_id, 'X-Naver-Client-Secret': client_secret}
}
}
resolve(options);
}
else{
......@@ -157,3 +171,5 @@ const receive_result = (options, event) => {
app.listen(3000, function () {
console.log('Linebot listening on port 3000!');
});
// 무조건 3글자 자르면 짧은글 씹힌다
\ No newline at end of file
......

20.3 KB