Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신일섭
/
ShoppingCart
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
4
Network
Create a new issue
Commits
Issue Boards
Authored by
신일섭
2020-06-24 22:51:37 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3617bb8d431349fb2c322da6b30214260f83b985
3617bb8d
1 parent
c639241f
필요없는 번역기능 제거
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
88 deletions
trans/trans.js
trans/trans.js
deleted
100644 → 0
View file @
c639241
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
Please
register
or
login
to post a comment