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-05 12:11:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
12c84e8bd08dbdd4bd1eb233fda65e7870d531f2
12c84e8b
1 parent
5fed0960
Update app.js
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
app.js
app.js
View file @
12c84e8
...
...
@@ -71,7 +71,7 @@ app.post('/webhook', line.middleware(config), (req, res) => {
})
});
// event handler
function
handleEvent
(
event
)
{
async
function
handleEvent
(
event
)
{
console
.
log
(
event
.
type
);
console
.
log
(
event
.
message
);
...
...
@@ -81,7 +81,7 @@ function handleEvent(event) {
return
Promise
.
resolve
(
null
);
}
else
if
(
event
.
type
==
'message'
&&
event
.
message
.
type
==
'image'
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
"!"
);
var
cheerio
=
require
(
'cheerio'
);
...
...
@@ -89,7 +89,7 @@ function handleEvent(event) {
let
endpoint
=
process
.
env
[
'COMPUTER_VISION_ENDPOINT'
];
console
.
log
(
"?"
);
var
uriBase
=
endpoint
+
'vision/v2.1/ocr'
;
var
options
=
{
var
options
=
{
uri
:
uriBase
,
qs
:
{
visualFeatures
:
'Categories'
,
...
...
@@ -102,7 +102,9 @@ function handleEvent(event) {
},
body
:
event
.
message
.
image
};
await
request
.
post
(
options
,
function
(
error
,
response
,
body
)
{
}).
then
(
request
.
post
(
options
,
function
(
error
,
response
,
body
)
{
var
data
=
JSON
.
stringify
(
body
);
var
text
=
''
;
console
.
log
(
data
);
...
...
@@ -137,8 +139,7 @@ function handleEvent(event) {
}
client
.
replyMessage
(
event
.
replyToken
,
result
).
then
(
resolve
).
catch
(
reject
);
});
});
})
}))
}
else
if
(
event
.
type
==
'message'
&&
event
.
message
.
type
==
'text'
)
{
...
...
Please
register
or
login
to post a comment