Showing
1 changed file
with
9 additions
and
6 deletions
... | @@ -36,8 +36,9 @@ app.use(bodyParser.json()); | ... | @@ -36,8 +36,9 @@ app.use(bodyParser.json()); |
36 | 36 | ||
37 | 37 | ||
38 | function first(text1){ | 38 | function first(text1){ |
39 | - if(text1 == 'y') | 39 | + if(text1 == 'y'){ |
40 | return true; | 40 | return true; |
41 | + } | ||
41 | else | 42 | else |
42 | return false; | 43 | return false; |
43 | } | 44 | } |
... | @@ -49,7 +50,7 @@ function hello(eventObj){ | ... | @@ -49,7 +50,7 @@ function hello(eventObj){ |
49 | 'Authorization': `Bearer ${TOKEN}` | 50 | 'Authorization': `Bearer ${TOKEN}` |
50 | }, | 51 | }, |
51 | json:{ | 52 | json:{ |
52 | - "replyToken":eventObj,replyToken, | 53 | + "replyToken":eventObj.replyToken, |
53 | "messages" :[ | 54 | "messages" :[ |
54 | { | 55 | { |
55 | "type":"text", | 56 | "type":"text", |
... | @@ -76,8 +77,8 @@ app.post('/hook', function (req, res) { | ... | @@ -76,8 +77,8 @@ app.post('/hook', function (req, res) { |
76 | var eventObj = req.body.events[0]; | 77 | var eventObj = req.body.events[0]; |
77 | var source = eventObj.source; | 78 | var source = eventObj.source; |
78 | var message = eventObj.message; | 79 | var message = eventObj.message; |
79 | - var text; | 80 | + var message_text = message.text; |
80 | - var text1; | 81 | + //var text1; |
81 | var text2; | 82 | var text2; |
82 | 83 | ||
83 | var findfoods; | 84 | var findfoods; |
... | @@ -86,14 +87,16 @@ app.post('/hook', function (req, res) { | ... | @@ -86,14 +87,16 @@ app.post('/hook', function (req, res) { |
86 | console.log('[request]', req.body); | 87 | console.log('[request]', req.body); |
87 | console.log('[request source] ', eventObj.source); | 88 | console.log('[request source] ', eventObj.source); |
88 | console.log('[request message]', eventObj.message); | 89 | console.log('[request message]', eventObj.message); |
89 | - text = hello(text1); | 90 | + text = first(message_text); |
90 | 91 | ||
91 | if(text == true){ | 92 | if(text == true){ |
92 | console.log('Hi',message); | 93 | console.log('Hi',message); |
93 | - hello(text2); | 94 | + hello(eventObj); |
94 | } | 95 | } |
96 | + else{ | ||
95 | getfoodinfo(eventObj.replyToken); | 97 | getfoodinfo(eventObj.replyToken); |
96 | getfood(eventObj.replyToken); | 98 | getfood(eventObj.replyToken); |
99 | + } | ||
97 | 100 | ||
98 | res.sendStatus(200); | 101 | res.sendStatus(200); |
99 | }); | 102 | }); | ... | ... |
-
Please register or login to post a comment