Showing
1 changed file
with
145 additions
and
158 deletions
1 | -// ------------- 2019102195 ------------------ | ||
2 | var express = require('express'); | 1 | var express = require('express'); |
3 | const request = require('request'); | 2 | const request = require('request'); |
4 | -const TARGET_URL = 'https://api.line.me/v2/bot/message/reply' | 3 | +const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'; |
5 | -const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast' | ||
6 | -const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast' | ||
7 | const fs = require('fs'); | 4 | const fs = require('fs'); |
8 | const path = require('path'); | 5 | const path = require('path'); |
9 | const HTTPS = require('https'); | 6 | const HTTPS = require('https'); |
10 | const sslport = 23023; | 7 | const sslport = 23023; |
11 | - | 8 | +const MULTI_TARGET_URL = 'https://api.line.me/v2/bot/message/multicast'; |
12 | - | 9 | +const BROAD_TARGET_URL = 'https://api.line.me/v2/bot/message/broadcast'; |
13 | -var spring = 0 | 10 | + |
14 | -var summer = 0 | 11 | +//const TOKEN = "토큰 입력" |
15 | -var fall = 0 | 12 | +//const domain = "본인의 도메인 입력" |
16 | -var winter = 0 | 13 | + |
17 | -var warm =0 | 14 | +var spring = 0; |
18 | -var cool =0 | 15 | +var summer = 0; |
19 | -var warm_index = 0 | 16 | +var fall = 0; |
20 | -var cool_index= 0 | 17 | +var winter = 0; |
21 | -var skinIndex=0 | 18 | + |
22 | -var i = 0 | 19 | +var warm = 0; |
23 | -var j = -9 | 20 | +var cool = 0; |
24 | -var QuestionCount=9 | 21 | + |
25 | -var QuestionIndex=0 | 22 | +var warm_index = 0; |
26 | -var count = 16 | 23 | +var cool_index = 0; |
27 | -var WarmOrCool=[warm,cool]; | 24 | +var skinIndex = 0; |
28 | -var season_color = [spring, summer, fall, winter] | 25 | + |
29 | -var Questions=['Q1: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 26 | +var i = 0; |
30 | - 'Q2: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 27 | +var j = -9; |
31 | - 'Q3: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 28 | + |
32 | - 'Q4: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 29 | +var QuestionCount = 9; |
33 | - 'Q5: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 30 | +var QuestionIndex |
34 | - 'Q6: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 31 | + = 0; |
35 | - 'Q7: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 32 | +var count = 16; |
36 | - 'Q8: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]', | 33 | + |
37 | - 'Q9: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]' | 34 | +var WarmOrCool = [warm, cool]; |
38 | -] | 35 | +var season_color = [spring, summer, fall, winter]; |
39 | - | 36 | + |
37 | +var Questions = [ | ||
38 | + '나의 피부색은 (1)노란기 (2)붉은기가 돈다.', | ||
39 | + '나의 머리색은 (1)갈색 (2)검정색에 가깝다.', | ||
40 | + '나의 혈관색은 (1)초록색 (2)푸른색에 가깝다. ', | ||
41 | + '나의 눈동자 색깔은 (1)밝은 갈색 (2)짙은 갈색이다. ', | ||
42 | + '나의 두피는 (1)노란색을 (2)푸른색을 띤다.', | ||
43 | + '나는 (1)골드 (2)실버 쥬얼리가 더 잘 어울린다. ', | ||
44 | + '나는 (1)아이보리 (2)새하얀 화이트가 더 잘 어울린다.', | ||
45 | + '나는 (1)브라운/카키 (2)핑크/블루 계열의 옷이 더 잘어울린다.', | ||
46 | + '햇빛에 노출되었을 경우 (1)갈색으로 탄다 (2)붉게 그을린다.', | ||
47 | +]; | ||
40 | var warm_files = [ | 48 | var warm_files = [ |
41 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg5/MDAxNjIyODk2MjQ1NDgy.GD_Uc2qXefDyVgwQ4NoYsYBCoFDI-W45ghNz3ImB_lEg.DtbZwnsqWUB8alA5gtk78B6dKd6UbwHRyUEsTMZn15Yg.PNG.shinee_p98/warm_carmel.png', | 49 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_carmel.png', |
42 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTU1/MDAxNjIyODk2MjQ1NjM0.-YA2roNdR9unkGH0TpTOwcuME5O8jFdmTd_PRQ8XjhQg.FCN4aAzGiM7rpCMsALcXTC2GclwdPH2yU0EehtKS05Ig.PNG.shinee_p98/warm_coral.png', | 50 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_coral.png', |
43 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjE1/MDAxNjIyODk2MjQ1Njk5._QgVhB-Djm4Ew67ys3Vmv2tQ3etNQ6gaLgCk7DBcdO8g.41j4dUE05LFKyfKxkVDeRIqSoyikWYvDENLhgBZjAAYg.PNG.shinee_p98/warm_green.png', | 51 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_green.png', |
44 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjk1/MDAxNjIyODk2MjQ1NzQ3._62ZktQ5_GgRFc9ci0tOYTIQzcpbB-8mBNC3AkPFdgUg.FlZmBkchPnw0XGXGPC44OOnqiqAoROW7wcAj0q6ZNmsg.PNG.shinee_p98/warm_mint.png', | 52 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_mint.png', |
45 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQy/MDAxNjIyODk2MjQ1NzM3.FIkcxRPdgW-PQamsCmTAIx6kCGJcaj83w6sg0bFXP9kg.iD-aye9VnbhuRzBsautBFm6aSB_2JArIbrHywJj8ol8g.PNG.shinee_p98/warm_purple.png', | 53 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_purple.png', |
46 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMzgg/MDAxNjIyODk2MjQ1NTc3.-ZmUf9IxcwX53bb9O-wKR4UtFUjji9toUMW0mIGeveQg.y-GV04bv3VxvU64OcAcZMROPb4SzvOjkuZOSMnuyRicg.PNG.shinee_p98/warm_softgreen.png', | 54 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_softgreen.png', |
47 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTMx/MDAxNjIyODk2MjQ2MjQz.5OuoiEz9j5RT4ypwrA1ncqN_XFR7to4DiiE0hL6AUdEg.VjGhPCDrj0e3FNxbzGYMQncgImY9M1t5mOZSn_Zvejog.PNG.shinee_p98/warm_yellow.png' | 55 | + 'https://personal-color-chatbot.s3.amazonaws.com/warm_yellow.jpg', |
48 | -] | 56 | +]; |
49 | -var warm_previews = [ | 57 | +var cool_files = [ |
50 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg5/MDAxNjIyODk2MjQ1NDgy.GD_Uc2qXefDyVgwQ4NoYsYBCoFDI-W45ghNz3ImB_lEg.DtbZwnsqWUB8alA5gtk78B6dKd6UbwHRyUEsTMZn15Yg.PNG.shinee_p98/warm_carmel/preview.png', | 58 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_blue.png', |
51 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTU1/MDAxNjIyODk2MjQ1NjM0.-YA2roNdR9unkGH0TpTOwcuME5O8jFdmTd_PRQ8XjhQg.FCN4aAzGiM7rpCMsALcXTC2GclwdPH2yU0EehtKS05Ig.PNG.shinee_p98/warm_coral/preview.png', | 59 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_lightpink.png', |
52 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjE1/MDAxNjIyODk2MjQ1Njk5._QgVhB-Djm4Ew67ys3Vmv2tQ3etNQ6gaLgCk7DBcdO8g.41j4dUE05LFKyfKxkVDeRIqSoyikWYvDENLhgBZjAAYg.PNG.shinee_p98/warm_green/preview.png', | 60 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_lightpurple.png', |
53 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjk1/MDAxNjIyODk2MjQ1NzQ3._62ZktQ5_GgRFc9ci0tOYTIQzcpbB-8mBNC3AkPFdgUg.FlZmBkchPnw0XGXGPC44OOnqiqAoROW7wcAj0q6ZNmsg.PNG.shinee_p98/warm_mint/preview.png', | 61 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_mint.png', |
54 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQy/MDAxNjIyODk2MjQ1NzM3.FIkcxRPdgW-PQamsCmTAIx6kCGJcaj83w6sg0bFXP9kg.iD-aye9VnbhuRzBsautBFm6aSB_2JArIbrHywJj8ol8g.PNG.shinee_p98/warm_purple/preview.png', | 62 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_navy.png', |
55 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMzgg/MDAxNjIyODk2MjQ1NTc3.-ZmUf9IxcwX53bb9O-wKR4UtFUjji9toUMW0mIGeveQg.y-GV04bv3VxvU64OcAcZMROPb4SzvOjkuZOSMnuyRicg.PNG.shinee_p98/warm_softgreen/preview.png', | 63 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_pink.png', |
56 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTMx/MDAxNjIyODk2MjQ2MjQz.5OuoiEz9j5RT4ypwrA1ncqN_XFR7to4DiiE0hL6AUdEg.VjGhPCDrj0e3FNxbzGYMQncgImY9M1t5mOZSn_Zvejog.PNG.shinee_p98/warm_yellow/preview.png' | 64 | + 'https://personal-color-chatbot.s3.amazonaws.com/cool_yellow.png', |
57 | -] | 65 | +]; |
58 | - | ||
59 | -var cool_files =[ | ||
60 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTcz/MDAxNjIyODk2MzA2MjA5.DLpREPAip4NyaJH3lydWGKjE1CvlO_1D7oBjLur9iF4g.lsXyiwgipMXvJHkRFQZPe7habxxrjrVzXBMoRv4qrZwg.PNG.shinee_p98/cool_blue.png', | ||
61 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjI4/MDAxNjIyODk2MzA2MjIz.awyaRZUbA_k6v47xK5uSF9svWPgcGXThY7AWVHgNH_0g.FzYznnXsc7DSRFFiWiQaW68BG-ov9PiXtrIBJMlM--wg.PNG.shinee_p98/cool_lightpink.png', | ||
62 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTkz/MDAxNjIyODk2MzA2Nzcy.5pVm-2ukqx1x2VroSSDWmQKKu2EPKa7BtED5lRYe5N0g.ExNtgy9xwg1j0mlNYTcKiAM19yY1uD0asPqh8KJ2w8Ig.PNG.shinee_p98/cool_lightpurple.png', | ||
63 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfOTUg/MDAxNjIyODk2MzA2NTg5.V5hY0iUFv_dNvrCll28JPt7hKrUQbNjAOluN7ReUJs8g.cYlHBSchsXteGKf6_gtRRGdmai6PqZ1ajZCnJMTR29gg.PNG.shinee_p98/cool_mint.png', | ||
64 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMzkg/MDAxNjIyODk2MzA2Mjkz.S9tKvHLMX-RSAU54WtJ_ZlH7M3yK1St-0PNqJZDSNhAg.PSG061nHMDzi2tuoYXsvk4XYr0rnoiTaDn36GXDjZygg.PNG.shinee_p98/cool_navy.png', | ||
65 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg2/MDAxNjIyODk2MzA2MjYz.i_SsCrDngVCULfEOnURDex0qSyzvNlsX8LjFg6A92Hog.zfYNYbn9xxPkUFY2YEl1Sn0aTs8OZ7f6FNx_p0TcCzkg.PNG.shinee_p98/cool_pink.png', | ||
66 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQg/MDAxNjIyODk2MzA2NTI4.tSHaux34joMni8wd6VtlOJO2EvW5aQI8xfWlxtVKrrog.sH4_FDJuPIg7r2jhpe1EDU9fbFY_UsmH9khN2sAgbfsg.JPEG.shinee_p98/cool_yellow.jpg' | ||
67 | -] | ||
68 | - | ||
69 | -var cool_previews=[ | ||
70 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTcz/MDAxNjIyODk2MzA2MjA5.DLpREPAip4NyaJH3lydWGKjE1CvlO_1D7oBjLur9iF4g.lsXyiwgipMXvJHkRFQZPe7habxxrjrVzXBMoRv4qrZwg.PNG.shinee_p98/cool_blue/preview.png', | ||
71 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjI4/MDAxNjIyODk2MzA2MjIz.awyaRZUbA_k6v47xK5uSF9svWPgcGXThY7AWVHgNH_0g.FzYznnXsc7DSRFFiWiQaW68BG-ov9PiXtrIBJMlM--wg.PNG.shinee_p98/cool_lightpink/preview.png', | ||
72 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTkz/MDAxNjIyODk2MzA2Nzcy.5pVm-2ukqx1x2VroSSDWmQKKu2EPKa7BtED5lRYe5N0g.ExNtgy9xwg1j0mlNYTcKiAM19yY1uD0asPqh8KJ2w8Ig.PNG.shinee_p98/cool_lightpurple/preview.png', | ||
73 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfOTUg/MDAxNjIyODk2MzA2NTg5.V5hY0iUFv_dNvrCll28JPt7hKrUQbNjAOluN7ReUJs8g.cYlHBSchsXteGKf6_gtRRGdmai6PqZ1ajZCnJMTR29gg.PNG.shinee_p98/cool_mint/preview.png', | ||
74 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMzkg/MDAxNjIyODk2MzA2Mjkz.S9tKvHLMX-RSAU54WtJ_ZlH7M3yK1St-0PNqJZDSNhAg.PSG061nHMDzi2tuoYXsvk4XYr0rnoiTaDn36GXDjZygg.PNG.shinee_p98/cool_navy/preview.png', | ||
75 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg2/MDAxNjIyODk2MzA2MjYz.i_SsCrDngVCULfEOnURDex0qSyzvNlsX8LjFg6A92Hog.zfYNYbn9xxPkUFY2YEl1Sn0aTs8OZ7f6FNx_p0TcCzkg.PNG.shinee_p98/cool_pink/preview.png', | ||
76 | - 'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQg/MDAxNjIyODk2MzA2NTI4.tSHaux34joMni8wd6VtlOJO2EvW5aQI8xfWlxtVKrrog.sH4_FDJuPIg7r2jhpe1EDU9fbFY_UsmH9khN2sAgbfsg.JPEG.shinee_p98/cool_yellow/preview.jpg' | ||
77 | -] | ||
78 | - | ||
79 | - | ||
80 | 66 | ||
81 | const bodyParser = require('body-parser'); | 67 | const bodyParser = require('body-parser'); |
82 | var app = express(); | 68 | var app = express(); |
83 | 69 | ||
84 | - | ||
85 | request.post( | 70 | request.post( |
86 | { | 71 | { |
87 | url: BROAD_TARGET_URL, | 72 | url: BROAD_TARGET_URL, |
... | @@ -92,11 +77,11 @@ request.post( | ... | @@ -92,11 +77,11 @@ request.post( |
92 | "messages": [ | 77 | "messages": [ |
93 | { | 78 | { |
94 | "type": "text", | 79 | "type": "text", |
95 | - "text": "안녕하세요! " | 80 | + "text": "STEP1: 제시된 질문에 대하여 자신에게 더 맞는 선택지를 고르세요 [1/2]" |
96 | }, | 81 | }, |
97 | { | 82 | { |
98 | "type": "text", | 83 | "type": "text", |
99 | - "text": "제시되는 4가지 사진 중 자신의 피부와 가장 잘 어울리는 사진의 번호를 입력하세요" | 84 | + "text": "STEP2: 제시된 이미지를 자신의 피부 위에 두고 자신에게 더 어울리는 색깔을 고르세요 [1/2]" |
100 | }, | 85 | }, |
101 | { | 86 | { |
102 | "type": "text", | 87 | "type": "text", |
... | @@ -105,30 +90,29 @@ request.post( | ... | @@ -105,30 +90,29 @@ request.post( |
105 | ] | 90 | ] |
106 | } | 91 | } |
107 | }, (error, response, body) => { | 92 | }, (error, response, body) => { |
108 | - console.log(body) | 93 | + console.log(body); |
109 | }); | 94 | }); |
110 | 95 | ||
111 | 96 | ||
112 | - | ||
113 | app.use(bodyParser.json()); | 97 | app.use(bodyParser.json()); |
114 | 98 | ||
115 | - | ||
116 | app.post('/hook', function (req, res) { | 99 | app.post('/hook', function (req, res) { |
117 | var eventObj = req.body.events[0]; | 100 | var eventObj = req.body.events[0]; |
118 | var source = eventObj.source; | 101 | var source = eventObj.source; |
119 | var message = eventObj.message; | 102 | var message = eventObj.message; |
120 | - | 103 | + |
121 | - TestSkinType(eventObj.replyToken, eventObj.message.text) | 104 | + TestSkinType(eventObj.replyToken, eventObj.message.text); |
122 | - Color_Test(eventObj.replyToken, eventObj.message.text) | 105 | + Color_Test(eventObj.replyToken, eventObj.message.text); |
123 | - if(YourSkinTypeIs(warm,cool)==0) Get_warmColor(eventObj.replyToken, eventObj.message.text); | 106 | + |
124 | - else if(YourSkinTypeIs(warm,cool)==1) Get_coolColor(eventObj.replyToken, eventObj.message.text); | 107 | + if (YourSkinTypeIs(warm, cool) === 0) Get_warmColor(eventObj.replyToken, eventObj.message.text); |
108 | + | ||
109 | + else if (YourSkinTypeIs(warm, cool) == 1) Get_coolColor(eventObj.replyToken, eventObj.message.text); | ||
125 | 110 | ||
126 | res.sendStatus(200); | 111 | res.sendStatus(200); |
112 | + | ||
127 | }); | 113 | }); |
128 | 114 | ||
129 | 115 | ||
130 | - | ||
131 | - | ||
132 | function TestSkinType(replyToken, message) { | 116 | function TestSkinType(replyToken, message) { |
133 | if (message == "start") { | 117 | if (message == "start") { |
134 | request.post( | 118 | request.post( |
... | @@ -147,16 +131,15 @@ function TestSkinType(replyToken, message) { | ... | @@ -147,16 +131,15 @@ function TestSkinType(replyToken, message) { |
147 | ], | 131 | ], |
148 | } | 132 | } |
149 | }, (error, response, body) => { | 133 | }, (error, response, body) => { |
150 | - console.log(body) | 134 | + console.log(body); |
151 | }); | 135 | }); |
152 | } | 136 | } |
153 | } | 137 | } |
154 | 138 | ||
155 | 139 | ||
156 | - | ||
157 | function Color_Test(replyToken, message) { | 140 | function Color_Test(replyToken, message) { |
158 | if (message == "1" || message == "2" || message == "3" || message == "4") { | 141 | if (message == "1" || message == "2" || message == "3" || message == "4") { |
159 | - if(message=="1" || message =="2"){ | 142 | + if (message == "1" || message == "2") { |
160 | request.post( | 143 | request.post( |
161 | { | 144 | { |
162 | url: TARGET_URL, | 145 | url: TARGET_URL, |
... | @@ -169,18 +152,15 @@ function Color_Test(replyToken, message) { | ... | @@ -169,18 +152,15 @@ function Color_Test(replyToken, message) { |
169 | { | 152 | { |
170 | "type": "text", | 153 | "type": "text", |
171 | "text": Questions[i], | 154 | "text": Questions[i], |
172 | - | ||
173 | }, | 155 | }, |
174 | ], | 156 | ], |
175 | } | 157 | } |
176 | }, (error, response, body) => { | 158 | }, (error, response, body) => { |
177 | - console.log(body) | 159 | + console.log(body); |
178 | }); | 160 | }); |
179 | - | ||
180 | - | ||
181 | } | 161 | } |
182 | - if(QuestionCount<=0){ | 162 | + if (QuestionCount <= 0) { |
183 | - if(YourSkinTypeIs(warm,cool)==0){ | 163 | + if (YourSkinTypeIs(warm, cool) === 0) { |
184 | request.post( | 164 | request.post( |
185 | { | 165 | { |
186 | url: TARGET_URL, | 166 | url: TARGET_URL, |
... | @@ -193,15 +173,15 @@ function Color_Test(replyToken, message) { | ... | @@ -193,15 +173,15 @@ function Color_Test(replyToken, message) { |
193 | { | 173 | { |
194 | "type": "image", | 174 | "type": "image", |
195 | "originalContentUrl": warm_files[j], | 175 | "originalContentUrl": warm_files[j], |
196 | - "previewImageUrl": warm_previews[j], | 176 | + "previewImageUrl": warm_files[j], |
197 | }, | 177 | }, |
198 | ], | 178 | ], |
199 | } | 179 | } |
200 | }, (error, response, body) => { | 180 | }, (error, response, body) => { |
201 | - console.log(body) | 181 | + console.log(body); |
202 | }); | 182 | }); |
203 | } | 183 | } |
204 | - else if(YourSkinTypeIs(warm,cool)==1){ | 184 | + else if (YourSkinTypeIs(warm, cool) == 1) { |
205 | request.post( | 185 | request.post( |
206 | { | 186 | { |
207 | url: TARGET_URL, | 187 | url: TARGET_URL, |
... | @@ -214,20 +194,17 @@ function Color_Test(replyToken, message) { | ... | @@ -214,20 +194,17 @@ function Color_Test(replyToken, message) { |
214 | { | 194 | { |
215 | "type": "image", | 195 | "type": "image", |
216 | "originalContentUrl": cool_files[j], | 196 | "originalContentUrl": cool_files[j], |
217 | - "previewImageUrl": cool_previews[j], | 197 | + "previewImageUrl": cool_files[j], |
218 | }, | 198 | }, |
219 | ], | 199 | ], |
220 | } | 200 | } |
221 | }, (error, response, body) => { | 201 | }, (error, response, body) => { |
222 | - console.log(body) | 202 | + console.log(body); |
223 | }); | 203 | }); |
224 | } | 204 | } |
225 | - | ||
226 | } | 205 | } |
227 | - | ||
228 | - | ||
229 | } | 206 | } |
230 | - if (count == 0) { | 207 | + if (count === 0) { |
231 | request.post( | 208 | request.post( |
232 | { | 209 | { |
233 | url: TARGET_URL, | 210 | url: TARGET_URL, |
... | @@ -244,71 +221,62 @@ function Color_Test(replyToken, message) { | ... | @@ -244,71 +221,62 @@ function Color_Test(replyToken, message) { |
244 | ], | 221 | ], |
245 | } | 222 | } |
246 | }, (error, response, body) => { | 223 | }, (error, response, body) => { |
247 | - console.log(body) | 224 | + console.log(body); |
248 | }); | 225 | }); |
249 | } | 226 | } |
250 | - if (message == "1"){ | 227 | + if (message == "1") { |
251 | - warm +=1 | 228 | + warm += 1; |
252 | } | 229 | } |
253 | - else if (message == "2"){ | 230 | + else if (message == "2") { |
254 | - cool += 1 | 231 | + cool += 1; |
255 | } | 232 | } |
256 | - if(QuestionCount<0){ | 233 | + if (QuestionCount < 0) { |
257 | - if (message =='1' && YourSkinTypeIs(warm,cool)==0) spring+=1 | 234 | + if (message == '1' && YourSkinTypeIs(warm, cool) === 0) spring += 1; |
258 | - else if(message=='2' && YourSkinTypeIs(warm,cool) ==0) fall+=1 | 235 | + else if (message == '2' && YourSkinTypeIs(warm, cool) === 0) fall += 1; |
259 | - else if(message=='1' && YourSkinTypeIs(warm,cool)==1) summer +=1 | 236 | + else if (message == '1' && YourSkinTypeIs(warm, cool) == 1) summer += 1; |
260 | - else if(message=='2' && YourSkinTypeIs(warm,cool)==1) winter+=1 | 237 | + else if (message == '2' && YourSkinTypeIs(warm, cool) == 1) winter += 1; |
261 | } | 238 | } |
262 | 239 | ||
263 | - console.log(spring, summer, fall, winter) | 240 | + i += 1; |
264 | - console.log('warm: ', warm ,'cool: ',cool) | 241 | + j += 1; |
265 | - i += 1 | 242 | + QuestionCount -= 1; |
266 | - j += 1 | 243 | + count -= 1; |
267 | - QuestionCount -=1; | ||
268 | - count -= 1 | ||
269 | - | ||
270 | - YourSkinTypeIs(warm,cool); | ||
271 | - | ||
272 | - if(YourSkinTypeIs(warm,cool)==0){ | ||
273 | - YourWarmColorIs(spring,fall); | ||
274 | - } | ||
275 | - else YourCoolColorIs(summer,winter); | ||
276 | 244 | ||
277 | - if (YourWarmColorIs(spring,fall) == 0) console.log("봄웜") | 245 | + YourSkinTypeIs(warm, cool); |
278 | - if (YourWarmColorIs(spring,fall) == 1) console.log("가을웜") | 246 | + if (YourSkinTypeIs(warm, cool) === 0) { |
279 | - if (YourCoolColorIs(summer,winter) == 3) console.log("여름쿨") | 247 | + YourWarmColorIs(spring, fall); |
280 | - if (YourCoolColorIs(summer,winter) == 4) console.log("겨울쿨") | 248 | + } |
249 | + else YourCoolColorIs(summer, winter); | ||
281 | } | 250 | } |
282 | 251 | ||
283 | -function YourSkinTypeIs(warm,cool){ | ||
284 | - var WarmOrCool=[warm,cool]; | ||
285 | - if(warm>cool){ | ||
286 | - skinIndex=0; | ||
287 | - } | ||
288 | - else skinIndex=1; | ||
289 | 252 | ||
253 | +function YourSkinTypeIs(warm, cool) { | ||
254 | + var WarmOrCool = [warm, cool]; | ||
255 | + if (warm > cool) { | ||
256 | + skinIndex = 0; | ||
257 | + } | ||
258 | + else skinIndex = 1; | ||
290 | return skinIndex; | 259 | return skinIndex; |
291 | } | 260 | } |
292 | 261 | ||
293 | 262 | ||
294 | - | ||
295 | function YourWarmColorIs(spring, fall) { | 263 | function YourWarmColorIs(spring, fall) { |
296 | - if(spring>fall) warm_index=0 | 264 | + if (spring > fall) warm_index = 0; |
297 | - else warm_index=1 | 265 | + else warm_index = 1; |
298 | - | ||
299 | return warm_index; | 266 | return warm_index; |
300 | } | 267 | } |
301 | 268 | ||
302 | -function YourCoolColorIs(summer,winter){ | 269 | + |
303 | - if(summer>winter) cool_index=3 | 270 | +function YourCoolColorIs(summer, winter) { |
304 | - else cool_index=4 | 271 | + if (summer > winter) cool_index = 3 |
272 | + else cool_index = 4 | ||
305 | return cool_index; | 273 | return cool_index; |
306 | } | 274 | } |
307 | 275 | ||
308 | 276 | ||
309 | function Get_warmColor(replyToken, message) { | 277 | function Get_warmColor(replyToken, message) { |
310 | if (message == "Y") { | 278 | if (message == "Y") { |
311 | - if (YourWarmColorIs(spring,fall) == 0) { | 279 | + if (YourWarmColorIs(spring, fall) == 0) { |
312 | request.post( | 280 | request.post( |
313 | { | 281 | { |
314 | url: TARGET_URL, | 282 | url: TARGET_URL, |
... | @@ -319,16 +287,21 @@ function Get_warmColor(replyToken, message) { | ... | @@ -319,16 +287,21 @@ function Get_warmColor(replyToken, message) { |
319 | "replyToken": replyToken, | 287 | "replyToken": replyToken, |
320 | "messages": [ | 288 | "messages": [ |
321 | { | 289 | { |
322 | - "type": "text", | 290 | + "type": "image", |
323 | - "text": "너는 봄웜" | 291 | + "originalContentUrl": 'https://personal-color-chatbot.s3.amazonaws.com/warm_spring.png', |
292 | + "previewImageUrl": 'https://personal-color-chatbot.s3.amazonaws.com/warm_spring.png', | ||
324 | }, | 293 | }, |
294 | + { | ||
295 | + "type": "text", | ||
296 | + "text": "당신의 퍼스널 컬러는 '봄 웜'입니다.\nBEST: 명도가 높고 채도가 낮은 색상 \nWORST: 전체적으로 흰 빛과 푸른 빛이 감도는 색상, 또는 무채색" | ||
297 | + } | ||
325 | ], | 298 | ], |
326 | } | 299 | } |
327 | }, (error, response, body) => { | 300 | }, (error, response, body) => { |
328 | console.log(body) | 301 | console.log(body) |
329 | }); | 302 | }); |
330 | } | 303 | } |
331 | - if (YourWarmColorIs(spring,fall) == 1) { | 304 | + if (YourWarmColorIs(spring, fall) == 1) { |
332 | request.post( | 305 | request.post( |
333 | { | 306 | { |
334 | url: TARGET_URL, | 307 | url: TARGET_URL, |
... | @@ -339,8 +312,13 @@ function Get_warmColor(replyToken, message) { | ... | @@ -339,8 +312,13 @@ function Get_warmColor(replyToken, message) { |
339 | "replyToken": replyToken, | 312 | "replyToken": replyToken, |
340 | "messages": [ | 313 | "messages": [ |
341 | { | 314 | { |
315 | + "type": "image", | ||
316 | + "originalContentUrl": 'https://personal-color-chatbot.s3.amazonaws.com/warm_fall.png', | ||
317 | + "previewImageUrl": 'https://personal-color-chatbot.s3.amazonaws.com/warm_fall.png', | ||
318 | + }, | ||
319 | + { | ||
342 | "type": "text", | 320 | "type": "text", |
343 | - "text": "너는 가을웜" | 321 | + "text": "당신의 퍼스널 컬러는 '가을 웜'입니다.\nBEST: 명도와 채도가 낮고 탁한톤의 색상, 노랑과 검정이 섞여있는 색상 \nWORST: 찬 계열의 색상과 파스텔톤" |
344 | }, | 322 | }, |
345 | ], | 323 | ], |
346 | } | 324 | } |
... | @@ -348,12 +326,13 @@ function Get_warmColor(replyToken, message) { | ... | @@ -348,12 +326,13 @@ function Get_warmColor(replyToken, message) { |
348 | console.log(body) | 326 | console.log(body) |
349 | }); | 327 | }); |
350 | } | 328 | } |
329 | + } | ||
351 | } | 330 | } |
352 | -} | ||
353 | 331 | ||
354 | -function Get_coolColor(replyToken,message){ | 332 | + |
355 | - if (message=="Y"){ | 333 | +function Get_coolColor(replyToken, message) { |
356 | - if (YourCoolColorIs(summer,winter) == 3) { | 334 | + if (message == "Y") { |
335 | + if (YourCoolColorIs(summer, winter) == 3) { | ||
357 | request.post( | 336 | request.post( |
358 | { | 337 | { |
359 | url: TARGET_URL, | 338 | url: TARGET_URL, |
... | @@ -364,8 +343,13 @@ function Get_coolColor(replyToken,message){ | ... | @@ -364,8 +343,13 @@ function Get_coolColor(replyToken,message){ |
364 | "replyToken": replyToken, | 343 | "replyToken": replyToken, |
365 | "messages": [ | 344 | "messages": [ |
366 | { | 345 | { |
346 | + "type": "image", | ||
347 | + "originalContentUrl": 'https://personal-color-chatbot.s3.amazonaws.com/cool_summer.png', | ||
348 | + "previewImageUrl": 'https://personal-color-chatbot.s3.amazonaws.com/cool_summer.png', | ||
349 | + }, | ||
350 | + { | ||
367 | "type": "text", | 351 | "type": "text", |
368 | - "text": "너는 여름쿨" | 352 | + "text": "당신의 퍼스널 컬러는 '여름 쿨'입니다.\nBEST: 명도는 높고 채도는 낮은 톤, 흰색과 파랑 톤의 기운이 느껴지는 색상\nWORST: 검은색과 너무 어두운색, 금속성의 반사적인 색, 노란기미가 있는 색" |
369 | }, | 353 | }, |
370 | ], | 354 | ], |
371 | } | 355 | } |
... | @@ -373,7 +357,7 @@ function Get_coolColor(replyToken,message){ | ... | @@ -373,7 +357,7 @@ function Get_coolColor(replyToken,message){ |
373 | console.log(body) | 357 | console.log(body) |
374 | }); | 358 | }); |
375 | } | 359 | } |
376 | - if (YourCoolColorIs(summer,winter) == 4) { | 360 | + if (YourCoolColorIs(summer, winter) == 4) { |
377 | request.post( | 361 | request.post( |
378 | { | 362 | { |
379 | url: TARGET_URL, | 363 | url: TARGET_URL, |
... | @@ -384,8 +368,13 @@ function Get_coolColor(replyToken,message){ | ... | @@ -384,8 +368,13 @@ function Get_coolColor(replyToken,message){ |
384 | "replyToken": replyToken, | 368 | "replyToken": replyToken, |
385 | "messages": [ | 369 | "messages": [ |
386 | { | 370 | { |
371 | + "type": "image", | ||
372 | + "originalContentUrl": 'https://personal-color-chatbot.s3.amazonaws.com/cool_winter.png', | ||
373 | + "previewImageUrl": 'https://personal-color-chatbot.s3.amazonaws.com/cool_winter.png', | ||
374 | + }, | ||
375 | + { | ||
387 | "type": "text", | 376 | "type": "text", |
388 | - "text": "너는 겨울쿨" | 377 | + "text": "당신의 퍼스널 컬러는 '겨울 쿨'입니다.\nBEST: 명도와 채도가 높은 톤, 푸르면서 흰색이 기본 색상\nWORST: 황금색 계열" |
389 | }, | 378 | }, |
390 | ], | 379 | ], |
391 | } | 380 | } |
... | @@ -397,8 +386,6 @@ function Get_coolColor(replyToken,message){ | ... | @@ -397,8 +386,6 @@ function Get_coolColor(replyToken,message){ |
397 | } | 386 | } |
398 | 387 | ||
399 | 388 | ||
400 | - | ||
401 | - | ||
402 | try { | 389 | try { |
403 | const option = { | 390 | const option = { |
404 | ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'), | 391 | ca: fs.readFileSync('/etc/letsencrypt/live/' + domain + '/fullchain.pem'), |
... | @@ -411,4 +398,4 @@ try { | ... | @@ -411,4 +398,4 @@ try { |
411 | } catch (error) { | 398 | } catch (error) { |
412 | console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); | 399 | console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'); |
413 | console.log(error); | 400 | console.log(error); |
414 | -} | 401 | +} |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment