Toggle navigation
Toggle navigation
This project
Loading...
Sign in
전세계
/
FakerQuiz
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ubuntu
2020-06-22 07:22:04 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cc6a0395574591cfedd5af91eff7f89d36063154
cc6a0395
1 parent
6e6547d9
버그: 유저별로 응답을 대기하지 않던 버그 수정
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
.gitignore
app.js
.gitignore
View file @
cc6a039
...
...
@@ -2,3 +2,4 @@ node_modules
package-lock.json
data.json
letsencrypt
nohup.out
\ No newline at end of file
...
...
app.js
View file @
cc6a039
...
...
@@ -20,7 +20,6 @@ const dataFileName = 'data.json';
var
fakerData
=
{};
var
quizList
=
[];
var
isWaitAns
=
false
;
var
users
=
{};
var
sumOfStreak
=
0
;
var
sumOfTry
=
0
;
...
...
@@ -421,23 +420,28 @@ app.post('/hook', async function (req, res) {
// request log
console
.
log
(
'======================'
,
new
Date
(),
'======================'
);
console
.
log
(
'[request]'
,
req
.
body
);
console
.
log
(
'[request source] '
,
eventObj
.
source
);
console
.
log
(
'[request message]'
,
eventObj
.
message
);
console
.
log
(
'[request source] '
,
source
);
console
.
log
(
'[request message]'
,
message
);
if
(
!
isWaitAns
&&
eventObj
.
message
.
text
==
'시작'
)
{
await
checkData
();
users
[
eventObj
.
source
.
userId
]
=
{
if
(
!
users
.
hasOwnProperty
(
source
.
userId
)
)
{
users
[
source
.
userId
]
=
{
isWaitingAns
:
false
,
streak
:
0
,
quizAns
:
null
,
quizInfo
:
null
};
sendQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
,
true
);
}
else
if
(
isWaitAns
)
{
if
(
checkAns
(
eventObj
.
source
.
userId
,
eventObj
.
message
.
text
))
{
users
[
eventObj
.
source
.
userId
].
streak
++
;
sendQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
,
false
);
}
if
(
!
users
[
source
.
userId
].
isWaitingAns
&&
message
.
text
==
'시작'
)
{
await
checkData
();
sendQuiz
(
eventObj
.
replyToken
,
source
.
userId
,
true
);
}
else
if
(
users
[
source
.
userId
].
isWaitingAns
)
{
if
(
checkAns
(
source
.
userId
,
message
.
text
))
{
users
[
source
.
userId
].
streak
++
;
sendQuiz
(
eventObj
.
replyToken
,
source
.
userId
,
false
);
}
else
{
endQuiz
(
eventObj
.
replyToken
,
eventObj
.
source
.
userId
);
endQuiz
(
eventObj
.
replyToken
,
source
.
userId
);
}
}
...
...
@@ -485,7 +489,7 @@ function sendQuiz(replyToken, id, isInit) {
}
);
isWait
Ans
=
true
;
users
[
id
].
isWaiting
Ans
=
true
;
}
function
checkAns
(
id
,
ans
)
{
...
...
@@ -497,7 +501,7 @@ function checkAns(id, ans) {
}
function
endQuiz
(
replyToken
,
id
)
{
isWait
Ans
=
false
;
users
[
id
].
isWaiting
Ans
=
false
;
sumOfTry
++
;
sumOfStreak
+=
users
[
id
].
streak
;
var
averageStreak
=
sumOfStreak
/
sumOfTry
;
...
...
Please
register
or
login
to post a comment