yangjisu

Grammar check fixed

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