Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
srvpro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
srvpro
Commits
91adc9a3
Commit
91adc9a3
authored
Oct 03, 2018
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mc'
parents
9af039eb
2ec6ae0d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
16 deletions
+27
-16
data/default_config.json
data/default_config.json
+2
-0
ygopro-server.coffee
ygopro-server.coffee
+11
-8
ygopro-server.js
ygopro-server.js
+14
-8
No files found.
data/default_config.json
View file @
91adc9a3
...
@@ -123,6 +123,8 @@
...
@@ -123,6 +123,8 @@
"challonge"
:
{
"challonge"
:
{
"enabled"
:
false
,
"enabled"
:
false
,
"post_detailed_score"
:
true
,
"post_detailed_score"
:
true
,
"post_score_midduel"
:
true
,
"cache_ttl"
:
60000
,
"api_key"
:
"123"
,
"api_key"
:
"123"
,
"tournament_id"
:
"456"
"tournament_id"
:
"456"
},
},
...
...
ygopro-server.coffee
View file @
91adc9a3
...
@@ -375,12 +375,13 @@ if settings.modules.challonge.enabled
...
@@ -375,12 +375,13 @@ if settings.modules.challonge.enabled
challonge
=
require
(
'challonge'
).
createClient
({
challonge
=
require
(
'challonge'
).
createClient
({
apiKey
:
settings
.
modules
.
challonge
.
api_key
apiKey
:
settings
.
modules
.
challonge
.
api_key
})
})
challonge_cache
=
[]
if
settings
.
modules
.
challonge
.
cache_ttl
challonge_cache
=
[]
challonge_queue_callbacks
=
[[],
[]]
challonge_queue_callbacks
=
[[],
[]]
is_requesting
=
[
false
,
false
]
is_requesting
=
[
false
,
false
]
get_callback
=
(
challonge_type
,
_callback
)
->
get_callback
=
(
challonge_type
,
_callback
)
->
return
((
err
,
data
)
->
return
((
err
,
data
)
->
if
!
err
and
data
if
settings
.
modules
.
challonge
.
cache_ttl
and
!
err
and
data
challonge_cache
[
challonge_type
]
=
data
challonge_cache
[
challonge_type
]
=
data
_callback
(
err
,
data
)
_callback
(
err
,
data
)
while
challonge_queue_callbacks
[
challonge_type
].
length
while
challonge_queue_callbacks
[
challonge_type
].
length
...
@@ -390,7 +391,7 @@ if settings.modules.challonge.enabled
...
@@ -390,7 +391,7 @@ if settings.modules.challonge.enabled
return
return
)
)
challonge
.
participants
.
_index
=
(
_data
)
->
challonge
.
participants
.
_index
=
(
_data
)
->
if
challonge_cache
[
0
]
if
settings
.
modules
.
challonge
.
cache_ttl
and
challonge_cache
[
0
]
_data
.
callback
(
null
,
challonge_cache
[
0
])
_data
.
callback
(
null
,
challonge_cache
[
0
])
else
if
is_requesting
[
0
]
else
if
is_requesting
[
0
]
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
)
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
)
...
@@ -400,7 +401,7 @@ if settings.modules.challonge.enabled
...
@@ -400,7 +401,7 @@ if settings.modules.challonge.enabled
challonge
.
participants
.
index
(
_data
)
challonge
.
participants
.
index
(
_data
)
return
return
challonge
.
matches
.
_index
=
(
_data
)
->
challonge
.
matches
.
_index
=
(
_data
)
->
if
challonge_cache
[
1
]
if
settings
.
modules
.
challonge
.
cache_ttl
and
challonge_cache
[
1
]
_data
.
callback
(
null
,
challonge_cache
[
1
])
_data
.
callback
(
null
,
challonge_cache
[
1
])
else
if
is_requesting
[
1
]
else
if
is_requesting
[
1
]
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
)
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
)
...
@@ -410,8 +411,9 @@ if settings.modules.challonge.enabled
...
@@ -410,8 +411,9 @@ if settings.modules.challonge.enabled
challonge
.
matches
.
index
(
_data
)
challonge
.
matches
.
index
(
_data
)
return
return
refresh_challonge_cache
=
()
->
refresh_challonge_cache
=
()
->
challonge_cache
[
0
]
=
null
if
settings
.
modules
.
challonge
.
cache_ttl
challonge_cache
[
1
]
=
null
challonge_cache
[
0
]
=
null
challonge_cache
[
1
]
=
null
return
return
refresh_challonge_cache
()
refresh_challonge_cache
()
# challonge.participants._index({
# challonge.participants._index({
...
@@ -426,7 +428,8 @@ if settings.modules.challonge.enabled
...
@@ -426,7 +428,8 @@ if settings.modules.challonge.enabled
# return
# return
# )
# )
# })
# })
setInterval
(
refresh_challonge_cache
,
60000
)
if
settings
.
modules
.
challonge
.
cache_ttl
setInterval
(
refresh_challonge_cache
,
settings
.
modules
.
challonge
.
cache_ttl
)
if
settings
.
modules
.
vip
.
enabled
if
settings
.
modules
.
vip
.
enabled
for
k
,
v
of
vip_info
.
cdkeys
when
v
.
length
==
0
for
k
,
v
of
vip_info
.
cdkeys
when
v
.
length
==
0
...
@@ -3177,7 +3180,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
...
@@ -3177,7 +3180,7 @@ ygopro.stoc_follow 'CHANGE_SIDE', false, (buffer, info, client, server)->
ygopro
.
stoc_send_chat
(
client
,
"${side_remain_part1}
#{
client
.
side_tcount
}
${side_remain_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
ygopro
.
stoc_send_chat
(
client
,
"${side_remain_part1}
#{
client
.
side_tcount
}
${side_remain_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
,
60000
,
60000
client
.
side_interval
=
sinterval
client
.
side_interval
=
sinterval
if
settings
.
modules
.
challonge
.
enabled
and
client
.
pos
==
0
if
settings
.
modules
.
challonge
.
enabled
and
settings
.
modules
.
challonge
.
post_score_midduel
and
client
.
pos
==
0
temp_log
=
JSON
.
parse
(
JSON
.
stringify
(
room
.
challonge_duel_log
))
temp_log
=
JSON
.
parse
(
JSON
.
stringify
(
room
.
challonge_duel_log
))
delete
temp_log
.
winnerId
delete
temp_log
.
winnerId
challonge
.
matches
.
update
({
challonge
.
matches
.
update
({
...
...
ygopro-server.js
View file @
91adc9a3
...
@@ -466,13 +466,15 @@
...
@@ -466,13 +466,15 @@
challonge
=
require
(
'
challonge
'
).
createClient
({
challonge
=
require
(
'
challonge
'
).
createClient
({
apiKey
:
settings
.
modules
.
challonge
.
api_key
apiKey
:
settings
.
modules
.
challonge
.
api_key
});
});
challonge_cache
=
[];
if
(
settings
.
modules
.
challonge
.
cache_ttl
)
{
challonge_cache
=
[];
}
challonge_queue_callbacks
=
[[],
[]];
challonge_queue_callbacks
=
[[],
[]];
is_requesting
=
[
false
,
false
];
is_requesting
=
[
false
,
false
];
get_callback
=
function
(
challonge_type
,
_callback
)
{
get_callback
=
function
(
challonge_type
,
_callback
)
{
return
(
function
(
err
,
data
)
{
return
(
function
(
err
,
data
)
{
var
cur_callback
;
var
cur_callback
;
if
(
!
err
&&
data
)
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
!
err
&&
data
)
{
challonge_cache
[
challonge_type
]
=
data
;
challonge_cache
[
challonge_type
]
=
data
;
}
}
_callback
(
err
,
data
);
_callback
(
err
,
data
);
...
@@ -484,7 +486,7 @@
...
@@ -484,7 +486,7 @@
});
});
};
};
challonge
.
participants
.
_index
=
function
(
_data
)
{
challonge
.
participants
.
_index
=
function
(
_data
)
{
if
(
challonge_cache
[
0
])
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
challonge_cache
[
0
])
{
_data
.
callback
(
null
,
challonge_cache
[
0
]);
_data
.
callback
(
null
,
challonge_cache
[
0
]);
}
else
if
(
is_requesting
[
0
])
{
}
else
if
(
is_requesting
[
0
])
{
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
);
challonge_queue_callbacks
[
0
].
push
(
_data
.
callback
);
...
@@ -495,7 +497,7 @@
...
@@ -495,7 +497,7 @@
}
}
};
};
challonge
.
matches
.
_index
=
function
(
_data
)
{
challonge
.
matches
.
_index
=
function
(
_data
)
{
if
(
challonge_cache
[
1
])
{
if
(
settings
.
modules
.
challonge
.
cache_ttl
&&
challonge_cache
[
1
])
{
_data
.
callback
(
null
,
challonge_cache
[
1
]);
_data
.
callback
(
null
,
challonge_cache
[
1
]);
}
else
if
(
is_requesting
[
1
])
{
}
else
if
(
is_requesting
[
1
])
{
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
);
challonge_queue_callbacks
[
1
].
push
(
_data
.
callback
);
...
@@ -506,11 +508,15 @@
...
@@ -506,11 +508,15 @@
}
}
};
};
refresh_challonge_cache
=
function
()
{
refresh_challonge_cache
=
function
()
{
challonge_cache
[
0
]
=
null
;
if
(
settings
.
modules
.
challonge
.
cache_ttl
)
{
challonge_cache
[
1
]
=
null
;
challonge_cache
[
0
]
=
null
;
challonge_cache
[
1
]
=
null
;
}
};
};
refresh_challonge_cache
();
refresh_challonge_cache
();
setInterval
(
refresh_challonge_cache
,
60000
);
if
(
settings
.
modules
.
challonge
.
cache_ttl
)
{
setInterval
(
refresh_challonge_cache
,
settings
.
modules
.
challonge
.
cache_ttl
);
}
}
}
if
(
settings
.
modules
.
vip
.
enabled
)
{
if
(
settings
.
modules
.
vip
.
enabled
)
{
...
@@ -4036,7 +4042,7 @@
...
@@ -4036,7 +4042,7 @@
},
60000
);
},
60000
);
client
.
side_interval
=
sinterval
;
client
.
side_interval
=
sinterval
;
}
}
if
(
settings
.
modules
.
challonge
.
enabled
&&
client
.
pos
===
0
)
{
if
(
settings
.
modules
.
challonge
.
enabled
&&
settings
.
modules
.
challonge
.
post_score_midduel
&&
client
.
pos
===
0
)
{
temp_log
=
JSON
.
parse
(
JSON
.
stringify
(
room
.
challonge_duel_log
));
temp_log
=
JSON
.
parse
(
JSON
.
stringify
(
room
.
challonge_duel_log
));
delete
temp_log
.
winnerId
;
delete
temp_log
.
winnerId
;
challonge
.
matches
.
update
({
challonge
.
matches
.
update
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment