yangjisu

Grammar check fixed

Showing 1 changed file with 5 additions and 3 deletions
...@@ -618,7 +618,7 @@ function handleEvent(event) { ...@@ -618,7 +618,7 @@ function handleEvent(event) {
618 if (detect_body.langCode = 'en') { 618 if (detect_body.langCode = 'en') {
619 var grammar = { 619 var grammar = {
620 url: EnGrammarCheck_api_url, 620 url: EnGrammarCheck_api_url,
621 - form: {key: '9WUGcY6ZayYMphG7', text: event.message.text}, 621 + form: {key: config.textgear_config.key, text: event.message.text},
622 } 622 }
623 request.post(grammar, function (error, response, body) { 623 request.post(grammar, function (error, response, body) {
624 if (!error && response.statusCode == 200) { 624 if (!error && response.statusCode == 200) {
...@@ -640,8 +640,10 @@ function handleEvent(event) { ...@@ -640,8 +640,10 @@ function handleEvent(event) {
640 result.text = temp; 640 result.text = temp;
641 641
642 var last_index = Object.keys(objBody.errors).length -1; 642 var last_index = Object.keys(objBody.errors).length -1;
643 - result.text += event.message.text.substring(objBody.errors[last_index]['offset'] + objBody.errors[last_index]['length'], event.message.text.length);
644 643
644 + if(last_index >=0) {
645 + result.text += event.message.text.substring(objBody.errors[last_index]['offset'] + objBody.errors[last_index]['length'], event.message.text.length);
646 + }
645 //번역된 문장 보내기 647 //번역된 문장 보내기
646 client 648 client
647 .replyMessage(event.replyToken, result) 649 .replyMessage(event.replyToken, result)
...@@ -704,4 +706,4 @@ function handleEvent(event) { ...@@ -704,4 +706,4 @@ function handleEvent(event) {
704 706
705 app.listen(3000, function () { 707 app.listen(3000, function () {
706 console.log("Linebot listening on port 3000!"); 708 console.log("Linebot listening on port 3000!");
707 -});
...\ No newline at end of file ...\ No newline at end of file
709 +});
......