Toggle navigation
Toggle navigation
This project
Loading...
Sign in
은승우
/
LINEBOT
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
은승우
2019-12-04 23:17:05 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ca86a129b52338280abf73db4ad0d6d972640f82
ca86a129
1 parent
99b477e5
image
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
39 deletions
app.js
app.js
View file @
ca86a12
...
...
@@ -62,42 +62,6 @@ const client = new line.Client(config);
// register a webhook handler with middleware
// about the middleware, please refer to doc
// Creates a client
var
vision
=
require
(
'google-vision-api-client'
);
var
requtil
=
vision
.
requtil
;
//Prepare your service account from trust preview certificated project
var
jsonfile
=
'/home/ubuntu/a/LINEBOT/googlevisionapikey'
;
//Initialize the api
vision
.
init
(
jsonfile
);
//Build the request payloads
var
d
=
requtil
.
createRequests
().
addRequest
(
requtil
.
createRequest
(
'/home/ubuntu/a/LINEBOT/photo/Fancy=TWICE.jpg'
)
.
withFeature
(
'Optical Character Recognition'
,
3
)
.
build
());
//Do query to the api server
vision
.
query
(
d
,
function
(
e
,
r
,
d
){
if
(
e
)
console
.
log
(
'ERROR:'
,
e
);
console
.
log
(
JSON
.
stringify
(
d
));
});
app
.
post
(
'/webhook'
,
line
.
middleware
(
config
),
(
req
,
res
)
=>
{
Promise
.
all
(
req
.
body
.
events
.
map
(
handleEvent
))
...
...
@@ -114,9 +78,12 @@ function handleEvent(event) {
// ignore non-message event
return
Promise
.
resolve
(
null
);
}
else
if
(
event
.
type
==
'message'
&&
event
.
message
.
type
==
'image'
)
{
else
if
(
event
.
type
==
'message'
&&
event
.
message
.
type
==
'image'
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
upload
=
multer
({
dest
:
'photo/'
})
upload
.
single
(
event
.
message
.
image
);
})
}
else
if
(
event
.
type
==
'message'
&&
event
.
message
.
type
==
'text'
)
{
...
...
Please
register
or
login
to post a comment