Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오규림
/
Personal_color_chatbot
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
오규림
2021-06-05 22:20:33 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e686ee36eb184b7211b489bde359357167a7cdff
e686ee36
1 parent
21299120
Update function & Add Questions
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
202 additions
and
98 deletions
app.js
app.js
View file @
e686ee3
// ------------- 2019102195 ------------------
var
express
=
require
(
'express'
);
const
request
=
require
(
'request'
);
const
TARGET_URL
=
'https://api.line.me/v2/bot/message/reply'
const
MULTI_TARGET_URL
=
'https://api.line.me/v2/bot/message/multicast'
const
BROAD_TARGET_URL
=
'https://api.line.me/v2/bot/message/broadcast'
const
fs
=
require
(
'fs'
);
const
path
=
require
(
'path'
);
const
HTTPS
=
require
(
'https'
);
const
sslport
=
23023
;
var
spring
=
0
var
summer
=
0
var
fall
=
0
var
winter
=
0
var
warm
=
0
var
cool
=
0
var
warm_index
=
0
var
cool_index
=
0
var
skinIndex
=
0
var
i
=
0
var
j
=
-
9
var
QuestionCount
=
9
var
QuestionIndex
=
0
var
count
=
16
var
WarmOrCool
=
[
warm
,
cool
];
var
season_color
=
[
spring
,
summer
,
fall
,
winter
]
var
Questions
=
[
'Q1: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q2: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q3: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q4: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q5: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q6: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q7: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q8: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
,
'Q9: 당신은 어떤 것이 어울리나요? [ 1 / 2 ]'
]
var
warm_files
=
[
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg5/MDAxNjIyODk2MjQ1NDgy.GD_Uc2qXefDyVgwQ4NoYsYBCoFDI-W45ghNz3ImB_lEg.DtbZwnsqWUB8alA5gtk78B6dKd6UbwHRyUEsTMZn15Yg.PNG.shinee_p98/warm_carmel.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTU1/MDAxNjIyODk2MjQ1NjM0.-YA2roNdR9unkGH0TpTOwcuME5O8jFdmTd_PRQ8XjhQg.FCN4aAzGiM7rpCMsALcXTC2GclwdPH2yU0EehtKS05Ig.PNG.shinee_p98/warm_coral.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjE1/MDAxNjIyODk2MjQ1Njk5._QgVhB-Djm4Ew67ys3Vmv2tQ3etNQ6gaLgCk7DBcdO8g.41j4dUE05LFKyfKxkVDeRIqSoyikWYvDENLhgBZjAAYg.PNG.shinee_p98/warm_green.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjk1/MDAxNjIyODk2MjQ1NzQ3._62ZktQ5_GgRFc9ci0tOYTIQzcpbB-8mBNC3AkPFdgUg.FlZmBkchPnw0XGXGPC44OOnqiqAoROW7wcAj0q6ZNmsg.PNG.shinee_p98/warm_mint.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQy/MDAxNjIyODk2MjQ1NzM3.FIkcxRPdgW-PQamsCmTAIx6kCGJcaj83w6sg0bFXP9kg.iD-aye9VnbhuRzBsautBFm6aSB_2JArIbrHywJj8ol8g.PNG.shinee_p98/warm_purple.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMzgg/MDAxNjIyODk2MjQ1NTc3.-ZmUf9IxcwX53bb9O-wKR4UtFUjji9toUMW0mIGeveQg.y-GV04bv3VxvU64OcAcZMROPb4SzvOjkuZOSMnuyRicg.PNG.shinee_p98/warm_softgreen.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTMx/MDAxNjIyODk2MjQ2MjQz.5OuoiEz9j5RT4ypwrA1ncqN_XFR7to4DiiE0hL6AUdEg.VjGhPCDrj0e3FNxbzGYMQncgImY9M1t5mOZSn_Zvejog.PNG.shinee_p98/warm_yellow.png'
]
var
warm_previews
=
[
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg5/MDAxNjIyODk2MjQ1NDgy.GD_Uc2qXefDyVgwQ4NoYsYBCoFDI-W45ghNz3ImB_lEg.DtbZwnsqWUB8alA5gtk78B6dKd6UbwHRyUEsTMZn15Yg.PNG.shinee_p98/warm_carmel/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTU1/MDAxNjIyODk2MjQ1NjM0.-YA2roNdR9unkGH0TpTOwcuME5O8jFdmTd_PRQ8XjhQg.FCN4aAzGiM7rpCMsALcXTC2GclwdPH2yU0EehtKS05Ig.PNG.shinee_p98/warm_coral/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjE1/MDAxNjIyODk2MjQ1Njk5._QgVhB-Djm4Ew67ys3Vmv2tQ3etNQ6gaLgCk7DBcdO8g.41j4dUE05LFKyfKxkVDeRIqSoyikWYvDENLhgBZjAAYg.PNG.shinee_p98/warm_green/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjk1/MDAxNjIyODk2MjQ1NzQ3._62ZktQ5_GgRFc9ci0tOYTIQzcpbB-8mBNC3AkPFdgUg.FlZmBkchPnw0XGXGPC44OOnqiqAoROW7wcAj0q6ZNmsg.PNG.shinee_p98/warm_mint/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQy/MDAxNjIyODk2MjQ1NzM3.FIkcxRPdgW-PQamsCmTAIx6kCGJcaj83w6sg0bFXP9kg.iD-aye9VnbhuRzBsautBFm6aSB_2JArIbrHywJj8ol8g.PNG.shinee_p98/warm_purple/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMzgg/MDAxNjIyODk2MjQ1NTc3.-ZmUf9IxcwX53bb9O-wKR4UtFUjji9toUMW0mIGeveQg.y-GV04bv3VxvU64OcAcZMROPb4SzvOjkuZOSMnuyRicg.PNG.shinee_p98/warm_softgreen/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTMx/MDAxNjIyODk2MjQ2MjQz.5OuoiEz9j5RT4ypwrA1ncqN_XFR7to4DiiE0hL6AUdEg.VjGhPCDrj0e3FNxbzGYMQncgImY9M1t5mOZSn_Zvejog.PNG.shinee_p98/warm_yellow/preview.png'
]
var
files
=
[
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTY0/MDAxNjIyNzI5NzM5NTQ5.JOX6SurxlH4Ip7rET53jG93MqyxB74mwouBh7beB7X0g.aC9QPmJmQPlFG9gMaGYJv_4uc0NZLeUI8GX0Gq6CRFUg.PNG.shinee_p98/brown.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTI4/MDAxNjIyNzI5NzQ3ODA3.CyDcjyTMLFqYJ_ECCQB6uhP5G96IlcjvneOBuf6OTlog.wMBN3zPFz7qUs6rYUmMetRV3_j0KxoA5hROt-Agts0Ag.PNG.shinee_p98/blue.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTU2/MDAxNjIyNzI5NzUyNjcz.Kk-ifPRihFIV_6U5rmo-JqTWEPHvJptzLBjRVh_36_Ig.v5Qu3GGWte5-swXhWb911TjsfDJ5welWfR7hPOrc7Jcg.PNG.shinee_p98/cyan.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjgy/MDAxNjIyNzI5NzU5MjA5.QUDMos5l0fTcjTokgIfrHuqy7UVF546VjRytwKItrNEg.aP3nTqJlvV3P2kZPLVA9ybcJ4k4_GiQjoHJICkHhLWwg.PNG.shinee_p98/green.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjEg/MDAxNjIyNzI5ODQyNDI5.BQd_licB-SC1fUbsbZBEwAiVHeqLffBSfxTIzMOYy5sg.6JzAY41JFZhQL9pa-B0HvEf4594017NxJ5dr2QDsth4g.PNG.shinee_p98/magenta.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTAw/MDAxNjIyNzI5ODQ3ODIx.hCVRLywItir-jvdf6dZ7NyIxmJC4PGc0HMufU9x8NCkg.EDGju3DjfxaydwBgai8NrSg8vZVKI0GMt3WXhIGckhUg.PNG.shinee_p98/orange.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjg0/MDAxNjIyNzI5ODUxOTA5.APYoGe3PsNbYWeaxiH87KLH2q3n6zOAJt4oC5QM8LEkg.bBMGuliyPvHXmb3hea344pa6rmTeDcor9YbaedD3NAEg.PNG.shinee_p98/purple.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjQ4/MDAxNjIyNzI5ODU1NzIw.fHgsAwcHld7WjzlfNWbN_Ui1CHGWAkheN9mJx5X5R34g.XuRPlq0ijc5GMO5MBRRizSBNHJyAOXkacwPEI2VasVwg.PNG.shinee_p98/red.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTY5/MDAxNjIyNzI5ODYwMjUw.Y1ancRsttM8SsbqE482zIpnrQS5HzJhzeC8YkuNav20g.5oC4Rclbpv65ntWPjdW8a_W3RgPUBQNjfRkIOoMuVkog.PNG.shinee_p98/white.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjkw/MDAxNjIyNzI5ODY0OTcw.r2_Ug2vWSRNnpLlOJjA_8G1Nj_RU3GxQE--0u-vxfxcg.bNJ1n-oZXx9F1YcLktt4Q3OyAiFnea0lOv_nN92XFUEg.PNG.shinee_p98/yellow.png'
var
cool_files
=
[
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTcz/MDAxNjIyODk2MzA2MjA5.DLpREPAip4NyaJH3lydWGKjE1CvlO_1D7oBjLur9iF4g.lsXyiwgipMXvJHkRFQZPe7habxxrjrVzXBMoRv4qrZwg.PNG.shinee_p98/cool_blue.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjI4/MDAxNjIyODk2MzA2MjIz.awyaRZUbA_k6v47xK5uSF9svWPgcGXThY7AWVHgNH_0g.FzYznnXsc7DSRFFiWiQaW68BG-ov9PiXtrIBJMlM--wg.PNG.shinee_p98/cool_lightpink.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTkz/MDAxNjIyODk2MzA2Nzcy.5pVm-2ukqx1x2VroSSDWmQKKu2EPKa7BtED5lRYe5N0g.ExNtgy9xwg1j0mlNYTcKiAM19yY1uD0asPqh8KJ2w8Ig.PNG.shinee_p98/cool_lightpurple.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfOTUg/MDAxNjIyODk2MzA2NTg5.V5hY0iUFv_dNvrCll28JPt7hKrUQbNjAOluN7ReUJs8g.cYlHBSchsXteGKf6_gtRRGdmai6PqZ1ajZCnJMTR29gg.PNG.shinee_p98/cool_mint.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMzkg/MDAxNjIyODk2MzA2Mjkz.S9tKvHLMX-RSAU54WtJ_ZlH7M3yK1St-0PNqJZDSNhAg.PSG061nHMDzi2tuoYXsvk4XYr0rnoiTaDn36GXDjZygg.PNG.shinee_p98/cool_navy.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg2/MDAxNjIyODk2MzA2MjYz.i_SsCrDngVCULfEOnURDex0qSyzvNlsX8LjFg6A92Hog.zfYNYbn9xxPkUFY2YEl1Sn0aTs8OZ7f6FNx_p0TcCzkg.PNG.shinee_p98/cool_pink.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQg/MDAxNjIyODk2MzA2NTI4.tSHaux34joMni8wd6VtlOJO2EvW5aQI8xfWlxtVKrrog.sH4_FDJuPIg7r2jhpe1EDU9fbFY_UsmH9khN2sAgbfsg.JPEG.shinee_p98/cool_yellow.jpg'
]
var
previews
=
[
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTY0/MDAxNjIyNzI5NzM5NTQ5.JOX6SurxlH4Ip7rET53jG93MqyxB74mwouBh7beB7X0g.aC9QPmJmQPlFG9gMaGYJv_4uc0NZLeUI8GX0Gq6CRFUg.PNG.shinee_p98/brown/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTI4/MDAxNjIyNzI5NzQ3ODA3.CyDcjyTMLFqYJ_ECCQB6uhP5G96IlcjvneOBuf6OTlog.wMBN3zPFz7qUs6rYUmMetRV3_j0KxoA5hROt-Agts0Ag.PNG.shinee_p98/blue/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTU2/MDAxNjIyNzI5NzUyNjcz.Kk-ifPRihFIV_6U5rmo-JqTWEPHvJptzLBjRVh_36_Ig.v5Qu3GGWte5-swXhWb911TjsfDJ5welWfR7hPOrc7Jcg.PNG.shinee_p98/cyan/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjgy/MDAxNjIyNzI5NzU5MjA5.QUDMos5l0fTcjTokgIfrHuqy7UVF546VjRytwKItrNEg.aP3nTqJlvV3P2kZPLVA9ybcJ4k4_GiQjoHJICkHhLWwg.PNG.shinee_p98/green/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjEg/MDAxNjIyNzI5ODQyNDI5.BQd_licB-SC1fUbsbZBEwAiVHeqLffBSfxTIzMOYy5sg.6JzAY41JFZhQL9pa-B0HvEf4594017NxJ5dr2QDsth4g.PNG.shinee_p98/magenta/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTAw/MDAxNjIyNzI5ODQ3ODIx.hCVRLywItir-jvdf6dZ7NyIxmJC4PGc0HMufU9x8NCkg.EDGju3DjfxaydwBgai8NrSg8vZVKI0GMt3WXhIGckhUg.PNG.shinee_p98/orange/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjg0/MDAxNjIyNzI5ODUxOTA5.APYoGe3PsNbYWeaxiH87KLH2q3n6zOAJt4oC5QM8LEkg.bBMGuliyPvHXmb3hea344pa6rmTeDcor9YbaedD3NAEg.PNG.shinee_p98/purple/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjQ4/MDAxNjIyNzI5ODU1NzIw.fHgsAwcHld7WjzlfNWbN_Ui1CHGWAkheN9mJx5X5R34g.XuRPlq0ijc5GMO5MBRRizSBNHJyAOXkacwPEI2VasVwg.PNG.shinee_p98/red/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMTY5/MDAxNjIyNzI5ODYwMjUw.Y1ancRsttM8SsbqE482zIpnrQS5HzJhzeC8YkuNav20g.5oC4Rclbpv65ntWPjdW8a_W3RgPUBQNjfRkIOoMuVkog.PNG.shinee_p98/white/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDNfMjkw/MDAxNjIyNzI5ODY0OTcw.r2_Ug2vWSRNnpLlOJjA_8G1Nj_RU3GxQE--0u-vxfxcg.bNJ1n-oZXx9F1YcLktt4Q3OyAiFnea0lOv_nN92XFUEg.PNG.shinee_p98/yellow/preview.png'
var
cool_previews
=
[
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTcz/MDAxNjIyODk2MzA2MjA5.DLpREPAip4NyaJH3lydWGKjE1CvlO_1D7oBjLur9iF4g.lsXyiwgipMXvJHkRFQZPe7habxxrjrVzXBMoRv4qrZwg.PNG.shinee_p98/cool_blue/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjI4/MDAxNjIyODk2MzA2MjIz.awyaRZUbA_k6v47xK5uSF9svWPgcGXThY7AWVHgNH_0g.FzYznnXsc7DSRFFiWiQaW68BG-ov9PiXtrIBJMlM--wg.PNG.shinee_p98/cool_lightpink/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTkz/MDAxNjIyODk2MzA2Nzcy.5pVm-2ukqx1x2VroSSDWmQKKu2EPKa7BtED5lRYe5N0g.ExNtgy9xwg1j0mlNYTcKiAM19yY1uD0asPqh8KJ2w8Ig.PNG.shinee_p98/cool_lightpurple/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfOTUg/MDAxNjIyODk2MzA2NTg5.V5hY0iUFv_dNvrCll28JPt7hKrUQbNjAOluN7ReUJs8g.cYlHBSchsXteGKf6_gtRRGdmai6PqZ1ajZCnJMTR29gg.PNG.shinee_p98/cool_mint/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMzkg/MDAxNjIyODk2MzA2Mjkz.S9tKvHLMX-RSAU54WtJ_ZlH7M3yK1St-0PNqJZDSNhAg.PSG061nHMDzi2tuoYXsvk4XYr0rnoiTaDn36GXDjZygg.PNG.shinee_p98/cool_navy/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMjg2/MDAxNjIyODk2MzA2MjYz.i_SsCrDngVCULfEOnURDex0qSyzvNlsX8LjFg6A92Hog.zfYNYbn9xxPkUFY2YEl1Sn0aTs8OZ7f6FNx_p0TcCzkg.PNG.shinee_p98/cool_pink/preview.png'
,
'https://postfiles.pstatic.net/MjAyMTA2MDVfMTQg/MDAxNjIyODk2MzA2NTI4.tSHaux34joMni8wd6VtlOJO2EvW5aQI8xfWlxtVKrrog.sH4_FDJuPIg7r2jhpe1EDU9fbFY_UsmH9khN2sAgbfsg.JPEG.shinee_p98/cool_yellow/preview.jpg'
]
var
i
=
0
var
count
=
10
const
MULTI_TARGET_URL
=
'https://api.line.me/v2/bot/message/multicast'
const
BROAD_TARGET_URL
=
'https://api.line.me/v2/bot/message/broadcast'
const
USER_ID
=
'Ub99bb2ebebbbc1e06efe715b76ec9fcd'
const
bodyParser
=
require
(
'body-parser'
);
var
app
=
express
();
request
.
post
(
{
url
:
BROAD_TARGET_URL
,
...
...
@@ -75,21 +109,27 @@ request.post(
});
app
.
use
(
bodyParser
.
json
());
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
app
.
post
(
'/hook'
,
function
(
req
,
res
)
{
var
eventObj
=
req
.
body
.
events
[
0
];
var
source
=
eventObj
.
source
;
var
message
=
eventObj
.
message
;
Start
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
)
TestSkinType
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
)
Color_Test
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
)
Get_Color
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
)
if
(
YourSkinTypeIs
(
warm
,
cool
)
==
0
)
Get_warmColor
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
else
if
(
YourSkinTypeIs
(
warm
,
cool
)
==
1
)
Get_coolColor
(
eventObj
.
replyToken
,
eventObj
.
message
.
text
);
res
.
sendStatus
(
200
);
});
function
Start
(
replyToken
,
message
)
{
function
TestSkinType
(
replyToken
,
message
)
{
if
(
message
==
"start"
)
{
request
.
post
(
{
...
...
@@ -101,12 +141,10 @@ function Start(replyToken, message) {
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"image"
,
"originalContentUrl"
:
files
[
0
],
"previewImageUrl"
:
previews
[
0
],
"type"
:
"text"
,
"text"
:
Questions
[
0
],
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
...
...
@@ -115,30 +153,79 @@ function Start(replyToken, message) {
}
var
index
=
0
function
Color_Test
(
replyToken
,
message
)
{
function
Color_Test
(
replyToken
,
message
)
{
if
(
message
==
"1"
||
message
==
"2"
||
message
==
"3"
||
message
==
"4"
)
{
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"image"
,
"originalContentUrl"
:
files
[
i
],
"previewImageUrl"
:
previews
[
i
],
},
],
if
(
message
==
"1"
||
message
==
"2"
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
Questions
[
i
],
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
QuestionCount
<=
0
){
if
(
YourSkinTypeIs
(
warm
,
cool
)
==
0
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"image"
,
"originalContentUrl"
:
warm_files
[
j
],
"previewImageUrl"
:
warm_previews
[
j
],
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
else
if
(
YourSkinTypeIs
(
warm
,
cool
)
==
1
){
request
.
post
(
{
url
:
TARGET_URL
,
headers
:
{
'Authorization'
:
`Bearer
${
TOKEN
}
`
},
json
:
{
"replyToken"
:
replyToken
,
"messages"
:
[
{
"type"
:
"image"
,
"originalContentUrl"
:
cool_files
[
j
],
"previewImageUrl"
:
cool_previews
[
j
],
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
}
}
if
(
count
==
0
)
{
request
.
post
(
...
...
@@ -155,53 +242,73 @@ function Color_Test(replyToken, message) {
"text"
:
"테스트가 완료되었습니다. 결과를 확인하시겠습니까? [Y/N] "
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
message
==
"1"
)
spring
+=
1
else
if
(
message
==
"2"
)
summer
+=
1
else
if
(
message
==
"3"
)
fall
+=
1
else
if
(
message
==
"4"
)
winter
+=
1
if
(
message
==
"1"
){
warm
+=
1
}
else
if
(
message
==
"2"
){
cool
+=
1
}
if
(
QuestionCount
<
0
){
if
(
message
==
'1'
&&
YourSkinTypeIs
(
warm
,
cool
)
==
0
)
spring
+=
1
else
if
(
message
==
'2'
&&
YourSkinTypeIs
(
warm
,
cool
)
==
0
)
fall
+=
1
else
if
(
message
==
'1'
&&
YourSkinTypeIs
(
warm
,
cool
)
==
1
)
summer
+=
1
else
if
(
message
==
'2'
&&
YourSkinTypeIs
(
warm
,
cool
)
==
1
)
winter
+=
1
}
console
.
log
(
spring
,
summer
,
fall
,
winter
)
console
.
log
(
'warm: '
,
warm
,
'cool: '
,
cool
)
i
+=
1
j
+=
1
QuestionCount
-=
1
;
count
-=
1
Your
ColorIs
(
spring
,
summer
,
fall
,
winter
)
Your
SkinTypeIs
(
warm
,
cool
);
if
(
YourColorIs
(
spring
,
summer
,
fall
,
winter
)
==
0
)
console
.
log
(
"봄웜"
)
if
(
YourColorIs
(
spring
,
summer
,
fall
,
winter
)
==
1
)
console
.
log
(
"여름쿨"
)
if
(
YourColorIs
(
spring
,
summer
,
fall
,
winter
)
==
2
)
console
.
log
(
"가을웜"
)
if
(
YourColorIs
(
spring
,
summer
,
fall
,
winter
)
==
3
)
console
.
log
(
"겨울쿨"
)
if
(
YourSkinTypeIs
(
warm
,
cool
)
==
0
){
YourWarmColorIs
(
spring
,
fall
);
}
else
YourCoolColorIs
(
summer
,
winter
);
if
(
YourWarmColorIs
(
spring
,
fall
)
==
0
)
console
.
log
(
"봄웜"
)
if
(
YourWarmColorIs
(
spring
,
fall
)
==
1
)
console
.
log
(
"가을웜"
)
if
(
YourCoolColorIs
(
summer
,
winter
)
==
3
)
console
.
log
(
"여름쿨"
)
if
(
YourCoolColorIs
(
summer
,
winter
)
==
4
)
console
.
log
(
"겨울쿨"
)
}
function
YourColorIs
(
spring
,
summer
,
fall
,
winter
)
{
function
YourSkinTypeIs
(
warm
,
cool
){
var
WarmOrCool
=
[
warm
,
cool
];
if
(
warm
>
cool
){
skinIndex
=
0
;
}
else
skinIndex
=
1
;
var
season_color
=
[
spring
,
summer
,
fall
,
winter
]
var
max
=
season_color
[
0
]
return
skinIndex
;
}
for
(
var
i
=
0
;
i
<
4
;
i
++
)
{
if
(
season_color
[
i
]
>
max
)
{
max
=
season_color
[
i
]
index
=
i
}
}
console
.
log
(
"index"
,
index
)
return
index
function
YourWarmColorIs
(
spring
,
fall
)
{
if
(
spring
>
fall
)
warm_index
=
0
else
warm_index
=
1
return
warm_index
;
}
function
YourCoolColorIs
(
summer
,
winter
){
if
(
summer
>
winter
)
cool_index
=
3
else
cool_index
=
4
return
cool_index
;
}
function
Get_Color
(
replyToken
,
message
)
{
function
Get_
warm
Color
(
replyToken
,
message
)
{
if
(
message
==
"Y"
)
{
if
(
Your
ColorIs
(
spring
,
summer
,
fall
,
winter
)
==
0
)
{
if
(
Your
WarmColorIs
(
spring
,
fall
)
==
0
)
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -216,13 +323,12 @@ function Get_Color(replyToken, message) {
"text"
:
"너는 봄웜"
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
Your
ColorIs
(
spring
,
summer
,
fall
,
winter
)
==
1
)
{
if
(
Your
WarmColorIs
(
spring
,
fall
)
==
1
)
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -234,16 +340,20 @@ function Get_Color(replyToken, message) {
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"너는
여름쿨
"
"text"
:
"너는
가을웜
"
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
YourColorIs
(
spring
,
summer
,
fall
,
winter
)
==
2
)
{
}
}
function
Get_coolColor
(
replyToken
,
message
){
if
(
message
==
"Y"
){
if
(
YourCoolColorIs
(
summer
,
winter
)
==
3
)
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -255,16 +365,15 @@ function Get_Color(replyToken, message) {
"messages"
:
[
{
"type"
:
"text"
,
"text"
:
"너는
가을웜
"
"text"
:
"너는
여름쿨
"
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
if
(
YourCo
lorIs
(
spring
,
summer
,
fall
,
winter
)
==
4
)
{
if
(
YourCo
olColorIs
(
summer
,
winter
)
==
4
)
{
request
.
post
(
{
url
:
TARGET_URL
,
...
...
@@ -279,26 +388,23 @@ function Get_Color(replyToken, message) {
"text"
:
"너는 겨울쿨"
},
],
}
},
(
error
,
response
,
body
)
=>
{
console
.
log
(
body
)
});
}
}
}
try
{
const
option
=
{
ca
:
fs
.
readFileSync
(
'/etc/letsencrypt/live/'
+
domain
+
'/fullchain.pem'
),
key
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
'/etc/letsencrypt/live/'
+
domain
+
'/privkey.pem'
),
'utf8'
).
toString
(),
cert
:
fs
.
readFileSync
(
path
.
resolve
(
process
.
cwd
(),
'/etc/letsencrypt/live/'
+
domain
+
'/cert.pem'
),
'utf8'
).
toString
(),
};
HTTPS
.
createServer
(
option
,
app
).
listen
(
sslport
,
()
=>
{
console
.
log
(
`[HTTPS] Server is started on port
${
sslport
}
`
);
});
...
...
@@ -306,5 +412,3 @@ try {
console
.
log
(
'[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.'
);
console
.
log
(
error
);
}
...
...
Please
register
or
login
to post a comment