신일섭

필요없는 번역기능 제거

const request = require('request');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = 'LFi+FvOOFOydz0EKN22WRnQyiilnEiyxe2HVV1WrI54Jnght6+Gga07m7pxqSQltBJG2AV2lYnYOAk4TqxzZFKW9R36CJcQs+NaNEiNKJtgBfT/t3tEta/J6GtXxGz/DqdHnfZqSSfLFpXzun/ITTwdB04t89/1O/w1cDnyilFU='
const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
const PAPAGO_ID = 'r_kuebFKCqBeL3SI_dFb'
const PAPAGO_SECRET = 'Wdz2tudrzB'
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "www.chatbotshin.tk"
const sslport = 23023;
const bodyParser = require('body-parser');
//-----target language verification--------------
var trans_dest = 'target=en'; // defualt = english
var trans_trigger = 0;
//-----------------------------------------------
// language identification & translation
function trans_lng_selector(message){
if(message=='/번역 영어' || message=='/번역 프랑스어' || message=='/번역 일본어'){
//trans_trigger = 0 or 1;
trans_change(message);
trans_trigger = 1;
console.log('[trans_dest]', trans_dest);
return trans_trigger;
}
}
function translating(replyToken, message) {
request.post(
{
url: PAPAGO_URL,
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=ko&' + trans_dest + '&text=' + message,
json:true
},(error, response, body) => {
if(!error && response.statusCode == 200) {
console.log(body.message);
var transMessage = body.message.result.translatedText;
request.post(
{
url: TARGET_URL,
headers: {
'Authorization': `Bearer ${TOKEN}`
},
json: {
"replyToken":replyToken,
"messages":[
{
"type":"text",
"text":transMessage
}
]
}
},(error, response, body) => {
console.log(body)
trans_trigger=0;
return trans_trigger;
});
}
});
}
// language index identification
function trans_change(index){
if(index == '/번역 영어'){
trans_dest = 'target=en';
}
else if(index == '/번역 일본어'){
trans_dest = 'target=ja';
}
else if(index == '/번역 프랑스어'){
trans_dest = 'target=fr';
}
}
module.exports.translating = translating;
module.exports.trans_lng_selector = trans_lng_selector;
module.exports.trans_change = trans_change;
\ No newline at end of file