Toggle navigation
Toggle navigation
This project
Loading...
Sign in
공정훈
/
find_mbti_bot
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
김성욱
2022-06-03 14:39:48 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0d5c05c63fde4df7bd3a93111447810dd57cbafd
0d5c05c6
1 parent
3fca7f49
Modify conflict code
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
252 additions
and
259 deletions
app/app.js
app/app.js
View file @
0d5c05c
...
...
@@ -5,7 +5,6 @@ const bodyParser = require('body-parser');
const
apiRouter
=
express
.
Router
();
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
...
...
@@ -14,11 +13,7 @@ app.use(bodyParser.urlencoded({
app
.
use
(
'/api'
,
apiRouter
);
let
userDB
=
new
Array
();
let
mbtiper
=
new
Array
();
<<<<<<<
HEAD
apiRouter
.
post
(
'/test'
,
(
req
,
res
)
=>
{
=======
apiRouter
.
post
(
'/sayHello'
,
function
(
req
,
res
)
{
const
responseBody
=
{
version
:
"2.0"
,
...
...
@@ -52,35 +47,19 @@ apiRouter.post('/question1', (req, res) => {
console
.
log
(
'[q1:user message] '
,
mesg
);
userDB
[
userId
]
=
[
''
,
''
,
''
,
''
,
''
];
console
.
log
(
userDB
[
userId
]);
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
<<<<<<<
HEAD
text
:
'MBTI 테스트 question8-14\n시작하려면 시작하기 버튼을 눌러주세요!'
=======
text
:
'금방 새로운 직장 사람들과 어울리기 시작합니다.'
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
}
}
],
quickReplies
:
[
{
action
:
"block"
,
<<<<<<<
HEAD
label
:
"시작하기"
,
message
:
"시작하기"
,
blockId
:
"62977ff05ceed96c385449b9"
},
{
action
:
"block"
,
label
:
"나중에 하기"
,
message
:
"나중에 하기"
,
blockId
:
"6297861be7a0253c7662ccb8"
=======
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297b11ae7a0253c7662ccea"
...
...
@@ -90,7 +69,6 @@ apiRouter.post('/question1', (req, res) => {
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297b11ae7a0253c7662ccea"
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
}
]
}
...
...
@@ -98,13 +76,6 @@ apiRouter.post('/question1', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
<<<<<<<
HEAD
apiRouter
.
post
(
'/question8'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
userDB
[
userId
]
=
[
''
,
''
,
''
,
''
,
''
];
console
.
log
(
userDB
);
const
responseBody
=
{
=======
apiRouter
.
post
(
'/question2'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
...
...
@@ -118,34 +89,18 @@ apiRouter.post('/question2', (req, res) => {
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
const
responseBody
=
{
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
<<<<<<<
HEAD
text
:
'[question8]\n여행 계획을 어떻게 세우시나요?'
=======
text
:
'평소 깻잎논쟁에 대해 1시간 이상을 생각해 보는 편입니다.'
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
}
}
],
quickReplies
:
[
{
action
:
"block"
,
<<<<<<<
HEAD
label
:
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
,
message
:
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
,
blockId
:
"629780e9e7a0253c7662cca6"
},
{
action
:
"block"
,
label
:
"시간과 장소를 자세하게 정한다"
,
message
:
"시간과 장소를 자세하게 정한다"
,
blockId
:
"629780e9e7a0253c7662cca6"
=======
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297b122ab89e678ee86b331"
...
...
@@ -155,7 +110,6 @@ apiRouter.post('/question2', (req, res) => {
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297b122ab89e678ee86b331"
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
}
]
}
...
...
@@ -163,20 +117,6 @@ apiRouter.post('/question2', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
<<<<<<<
HEAD
apiRouter
.
post
(
'/question9'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
){
mbti
=
'P'
;
}
else
if
(
mesg
==
"시간과 장소를 자세하게 정한다"
)
{
mbti
=
'J'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
);
=======
apiRouter
.
post
(
'/question3'
,
function
(
req
,
res
)
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
...
...
@@ -230,34 +170,28 @@ apiRouter.post('/question4', (req, res) => {
}
userDB
[
userId
][
2
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
<<<<<<<
HEAD
text
:
'[question9]\n재미있는 책이나 비디오 게임이 사교 모임보다 더 낫습니다.'
=======
text
:
"주의깊게 미리 계획하기 보다는 즉흥적으로 움직입니다."
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
}
}
],
quickReplies
:
[
<<<<<<<
HEAD
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"629780f4ab89e678ee86b2de
"
blockId
:
"6297b12be7a0253c7662ccec
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"629780f4ab89e678ee86b2de
"
blockId
:
"6297b12be7a0253c7662ccec
"
}
]
}
...
...
@@ -265,25 +199,25 @@ apiRouter.post('/question4', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question10'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
apiRouter
.
post
(
'/question5'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
;
console
.
log
(
'[q1:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'I'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'E'
;
if
(
mesg
==
"네"
)
{
mbti
=
'P'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'J'
;
}
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
);
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'
[question10]\n본인이 창의적이기보다 현실적인 사람이라고 생각
합니다.'
text
:
'
주목받는 것을 좋아
합니다.'
}
}
],
...
...
@@ -292,13 +226,13 @@ apiRouter.post('/question10', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297
81015ceed96c385449c8
"
blockId
:
"6297
b130e7a0253c7662ccee
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297
81015ceed96c385449c8
"
blockId
:
"6297
b130e7a0253c7662ccee
"
}
]
}
...
...
@@ -306,25 +240,25 @@ apiRouter.post('/question10', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question11'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
apiRouter
.
post
(
'/question6'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q2:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'S'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'N'
;
if
(
mesg
==
"네"
)
{
mbti
=
'E'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'I'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
console
.
log
(
userDB
);
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'
[question11]\n팀플을 하는 경우, 충실하지만 실적을 못 내는 팀원을 제명하기 어려워
합니다.'
text
:
'
종종 인간 실존에 대한 이유를 생각
합니다.'
}
}
],
...
...
@@ -333,13 +267,13 @@ apiRouter.post('/question11', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297
810fe7a0253c7662cca8
"
blockId
:
"6297
b133f591aa190554a260
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297
810fe7a0253c7662cca8
"
blockId
:
"6297
b133f591aa190554a260
"
}
]
}
...
...
@@ -347,25 +281,25 @@ apiRouter.post('/question11', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question12'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
apiRouter
.
post
(
'/question7'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q2:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'F'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'T'
;
if
(
mesg
==
"네"
)
{
mbti
=
'N'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'S'
;
}
userDB
[
userId
][
2
]
+=
mbti
;
console
.
log
(
userDB
);
userDB
[
userId
][
1
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'
[question12]\n집과 업무 환경이 잘 정돈되어 있
습니다.'
text
:
'
어떤 일에서 성과를 냈을 때 “고생했어”보다 “잘했어”라는 말이 더 좋
습니다.'
}
}
],
...
...
@@ -374,13 +308,13 @@ apiRouter.post('/question12', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297
811bf591aa190554a22e
"
blockId
:
"6297
b3505ceed96c38544a0a
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297
811bf591aa190554a22e
"
blockId
:
"6297
b3505ceed96c38544a0a
"
}
]
}
...
...
@@ -388,16 +322,49 @@ apiRouter.post('/question12', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question13'
,
(
req
,
res
)
=>
{
apiRouter
.
post
(
'/question8'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
userDB
[
userId
]
=
[
''
,
''
,
''
,
''
,
''
];
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[question8]\n여행 계획을 어떻게 세우시나요?'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
,
message
:
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
,
blockId
:
"629780e9e7a0253c7662cca6"
},
{
action
:
"block"
,
label
:
"시간과 장소를 자세하게 정한다"
,
message
:
"시간과 장소를 자세하게 정한다"
,
blockId
:
"629780e9e7a0253c7662cca6"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question9'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'J'
;
}
else
if
(
mesg
==
"아니오"
)
{
if
(
mesg
==
"테마만 정한다(ex.맛집 방문하는 날, 사진 찍는 날)"
){
mbti
=
'P'
;
}
else
if
(
mesg
==
"시간과 장소를 자세하게 정한다"
)
{
mbti
=
'J'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
...
...
@@ -406,7 +373,7 @@ apiRouter.post('/question13', (req, res) => {
outputs
:
[
{
simpleText
:
{
text
:
'[question13]\n친구 관계가 좁고 깊은 편입
니다.'
text
:
'[question9]\n재미있는 책이나 비디오 게임이 사교 모임보다 더 낫습
니다.'
}
}
],
...
...
@@ -415,21 +382,21 @@ apiRouter.post('/question13', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"62978127ab89e678ee86b2e2
"
blockId
:
"629780f4ab89e678ee86b2de
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62978127ab89e678ee86b2e2
"
blockId
:
"629780f4ab89e678ee86b2de
"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
});
apiRouter
.
post
(
'/question14
'
,
(
req
,
res
)
=>
{
apiRouter
.
post
(
'/question10
'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
...
...
@@ -447,7 +414,7 @@ apiRouter.post('/question14', (req, res) => {
outputs
:
[
{
simpleText
:
{
text
:
'[question14]\n공부하기 싫을 때 공부는 왜 해야 하는 것인지 고민에 빠질 때가 있습
니다.'
text
:
'[question10]\n본인이 창의적이기보다 현실적인 사람이라고 생각합
니다.'
}
}
],
...
...
@@ -456,54 +423,39 @@ apiRouter.post('/question14', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"62979c9ce7a0253c7662ccd4"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62979c9ce7a0253c7662ccd4"
}
]
=======
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297b12be7a0253c7662ccec"
blockId
:
"629781015ceed96c385449c8"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297b12be7a0253c7662ccec
"
blockId
:
"629781015ceed96c385449c8
"
}
]
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
});
apiRouter
.
post
(
'/question5'
,
(
req
,
res
)
=>
{
apiRouter
.
post
(
'/question11'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
;
console
.
log
(
'[q1:user message] '
,
mesg
);
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'P'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'J'
;
if
(
mesg
==
"네"
){
mbti
=
'S'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'N'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'주목받는 것을 좋아
합니다.'
text
:
'[question11]\n팀플을 하는 경우, 충실하지만 실적을 못 내는 팀원을 제명하기 어려워
합니다.'
}
}
],
...
...
@@ -512,39 +464,39 @@ apiRouter.post('/question5', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297b130e7a0253c7662ccee
"
blockId
:
"6297810fe7a0253c7662cca8
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297b130e7a0253c7662ccee
"
blockId
:
"6297810fe7a0253c7662cca8
"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
});
apiRouter
.
post
(
'/question6'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
apiRouter
.
post
(
'/question12'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q2:user message] '
,
mesg
)
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'E'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'I'
;
if
(
mesg
==
"네"
){
mbti
=
'F'
;
}
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'T'
;
}
userDB
[
userId
][
2
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'종종 인간 실존에 대한 이유를 생각합
니다.'
text
:
'[question12]\n집과 업무 환경이 잘 정돈되어 있습
니다.'
}
}
],
...
...
@@ -553,39 +505,39 @@ apiRouter.post('/question6', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297b133f591aa190554a260
"
blockId
:
"6297811bf591aa190554a22e
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297b133f591aa190554a260
"
blockId
:
"6297811bf591aa190554a22e
"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
});
apiRouter
.
post
(
'/question7'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
apiRouter
.
post
(
'/question13'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[q2:user message] '
,
mesg
)
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'N'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'S'
;
if
(
mesg
==
"네"
){
mbti
=
'J'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'P'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'어떤 일에서 성과를 냈을 때 “고생했어”보다 “잘했어”라는 말이 더 좋습
니다.'
text
:
'[question13]\n친구 관계가 좁고 깊은 편입
니다.'
}
}
],
...
...
@@ -594,132 +546,63 @@ apiRouter.post('/question7', (req, res) => {
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6297b3505ceed96c38544a0a
"
blockId
:
"62978127ab89e678ee86b2e2
"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6297b3505ceed96c38544a0a
"
blockId
:
"62978127ab89e678ee86b2e2
"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
});
apiRouter
.
post
(
'/result
'
,
(
req
,
res
)
=>
{
apiRouter
.
post
(
'/question14
'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
<<<<<<<
HEAD
mbtiper
=
[
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
];
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'
N
'
;
mbti
=
'
I
'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'S'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
var
e
=
0
;
var
n
=
0
;
var
f
=
0
;
var
j
=
0
;
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
0
][
i
]
==
"E"
){
e
++
;
}
}
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
1
][
i
]
==
"N"
){
n
++
;
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
if
(
userDB
[
userId
][
2
][
i
]
==
"F"
){
f
++
;
}
}
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
3
][
i
]
==
"J"
){
j
++
;
}
}
var
i
=
2
-
e
;
var
s
=
2
-
n
;
var
t
=
1
-
f
;
var
p
=
2
-
j
;
mbtiper
[
0
]
+=
20
*
e
;
mbtiper
[
1
]
+=
20
*
i
;
mbtiper
[
2
]
+=
20
*
n
;
mbtiper
[
3
]
+=
20
*
s
;
mbtiper
[
4
]
+=
20
*
t
;
mbtiper
[
5
]
+=
20
*
f
;
mbtiper
[
6
]
+=
20
*
j
;
mbtiper
[
7
]
+=
20
*
p
;
if
(
mbtiper
[
0
]
>
mbtiper
[
1
]){
userDB
[
userId
][
4
]
+=
'E'
;
}
else
{
userDB
[
userId
][
4
]
+=
'I'
;
}
if
(
mbtiper
[
2
]
>
mbtiper
[
3
]){
userDB
[
userId
][
4
]
+=
'N'
;
}
else
{
userDB
[
userId
][
4
]
+=
'S'
;
}
if
(
mbtiper
[
4
]
>
mbtiper
[
5
]){
userDB
[
userId
][
4
]
+=
'T'
;
}
else
{
userDB
[
userId
][
4
]
+=
'F'
;
}
if
(
mbtiper
[
6
]
>
mbtiper
[
7
]){
userDB
[
userId
][
4
]
+=
'J'
;
}
else
{
userDB
[
userId
][
4
]
+=
'P'
;
mbti
=
'E'
;
}
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
][
4
]
text
:
'[question14]\n공부하기 싫을 때 공부는 왜 해야 하는 것인지 고민에 빠질 때가 있습니다.'
}
}
],
quickReplies
:
[{
quickReplies
:
[
{
action
:
"block"
,
label
:
"MBTI 테스트 다시하기
"
,
message
:
"MBTI 테스트 다시하기
"
,
blockId
:
"62977ff05ceed96c385449b9
"
label
:
"네
"
,
message
:
"네
"
,
blockId
:
"62979c9ce7a0253c7662ccd4
"
},
{
action
:
"block"
,
label
:
"결과 상세보기"
,
message
:
"결과 상세보기"
,
blockId
:
"62987b78e7a0253c7662dcd9"
}]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/percent'
,
(
req
,
res
)
=>
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'E: '
+
mbtiper
[
0
]
+
'%\nI: '
+
mbtiper
[
1
]
+
'%\nN: '
+
mbtiper
[
2
]
+
'%\nS: '
+
mbtiper
[
3
]
+
'%\nT: '
+
mbtiper
[
4
]
+
'%\nF: '
+
mbtiper
[
5
]
+
'%\nJ: '
+
mbtiper
[
6
]
+
'%\nP: '
+
mbtiper
[
7
]
+
'%'
}
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"62979c9ce7a0253c7662ccd4"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
=======
apiRouter
.
post
(
'/result'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
console
.
log
(
'[result:user message] '
,
mesg
);
var
mbti
=
''
;
...
...
@@ -890,7 +773,117 @@ function result(Array){
Array
[
4
]
+=
'J'
;
}
>>>>>>>
9
cc768840e30632a42343600db176f035dc0ebf9
apiRouter
.
post
(
'/result'
,
(
req
,
res
)
=>
{
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
mbtiper
=
[
''
,
''
,
''
,
''
,
''
,
''
,
''
,
''
];
var
mbti
=
''
;
if
(
mesg
==
"네"
){
mbti
=
'N'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'S'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
var
e
=
0
;
var
n
=
0
;
var
f
=
0
;
var
j
=
0
;
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
0
][
i
]
==
"E"
){
e
++
;
}
}
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
1
][
i
]
==
"N"
){
n
++
;
}
}
for
(
i
=
0
;
i
<
1
;
i
++
){
if
(
userDB
[
userId
][
2
][
i
]
==
"F"
){
f
++
;
}
}
for
(
i
=
0
;
i
<
2
;
i
++
){
if
(
userDB
[
userId
][
3
][
i
]
==
"J"
){
j
++
;
}
}
var
i
=
2
-
e
;
var
s
=
2
-
n
;
var
t
=
1
-
f
;
var
p
=
2
-
j
;
mbtiper
[
0
]
+=
20
*
e
;
mbtiper
[
1
]
+=
20
*
i
;
mbtiper
[
2
]
+=
20
*
n
;
mbtiper
[
3
]
+=
20
*
s
;
mbtiper
[
4
]
+=
20
*
t
;
mbtiper
[
5
]
+=
20
*
f
;
mbtiper
[
6
]
+=
20
*
j
;
mbtiper
[
7
]
+=
20
*
p
;
if
(
mbtiper
[
0
]
>
mbtiper
[
1
]){
userDB
[
userId
][
4
]
+=
'E'
;
}
else
{
userDB
[
userId
][
4
]
+=
'I'
;
}
if
(
mbtiper
[
2
]
>
mbtiper
[
3
]){
userDB
[
userId
][
4
]
+=
'N'
;
}
else
{
userDB
[
userId
][
4
]
+=
'S'
;
}
if
(
mbtiper
[
4
]
>
mbtiper
[
5
]){
userDB
[
userId
][
4
]
+=
'T'
;
}
else
{
userDB
[
userId
][
4
]
+=
'F'
;
}
if
(
mbtiper
[
6
]
>
mbtiper
[
7
]){
userDB
[
userId
][
4
]
+=
'J'
;
}
else
{
userDB
[
userId
][
4
]
+=
'P'
;
}
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
][
4
]
}
}
],
quickReplies
:
[{
action
:
"block"
,
label
:
"MBTI 테스트 다시하기"
,
message
:
"MBTI 테스트 다시하기"
,
blockId
:
"62977ff05ceed96c385449b9"
},
{
action
:
"block"
,
label
:
"결과 상세보기"
,
message
:
"결과 상세보기"
,
blockId
:
"62987b78e7a0253c7662dcd9"
}]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/percent'
,
(
req
,
res
)
=>
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'E: '
+
mbtiper
[
0
]
+
'%\nI: '
+
mbtiper
[
1
]
+
'%\nN: '
+
mbtiper
[
2
]
+
'%\nS: '
+
mbtiper
[
3
]
+
'%\nT: '
+
mbtiper
[
4
]
+
'%\nF: '
+
mbtiper
[
5
]
+
'%\nJ: '
+
mbtiper
[
6
]
+
'%\nP: '
+
mbtiper
[
7
]
+
'%'
}
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
app
.
listen
((
process
.
env
.
PORT
||
3000
),
function
()
{
console
.
log
(
'Example skill server listening on port 3000!'
);
});
\ No newline at end of file
...
...
Please
register
or
login
to post a comment