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-05 00:55:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5a3a18ed25d69d2536c43cbbbffc8df434548e62
5a3a18ed
1 parent
b95b6fbb
번역기 define error 해결
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
app.js
trans/trans.js
app.js
View file @
5a3a18e
...
...
@@ -16,6 +16,7 @@ const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
const
PAPAGO_ID
=
'r_kuebFKCqBeL3SI_dFb'
const
PAPAGO_SECRET
=
'Wdz2tudrzB'
var
trans
=
require
(
'./trans/trans'
)
var
trans_counter
=
0
;
//-----------------------------------------------------------
const
fs
=
require
(
'fs'
);
...
...
@@ -25,10 +26,7 @@ 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
;
//-----------------------------------------------
var
app
=
express
();
...
...
@@ -51,12 +49,13 @@ app.post('/hook', function (req, res) {
console
.
log
(
'[request message]'
,
eventObj
.
message
);
//----------------------------------------------------------------------------
// language identification & translation
if
(
eventObj
.
message
.
text
.
indexOf
(
'/번역'
)){
trans
.
trans_lng_selector
();
// trans_trigger -> 1
//--------------------language identification & translation-------------------
if
(
eventObj
.
message
.
text
.
includes
(
'/번역'
)){
console
.
log
(
'번역캐치: '
,
eventObj
.
message
.
text
);
trans_counter
=
trans
.
trans_lng_selector
(
eventObj
.
message
.
text
);
// after this trans_trigger = 1
}
else
if
(
trans_
trigg
er
==
1
){
trans
lating
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
else
if
(
trans_
count
er
==
1
){
trans
_counter
=
trans
.
translating
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
// after this trans_trigger = 0
}
...
...
trans/trans.js
View file @
5a3a18e
...
...
@@ -11,14 +11,19 @@ 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
(){
if
(
eventObj
.
message
.
text
==
'/번역 영어'
||
eventObj
.
message
.
text
==
'/번역 프랑스어'
||
eventObj
.
message
.
text
==
'/번역 일본어'
){
function
trans_lng_selector
(
message
){
if
(
message
==
'/번역 영어'
||
message
==
'/번역 프랑스어'
||
message
==
'/번역 일본어'
){
//trans_trigger = 0 or 1;
trans_change
(
eventObj
.
message
.
text
);
trans_change
(
message
);
trans_trigger
=
1
;
console
.
log
(
'[trans_dest]'
,
trans_dest
);
return
trans_trigger
;
}
}
...
...
@@ -57,6 +62,8 @@ function translating(replyToken, message) {
}
},(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
trans_trigger
=
0
;
return
trans_trigger
;
});
}
});
...
...
Please
register
or
login
to post a comment