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 15:04:47 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
129883e6ea4c0dd00bc1de4e29ca95f69f610e01
129883e6
2 parents
0d5c05c6
40750584
Combine all questions
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
337 additions
and
0 deletions
app/app.js
app/app.js
View file @
129883e
...
...
@@ -41,6 +41,36 @@ apiRouter.post('/sayHello', function(req, res) {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/test'
,
(
req
,
res
)
=>
{
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'재밌는 MBTI 테스트'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"할래!"
,
message
:
"할래!"
,
blockId
:
"6294c3ecf591aa1905548230"
},
{
action
:
"block"
,
label
:
"안 할래"
,
message
:
"안 할래"
,
blockId
:
"628b7ef293b31d5b60ab4b29"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question1'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
;
...
...
@@ -601,6 +631,238 @@ apiRouter.post('/question8', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question15'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
userDB
[
userId
]
=
[
''
,
''
,
''
,
''
,
''
];
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[Question 15/20]\n친구: 우울해서 아이패드 샀어'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"왜ㅠㅠ무슨일 있었어?"
,
message
:
"왜ㅠㅠ무슨일 있었어?"
,
blockId
:
"6294c467e7a0253c7662acac"
},
{
action
:
"block"
,
label
:
"어떤 기종샀어?"
,
message
:
"어떤 기종샀어?"
,
blockId
:
"6294c467e7a0253c7662acac"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question16'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
mbti
=
''
;
if
(
mesg
==
"왜ㅠㅠ무슨일 있었어?"
)
{
mbti
=
'F'
;
}
else
if
(
mesg
==
"어떤 기종샀어?"
)
{
mbti
=
'T'
;
}
userDB
[
userId
][
2
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[Question 16/20]\n이메일에 가능한 빨리 회신하려고 하고 지저분한 편지함을 참을 수 없다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6294c4755ceed96c38542a53"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6294c4755ceed96c38542a53"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question17'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'J'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'P'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[Question 17/20]\n당일에 갑자기 잡히는 약속이 부담스럽다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6294c4aff591aa1905548236"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6294c4aff591aa1905548236"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question18'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'I'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'E'
;
}
userDB
[
userId
][
0
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[Question 18/20]\n비행기에 타기 전 만약 비행기에 테러범이 있으면 어떻게 행동할지 상상해봤다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6294c4c2e7a0253c7662acb1"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6294c4c2e7a0253c7662acb1"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question19'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'N'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'S'
;
}
userDB
[
userId
][
1
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[Question 19/20]\n친구가 취업이 안돼서 힘들어하는 상황에 당신의 반응은?'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"요즘 취업 어렵지 힘들겠다ㅠㅠ"
,
message
:
"요즘 취업 어렵지 힘들겠다ㅠㅠ"
,
blockId
:
"6294c4c8e7a0253c7662acb3"
},
{
action
:
"block"
,
label
:
"무슨 준비하고있어? 이력서는 넣어봤어?"
,
message
:
"무슨 준비하고있어? 이력서는 넣어봤어?"
,
blockId
:
"6294c4c8e7a0253c7662acb3"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/question20'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
mbti
=
''
;
if
(
mesg
==
"요즘 취업 어렵지 힘들겠다ㅠㅠ"
)
{
mbti
=
'F'
;
}
else
if
(
mesg
==
"무슨 준비하고있어? 이력서는 넣어봤어?"
)
{
mbti
=
'T'
;
}
userDB
[
userId
][
2
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
'[Question 20/20]\n마지막 여행지를 향해 가던 중 흥미로운 장소를 발견했을 때, 남은 일정을 고려하는 편이다.'
}
}
],
quickReplies
:
[
{
action
:
"block"
,
label
:
"네"
,
message
:
"네"
,
blockId
:
"6293885b7bd2fd4333583df0"
},
{
action
:
"block"
,
label
:
"아니오"
,
message
:
"아니오"
,
blockId
:
"6293885b7bd2fd4333583df0"
}
]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/result'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
...
...
@@ -884,6 +1146,81 @@ apiRouter.post('/percent', (req, res) => {
res
.
status
(
200
).
send
(
responseBody
);
});
apiRouter
.
post
(
'/result'
,
(
req
,
res
)
=>
{
var
userId
=
req
.
body
.
userRequest
.
user
.
id
;
var
mesg
=
req
.
body
.
userRequest
.
utterance
;
var
mbti
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'J'
;
}
else
if
(
mesg
==
"아니오"
)
{
mbti
=
'P'
;
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
analysis_mbti
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
][
4
]
}
}
],
quickReplies
:
[{
action
:
"block"
,
label
:
"MBTI 테스트 다시하기"
,
message
:
"MBTI 테스트 다시하기"
,
blockId
:
"628b7ef293b31d5b60ab4b29"
//to question 1
}]
}
}
res
.
status
(
200
).
send
(
responseBody
);
});
function
analysis_mbti
(
userdb
)
{
var
e
=
count_mbti
(
userdb
[
0
],
'E'
);
var
i
=
1
-
e
;
//-> 5
var
n
=
count_mbti
(
userdb
[
1
],
'N'
);
var
s
=
1
-
n
;
//-> 5
var
f
=
count_mbti
(
userdb
[
2
],
'F'
);
var
t
=
2
-
f
;
//-> 5
var
j
=
count_mbti
(
userdb
[
3
],
'J'
);
var
p
=
2
-
j
;
//-> 5
if
(
e
>
i
)
{
userdb
[
4
]
+=
'E'
;
}
else
{
userdb
[
4
]
+=
'I'
;
}
if
(
n
>
s
)
{
userdb
[
4
]
+=
'N'
;
}
else
{
userdb
[
4
]
+=
'S'
;
}
if
(
f
>
t
)
{
userdb
[
4
]
+=
'F'
;
}
else
{
userdb
[
4
]
+=
'T'
;
}
if
(
j
>
p
)
{
userdb
[
4
]
+=
'J'
;
}
else
{
userdb
[
4
]
+=
'P'
;
}
}
function
count_mbti
(
item_list
,
mbti_ch
)
{
var
result
=
0
;
for
(
var
i
=
0
;
i
<
5
;
i
++
)
{
if
(
item_list
[
i
]
==
'mbti_ch'
){
result
+=
1
;
}
}
return
result
;
}
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