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-01 22:50:31 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
40750584ff54b618b4c874ae2e7ee7183192b714
40750584
1 parent
c447044a
Add mbti analysis
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
2 deletions
app/app.js
app/app.js
View file @
4075058
...
...
@@ -306,7 +306,6 @@ apiRouter.post('/question20', (req, res) => {
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
=
''
;
if
(
mesg
==
"네"
)
{
mbti
=
'J'
;
...
...
@@ -315,13 +314,15 @@ apiRouter.post('/result', (req, res) => {
}
userDB
[
userId
][
3
]
+=
mbti
;
console
.
log
(
userDB
[
userId
]);
analysis_mbti
(
userDB
[
userId
]);
const
responseBody
=
{
version
:
"2.0"
,
template
:
{
outputs
:
[
{
simpleText
:
{
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
]
text
:
"당신의 MBTI는 : "
+
userDB
[
userId
][
4
]
}
}
],
...
...
@@ -336,6 +337,47 @@ apiRouter.post('/result', (req, res) => {
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