Toggle navigation
Toggle navigation
This project
Loading...
Sign in
조아혜
/
cfr-chatbot
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
조아혜
2020-12-06 02:05:40 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
35b187609d53728184b3c27fd75cdf590e6ed5ac
35b18760
1 parent
f616bea9
modify result message
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
30 deletions
cfr_module.js
chatbot.js
cfr_module.js
0 → 100644
View file @
35b1876
var
client_id
=
'v3M4wjolGLkrvNA3GUIW'
;
var
client_secret
=
'fKF6vjkWhE'
;
var
fs
=
require
(
'fs'
);
var
request
=
require
(
'request'
);
const
path
=
require
(
'path'
);
var
express
=
require
(
'express'
);
var
app
=
express
();
var
domain
=
"www.osstest237.ml"
const
sslport
=
23023
;
const
HTTPS
=
require
(
'https'
);
exports
.
imgtodata
=
function
(
dir
){
var
api_url
=
'https://openapi.naver.com/v1/vision/face'
;
// 얼굴 감지
var
_formData
=
{
image
:
'image'
,
image
:
fs
.
createReadStream
(
path
.
join
(
__dirname
,
dir
))
// FILE 이름
};
request
.
post
(
{
url
:
api_url
,
formData
:
_formData
,
headers
:
{
'X-Naver-Client-Id'
:
client_id
,
'X-Naver-Client-Secret'
:
client_secret
}
},
(
err
,
response
,
body
)
=>
{
console
.
log
(
response
.
statusCode
);
// 200
//console.log(response.headers['content-type'])
data
=
JSON
.
parse
(
body
);
gender
=
data
.
faces
[
0
].
gender
.
value
;
emotion
=
data
.
faces
[
0
].
emotion
.
value
console
.
log
(
gender
);
console
.
log
(
emotion
);
//return {gender:gender,emotion:emotion};
});
}
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
key
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
'/etc/letsencrypt/live/'
+
domain
+
'/privkey.pem'
),
'utf8'
).
toString
(),
cert
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
'/etc/letsencrypt/live/'
+
domain
+
'/cert.pem'
),
'utf8'
).
toString
(),
};
HTTPS
.
createServer
(
option
,
app
).
listen
(
sslport
,
()
=>
{
console
.
log
(
`[HTTPS] Server is started on port
${
sslport
}
`
);
});
}
catch
(
error
)
{
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
//imgtodata('./test3.jpg');
\ No newline at end of file
chatbot.js
View file @
35b1876
...
...
@@ -3,12 +3,12 @@ var client_id = 'v3M4wjolGLkrvNA3GUIW';
var
client_secret
=
'fKF6vjkWhE'
;
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
TOKEN
=
'
hMnfhBQc8nadyn5Ow6aejAVDUoUEp9N8YxOFxfOB2V83TOf0vjquT4cC8ll4Ccq4hkWJ8xHij53FzjMteqLLuUL6bZs+ZONI+f5aawIulRg4Y4FFBGp1O03awvgxGn503iyI7+5iQCEi80Kus6cRZQ
dB04t89/1O/w1cDnyilFU='
//수정해주세용
const
SECRET
=
'
270103fd4cbd81695ceb6d0ed7f85f4b
'
//수정해주세용
const
TOKEN
=
'
w5i8sURqF5bof6DWeB87n+oCeWrYaFf7a5YZzfzN1jeITIlZ3PcOmZRcdGCo/djTuHhNxybfJ69y7Jex+7tipBNRynngfyWX9CK1L3EupuhnX8rubeCmJda7HvsQWXVo8ZDcwl2aLwXsE3kiYF2qEw
dB04t89/1O/w1cDnyilFU='
//수정해주세용
const
SECRET
=
'
b0b4501ebc2813a2b0e586293a35b466
'
//수정해주세용
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
domain
=
"www.oss
chatbot.tk
"
//수정해주세용
const
domain
=
"www.oss
test237.ml
"
//수정해주세용
const
sslport
=
23023
;
const
line
=
require
(
'@line/bot-sdk'
);
...
...
@@ -260,7 +260,7 @@ function QuickReplyCfrYes(replyToken) {
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"사진을 입력해주세요."
,
"text"
:
"사진을 입력해주세요.
얼굴 인식이 되지 않을 경우 위치 기반으로 추천됩니다.
"
,
"quickReply"
:
quickReplyCfrYes
}
]
...
...
@@ -351,6 +351,12 @@ function RecommendationResult(replyToken, query) {
roadAddress
=
data
.
items
[
0
].
roadAddress
;
console
.
log
(
roadAddress
);
var
x
=
Number
(
data
.
items
[
0
].
mapx
);
var
y
=
Number
(
data
.
items
[
0
].
mapy
);
var
longitude
=
TMtoWGS
(
x
,
y
)[
0
];
var
latitude
=
TMtoWGS
(
x
,
y
)[
1
];
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -360,28 +366,13 @@ function RecommendationResult(replyToken, query) {
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
/*{
"type": "imagemap",
// 이미지 불러올 수 없습니다 뜸
"baseUrl": "https://www.flaticon.com/free-icon/food-store_2934069?term=restaurant&page=1&position=7&related_item_id=2934069",
"altText": "이미지를 누르시면 해당 가게로 이동합니다.",
"baseSize": {
"width": 1040,
"height": 1040
},
"actions": [
{
"type": "uri",
"linkUri": link, // 가게 링크
"area": {
"x": 0,
"y": 0,
"width": 1040,
"height": 1040
}
}
]
},*/
"type"
:
"location"
,
"title"
:
title
,
"address"
:
address
,
"latitude"
:
latitude
,
"longitude"
:
longitude
},
{
"type"
:
"text"
,
"text"
:
"맛집 이름: "
+
title
...
...
@@ -390,11 +381,6 @@ function RecommendationResult(replyToken, query) {
"type"
:
"text"
,
"text"
:
"맛집 주소: "
+
address
}
/*{
"type":"location",
"title":"맛집 주소",
"address":address
}*/
]
}
},
(
error
,
response
,
body
)
=>
{
...
...
Please
register
or
login
to post a comment