Toggle navigation
Toggle navigation
This project
Loading...
Sign in
신정아
/
weather_chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
1
Network
Create a new issue
Commits
Issue Boards
Authored by
Ubuntu
2020-06-04 04:55:14 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ce129d08d818ec6f09c3bdfbb3210f4adf77cb98
ce129d08
1 parent
7a4e7f2f
0604 linechatbot
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
5 deletions
Experiments/messenger/trans/app.js
Experiments/messenger/trans/package-lock.json
Experiments/messenger/trans/package.json
Experiments/messenger/trans/app.js
View file @
ce129d0
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
TOKEN
=
'
채널 토큰
'
const
TOKEN
=
'
RbPAXRYWub0evg2yyi7oiHytZsZsE0JtbZgRYZNZDU1vjpJkOwGqwh+aKTYKVhVHh6LZOUVZLl84NQQlNWNbXR9hUhPEiLEK0cie4O3OlKUuEe/3wAsjPu7HbRi1zn9BsR3Qr4pcqmiIKP8HRUKvEwdB04t89/1O/w1cDnyilFU=
'
const
PAPAGO_URL
=
'https://openapi.naver.com/v1/papago/n2mt'
const
PAPAGO_ID
=
'
파파고 ID
'
const
PAPAGO_SECRET
=
'
파파고 Client Secret
'
const
PAPAGO_ID
=
'
PA1ukOX3tRrte6BLkI2V
'
const
PAPAGO_SECRET
=
'
AnRP59FJPm
'
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"
도메인 명
"
const
domain
=
"
www.osschat.tk
"
const
sslport
=
23023
;
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
var
target
=
'en'
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
...
...
@@ -26,6 +27,7 @@ app.post('/hook', function (req, res) {
console
.
log
(
'[request message]'
,
eventObj
.
message
);
trans
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
//trans함수로 번역(reaplyToken과 message.text를 이용)
res
.
sendStatus
(
200
);
...
...
@@ -33,6 +35,17 @@ app.post('/hook', function (req, res) {
function
trans
(
replyToken
,
message
)
{
if
(
message
==
'영어'
){
target
=
'en'
return
}
else
if
(
message
==
'일본어'
){
target
=
'ja'
return
}
else
if
(
message
==
'프랑스어'
){
target
=
'fr'
return
}
request
.
post
(
{
url
:
PAPAGO_URL
,
...
...
@@ -41,7 +54,8 @@ function trans(replyToken, message) {
'X-Naver-Client-Id'
:
`
${
PAPAGO_ID
}
`
,
'X-Naver-Client-Secret'
:
`
${
PAPAGO_SECRET
}
`
},
body
:
'source=ko&target=en&text='
+
message
,
body
:
`source=ko&target=
${
target
}
&text=`
+
message
,
//source는 한국어, 결과는 영어로 바꿈
//=뒤에는 바뀌고 싶은 메세지가 들어감
json
:
true
},(
error
,
response
,
body
)
=>
{
if
(
!
error
&&
response
.
statusCode
==
200
)
{
...
...
Experiments/messenger/trans/package-lock.json
View file @
ce129d0
...
...
@@ -57,6 +57,14 @@
"resolved"
:
"https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz"
,
"integrity"
:
"sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug=="
},
"axios"
:
{
"version"
:
"0.19.2"
,
"resolved"
:
"https://registry.npmjs.org/axios/-/axios-0.19.2.tgz"
,
"integrity"
:
"sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA=="
,
"requires"
:
{
"follow-redirects"
:
"1.5.10"
}
},
"bcrypt-pbkdf"
:
{
"version"
:
"1.0.2"
,
"resolved"
:
"https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz"
,
...
...
@@ -259,6 +267,24 @@
"unpipe"
:
"~1.0.0"
}
},
"follow-redirects"
:
{
"version"
:
"1.5.10"
,
"resolved"
:
"https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz"
,
"integrity"
:
"sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ=="
,
"requires"
:
{
"debug"
:
"=3.1.0"
},
"dependencies"
:
{
"debug"
:
{
"version"
:
"3.1.0"
,
"resolved"
:
"https://registry.npmjs.org/debug/-/debug-3.1.0.tgz"
,
"integrity"
:
"sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g=="
,
"requires"
:
{
"ms"
:
"2.0.0"
}
}
}
},
"forever-agent"
:
{
"version"
:
"0.6.1"
,
"resolved"
:
"https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz"
,
...
...
Experiments/messenger/trans/package.json
View file @
ce129d0
...
...
@@ -9,6 +9,7 @@
"author"
:
""
,
"license"
:
"ISC"
,
"dependencies"
:
{
"axios"
:
"^0.19.2"
,
"express"
:
"^4.17.1"
,
"request"
:
"^2.88.2"
}
...
...
Please
register
or
login
to post a comment