전언석

EDIT : when ingredients are more than 2

...@@ -40,9 +40,12 @@ app.post('/hook', function (req, res) { ...@@ -40,9 +40,12 @@ app.post('/hook', function (req, res) {
40 var index = 0; 40 var index = 0;
41 var istrue = false; 41 var istrue = false;
42 for (var i = 0; i < results.length; i++) { 42 for (var i = 0; i < results.length; i++) {
43 - if (results[i].ingredients === message.text) { 43 + var ingredients_list = results[i].ingredients.split(", ");
44 - index = i; 44 + for (var j = 0; j < ingredients_list.length; j++) {
45 - istrue = true; 45 + if (ingredients_list[j] === message.text) {
46 + index = i;
47 + istrue = true;
48 + }
46 } 49 }
47 } 50 }
48 if (istrue) { 51 if (istrue) {
...@@ -61,6 +64,10 @@ app.post('/hook', function (req, res) { ...@@ -61,6 +64,10 @@ app.post('/hook', function (req, res) {
61 }, 64 },
62 { 65 {
63 "type": "text", 66 "type": "text",
67 + "text": `필요한 재료는\n${results[index].ingredients} 입니다.`
68 + },
69 + {
70 + "type": "text",
64 "text": `레시피\n${results[index].recipe}` 71 "text": `레시피\n${results[index].recipe}`
65 } 72 }
66 ] 73 ]
......