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
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
MyCard
srvpro
Commits
8ce9e25d
Commit
8ce9e25d
authored
Dec 30, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
duel start add another api
parent
35caa0d4
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
51 deletions
+115
-51
data/default_config.json
data/default_config.json
+2
-2
ygopro-server.coffee
ygopro-server.coffee
+47
-19
ygopro-server.js
ygopro-server.js
+66
-30
No files found.
data/default_config.json
View file @
8ce9e25d
...
...
@@ -174,9 +174,9 @@
"post_score"
:
false
,
"get_score"
:
false
,
"punish_quit_before_match"
:
false
,
"
init_post
"
:
{
"
match_api
"
:
{
"enabled"
:
false
,
"url"
:
"https://sapi.moecube.com:444/ygopro/match
/clear
"
,
"url"
:
"https://sapi.moecube.com:444/ygopro/match"
,
"accesskey"
:
"momobako"
}
},
...
...
ygopro-server.coffee
View file @
8ce9e25d
...
...
@@ -246,6 +246,26 @@ loadLFList = (path) ->
lflists
.
push
({
date
:
moment
(
list
.
match
(
/!([\d\.]+)/
)[
1
],
'YYYY.MM.DD'
).
utcOffset
(
"-08:00"
),
tcg
:
list
.
indexOf
(
'TCG'
)
!=
-
1
})
catch
call_match_api
=
(
method
,
path
,
params
)
->
if
not
settings
.
modules
.
arena_mode
.
match_api
.
enabled
return
null
match_api_url
=
new
URL
(
settings
.
modules
.
arena_mode
.
match_api
.
url
+
"/"
+
path
)
match_api_url
.
searchParams
.
append
(
'ak'
,
settings
.
modules
.
arena_mode
.
match_api
.
accesskey
)
for
entry
of
Object
.
entries
(
params
)
key
=
entry
[
0
]
val
=
entry
[
1
]
match_api_url
.
searchParams
.
append
(
key
,
val
)
try
res
=
await
axios
({
method
:
method
url
:
match_api_url
.
toString
()
timeout
:
30000
})
return
res
.
data
catch
e
log
.
warn
'MATCH API CALL ERROR'
,
method
,
path
,
JSON
.
stringify
(
params
),
e
.
toString
()
return
null
init
=
()
->
log
.
info
(
'Reading config.'
)
await
createDirectoryIfNotExists
(
"./config"
)
...
...
@@ -337,6 +357,13 @@ init = () ->
settings
.
modules
.
trusted_proxies
=
settings
.
modules
.
neos
.
trusted_proxies
delete
settings
.
modules
.
neos
.
trusted_proxies
imported
=
true
# migrate arena_mode.init_post to match_api
if
settings
.
modules
.
arena_mode
.
init_post
settings
.
modules
.
arena_mode
.
match_api
=
settings
.
modules
.
arena_mode
.
init_post
if
settings
.
modules
.
arena_mode
.
match_api
.
url
.
endsWith
(
'/clear'
)
settings
.
modules
.
arena_mode
.
match_api
.
url
=
settings
.
modules
.
arena_mode
.
match_api
.
url
.
slice
(
0
,
-
6
)
delete
settings
.
modules
.
arena_mode
.
init_post
imported
=
true
#finish
keysFromEnv
=
Object
.
keys
(
process
.
env
).
filter
((
key
)
=>
key
.
startsWith
(
'SRVPRO_'
))
if
keysFromEnv
.
length
>
0
...
...
@@ -490,16 +517,8 @@ init = () ->
# pg_client.on 'drain', pg_client.end.bind(pg_client)
# log.info "loading mycard user..."
# pg_client.connect()
if
settings
.
modules
.
arena_mode
.
enabled
and
settings
.
modules
.
arena_mode
.
init_post
.
enabled
postData
=
qs
.
stringify
({
ak
:
settings
.
modules
.
arena_mode
.
init_post
.
accesskey
,
arena
:
settings
.
modules
.
arena_mode
.
mode
})
try
log
.
info
(
"Sending arena init post."
)
await
axios
.
post
(
settings
.
modules
.
arena_mode
.
init_post
.
url
+
"?"
+
postData
)
catch
e
log
.
warn
'ARENA INIT POST ERROR'
,
e
if
settings
.
modules
.
arena_mode
.
enabled
await
call_match_api
(
'POST'
,
'clear'
,
{
arena
:
settings
.
modules
.
arena_mode
.
mode
})
if
settings
.
modules
.
challonge
.
enabled
Challonge
=
require
(
'./challonge'
).
Challonge
...
...
@@ -2469,7 +2488,7 @@ ygopro.ctos_follow 'JOIN_GAME', true, (buffer, info, client, server, datas)->
if
decrypted_buffer
break
if
!
decrypted_buffer
ygopro
.
stoc_die
(
client
,
'${invalid_password_
checksum
}'
)
ygopro
.
stoc_die
(
client
,
'${invalid_password_
unauthorized
}'
)
return
return
create_room_with_action
(
decrypted_buffer
)
...
...
@@ -3135,7 +3154,8 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
roomlist
.
start
room
if
!
room
.
windbot
and
settings
.
modules
.
http
.
websocket_roomlist
#room.duels = []
room
.
dueling_players
=
[]
for
player
in
room
.
get_playing_player
()
playing_players
=
room
.
get_playing_player
()
for
player
in
playing_players
room
.
dueling_players
[
player
.
pos
]
=
player
room
.
scores
[
player
.
name_vpass
]
=
0
room
.
player_datas
.
push
key
:
CLIENT_get_authorize_key
(
player
),
name
:
player
.
name
,
pos
:
player
.
pos
...
...
@@ -3144,19 +3164,27 @@ ygopro.stoc_follow 'DUEL_START', false, (buffer, info, client, server, datas)->
ROOM_players_oppentlist
[
player
.
ip
]
=
null
if
room
.
hostinfo
.
auto_death
ygopro
.
stoc_send_chat_to_room
(
room
,
"${auto_death_part1}
#{
room
.
hostinfo
.
auto_death
}
${auto_death_part2}"
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
)
else
if
room
.
duel_stage
==
ygopro
.
constants
.
DUEL_STAGE
.
SIDING
and
client
.
pos
<
4
# side deck verified
client
.
selected_preduel
=
true
if
client
.
side_tcount
clearInterval
client
.
side_interval
client
.
side_interval
=
null
client
.
side_tcount
=
null
if
settings
.
modules
.
hide_name
==
"start"
and
room
.
duel_count
==
0
if
settings
.
modules
.
hide_name
==
"start"
for
player
in
room
.
get_playing_player
()
when
player
!=
client
ygopro
.
stoc_send
(
client
,
'HS_PLAYER_ENTER'
,
{
name
:
player
.
name
,
pos
:
player
.
pos
padding
:
0
,
})
if
room
.
arena
await
call_match_api
(
'POST'
,
'room-start'
,
{
usernameA
:
playing_players
[
0
].
name
,
usernameB
:
playing_players
[
1
].
name
,
roomname
:
room
.
name
,
starttime
:
room
.
start_time
,
arena
:
room
.
arena
})
else
if
room
.
duel_stage
==
ygopro
.
constants
.
DUEL_STAGE
.
SIDING
and
client
.
pos
<
4
# side deck verified
client
.
selected_preduel
=
true
if
client
.
side_tcount
clearInterval
client
.
side_interval
client
.
side_interval
=
null
client
.
side_tcount
=
null
if
settings
.
modules
.
tips
.
enabled
ygopro
.
stoc_send_random_tip
(
client
)
deck_text
=
null
...
...
ygopro-server.js
View file @
8ce9e25d
// Generated by CoffeeScript 2.7.0
(
function
()
{
// 标准库
var
Aragami
,
CLIENT_get_absolute_pos
,
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_get_partner
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
CLIENT_send_replays_and_kick
,
CLIENT_set_ip
,
PQueue
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
YGOProDeck
,
_
,
_async
,
addCallback
,
aragami
,
aragami_classes
,
athleticChecker
,
auth
,
axios
,
badwordR
,
badwords
,
ban_user
,
bunyan
,
challonge
,
checkFileExists
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
extra_mode_list
,
fs
,
geoip
,
getDuelLogQueryFromQs
,
getRealIp
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
ip6addr
,
isTrustedProxy
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_tips
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
moment_long_ago_string
,
moment_now
,
moment_now_string
,
msg_polyfill
,
neosRequestListener
,
net
,
netRequestHandler
,
os
,
osu
,
path
,
qs
,
real_windbot_server_ip
,
release_disconnect
,
report_to_big_brother
,
request
,
roomlist
,
rooms_count
,
setting_change
,
setting_get
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
toIpv4
,
toIpv6
,
url
,
util
,
utility
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
var
Aragami
,
CLIENT_get_absolute_pos
,
CLIENT_get_authorize_key
,
CLIENT_get_kick_reconnect_target
,
CLIENT_get_partner
,
CLIENT_heartbeat_register
,
CLIENT_heartbeat_unregister
,
CLIENT_import_data
,
CLIENT_is_able_to_kick_reconnect
,
CLIENT_is_able_to_reconnect
,
CLIENT_is_banned_by_mc
,
CLIENT_is_player
,
CLIENT_kick
,
CLIENT_kick_reconnect
,
CLIENT_pre_reconnect
,
CLIENT_reconnect
,
CLIENT_reconnect_register
,
CLIENT_reconnect_unregister
,
CLIENT_send_pre_reconnect_info
,
CLIENT_send_reconnect_info
,
CLIENT_send_replays
,
CLIENT_send_replays_and_kick
,
CLIENT_set_ip
,
PQueue
,
Q
,
ROOM_all
,
ROOM_bad_ip
,
ROOM_ban_player
,
ROOM_clear_disconnect
,
ROOM_connected_ip
,
ROOM_find_by_name
,
ROOM_find_by_pid
,
ROOM_find_by_port
,
ROOM_find_by_title
,
ROOM_find_or_create_ai
,
ROOM_find_or_create_by_name
,
ROOM_find_or_create_random
,
ROOM_kick
,
ROOM_player_flee
,
ROOM_player_get_score
,
ROOM_player_lose
,
ROOM_player_win
,
ROOM_players_oppentlist
,
ROOM_unwelcome
,
ROOM_validate
,
ReplayParser
,
ResolveData
,
Room
,
SERVER_clear_disconnect
,
SERVER_kick
,
SOCKET_flush_data
,
YGOProDeck
,
_
,
_async
,
addCallback
,
aragami
,
aragami_classes
,
athleticChecker
,
auth
,
axios
,
badwordR
,
badwords
,
ban_user
,
bunyan
,
c
all_match_api
,
c
hallonge
,
checkFileExists
,
createDirectoryIfNotExists
,
crypto
,
dataManager
,
deck_name_match
,
dialogues
,
disconnect_list
,
exec
,
execFile
,
extra_mode_list
,
fs
,
geoip
,
getDuelLogQueryFromQs
,
getRealIp
,
get_memory_usage
,
http
,
httpRequestListener
,
importOldConfig
,
import_datas
,
init
,
ip6addr
,
isTrustedProxy
,
lflists
,
loadJSON
,
loadJSONAsync
,
loadLFList
,
loadRemoteData
,
load_dialogues
,
load_tips
,
log
,
long_resolve_cards
,
memory_usage
,
merge
,
moment
,
moment_long_ago_string
,
moment_now
,
moment_now_string
,
msg_polyfill
,
neosRequestListener
,
net
,
netRequestHandler
,
os
,
osu
,
path
,
qs
,
real_windbot_server_ip
,
release_disconnect
,
report_to_big_brother
,
request
,
roomlist
,
rooms_count
,
setting_change
,
setting_get
,
setting_save
,
settings
,
spawn
,
spawnSync
,
spawn_windbot
,
tips
,
toIpv4
,
toIpv6
,
url
,
util
,
utility
,
wait_room_start
,
wait_room_start_arena
,
windbot_looplimit
,
windbot_process
,
windbots
,
ygopro
,
zlib
;
net
=
require
(
'
net
'
);
...
...
@@ -319,8 +319,34 @@
}
};
call_match_api
=
async
function
(
method
,
path
,
params
)
{
var
e
,
entry
,
key
,
match_api_url
,
res
,
val
;
if
(
!
settings
.
modules
.
arena_mode
.
match_api
.
enabled
)
{
return
null
;
}
match_api_url
=
new
URL
(
settings
.
modules
.
arena_mode
.
match_api
.
url
+
"
/
"
+
path
);
match_api_url
.
searchParams
.
append
(
'
ak
'
,
settings
.
modules
.
arena_mode
.
match_api
.
accesskey
);
for
(
entry
in
Object
.
entries
(
params
))
{
key
=
entry
[
0
];
val
=
entry
[
1
];
match_api_url
.
searchParams
.
append
(
key
,
val
);
}
try
{
res
=
(
await
axios
({
method
:
method
,
url
:
match_api_url
.
toString
(),
timeout
:
30000
}));
return
res
.
data
;
}
catch
(
error1
)
{
e
=
error1
;
log
.
warn
(
'
MATCH API CALL ERROR
'
,
method
,
path
,
JSON
.
stringify
(
params
),
e
.
toString
());
return
null
;
}
};
init
=
async
function
()
{
var
AthleticChecker
,
Challonge
,
DataManager
,
chat_color
,
config
,
cppversion
,
defaultConfig
,
default_data
,
dirPath
,
dns
,
e
,
get_rooms_count
,
http_server
,
https
,
httpsOptions
,
https_server
,
imported
,
j
,
key
,
keysFromEnv
,
l
,
len
,
len1
,
len2
,
m
,
main_http_server
,
mkdirList
,
neosHttpServer
,
neosWsServer
,
plugin_filename
,
plugin_list
,
plugin_path
,
postData
,
settingKey
,
val
,
valFromDefault
,
ws
;
var
AthleticChecker
,
Challonge
,
DataManager
,
chat_color
,
config
,
cppversion
,
defaultConfig
,
default_data
,
dirPath
,
dns
,
e
,
get_rooms_count
,
http_server
,
https
,
httpsOptions
,
https_server
,
imported
,
j
,
key
,
keysFromEnv
,
l
,
len
,
len1
,
len2
,
m
,
main_http_server
,
mkdirList
,
neosHttpServer
,
neosWsServer
,
plugin_filename
,
plugin_list
,
plugin_path
,
settingKey
,
val
,
valFromDefault
,
ws
;
log
.
info
(
'
Reading config.
'
);
await
createDirectoryIfNotExists
(
"
./config
"
);
await
importOldConfig
();
...
...
@@ -438,6 +464,15 @@
delete
settings
.
modules
.
neos
.
trusted_proxies
;
imported
=
true
;
}
// migrate arena_mode.init_post to match_api
if
(
settings
.
modules
.
arena_mode
.
init_post
)
{
settings
.
modules
.
arena_mode
.
match_api
=
settings
.
modules
.
arena_mode
.
init_post
;
if
(
settings
.
modules
.
arena_mode
.
match_api
.
url
.
endsWith
(
'
/clear
'
))
{
settings
.
modules
.
arena_mode
.
match_api
.
url
=
settings
.
modules
.
arena_mode
.
match_api
.
url
.
slice
(
0
,
-
6
);
}
delete
settings
.
modules
.
arena_mode
.
init_post
;
imported
=
true
;
}
//finish
keysFromEnv
=
Object
.
keys
(
process
.
env
).
filter
((
key
)
=>
{
return
key
.
startsWith
(
'
SRVPRO_
'
);
...
...
@@ -615,18 +650,10 @@
// pg_client.on 'drain', pg_client.end.bind(pg_client)
// log.info "loading mycard user..."
// pg_client.connect()
if
(
settings
.
modules
.
arena_mode
.
enabled
&&
settings
.
modules
.
arena_mode
.
init_post
.
enabled
)
{
postData
=
qs
.
stringify
({
ak
:
settings
.
modules
.
arena_mode
.
init_post
.
accesskey
,
if
(
settings
.
modules
.
arena_mode
.
enabled
)
{
await
call_match_api
(
'
POST
'
,
'
clear
'
,
{
arena
:
settings
.
modules
.
arena_mode
.
mode
});
try
{
log
.
info
(
"
Sending arena init post.
"
);
await
axios
.
post
(
settings
.
modules
.
arena_mode
.
init_post
.
url
+
"
?
"
+
postData
);
}
catch
(
error1
)
{
e
=
error1
;
log
.
warn
(
'
ARENA INIT POST ERROR
'
,
e
);
}
}
}
if
(
settings
.
modules
.
challonge
.
enabled
)
{
...
...
@@ -3245,7 +3272,7 @@
}
}
if
(
!
decrypted_buffer
)
{
ygopro
.
stoc_die
(
client
,
'
${invalid_password_
checksum
}
'
);
ygopro
.
stoc_die
(
client
,
'
${invalid_password_
unauthorized
}
'
);
return
;
}
return
create_room_with_action
(
decrypted_buffer
);
...
...
@@ -4156,7 +4183,7 @@
};
ygopro
.
stoc_follow
(
'
DUEL_START
'
,
false
,
async
function
(
buffer
,
info
,
client
,
server
,
datas
)
{
var
deck_arena
,
deck_name
,
deck_text
,
j
,
l
,
len
,
len1
,
player
,
ref
,
ref1
,
room
;
var
deck_arena
,
deck_name
,
deck_text
,
j
,
l
,
len
,
len1
,
player
,
playing_players
,
ref
,
room
;
room
=
ROOM_all
[
client
.
rid
];
if
(
!
(
room
&&
!
client
.
reconnecting
))
{
return
;
...
...
@@ -4170,9 +4197,9 @@
}
//room.duels = []
room
.
dueling_players
=
[];
ref
=
room
.
get_playing_player
();
for
(
j
=
0
,
len
=
ref
.
length
;
j
<
len
;
j
++
)
{
player
=
ref
[
j
];
playing_players
=
room
.
get_playing_player
();
for
(
j
=
0
,
len
=
playing_players
.
length
;
j
<
len
;
j
++
)
{
player
=
playing_players
[
j
];
room
.
dueling_players
[
player
.
pos
]
=
player
;
room
.
scores
[
player
.
name_vpass
]
=
0
;
room
.
player_datas
.
push
({
...
...
@@ -4188,18 +4215,10 @@
if
(
room
.
hostinfo
.
auto_death
)
{
ygopro
.
stoc_send_chat_to_room
(
room
,
`\${auto_death_part1}
${
room
.
hostinfo
.
auto_death
}
\${auto_death_part2}`
,
ygopro
.
constants
.
COLORS
.
BABYBLUE
);
}
}
else
if
(
room
.
duel_stage
===
ygopro
.
constants
.
DUEL_STAGE
.
SIDING
&&
client
.
pos
<
4
)
{
// side deck verified
client
.
selected_preduel
=
true
;
if
(
client
.
side_tcount
)
{
clearInterval
(
client
.
side_interval
);
client
.
side_interval
=
null
;
client
.
side_tcount
=
null
;
}
}
if
(
settings
.
modules
.
hide_name
===
"
start
"
&&
room
.
duel_count
===
0
)
{
ref1
=
room
.
get_playing_player
();
for
(
l
=
0
,
len1
=
ref1
.
length
;
l
<
len1
;
l
++
)
{
player
=
ref1
[
l
];
if
(
settings
.
modules
.
hide_name
===
"
start
"
)
{
ref
=
room
.
get_playing_player
();
for
(
l
=
0
,
len1
=
ref
.
length
;
l
<
len1
;
l
++
)
{
player
=
ref
[
l
];
if
(
player
!==
client
)
{
ygopro
.
stoc_send
(
client
,
'
HS_PLAYER_ENTER
'
,
{
name
:
player
.
name
,
...
...
@@ -4209,6 +4228,23 @@
}
}
}
if
(
room
.
arena
)
{
await
call_match_api
(
'
POST
'
,
'
room-start
'
,
{
usernameA
:
playing_players
[
0
].
name
,
usernameB
:
playing_players
[
1
].
name
,
roomname
:
room
.
name
,
starttime
:
room
.
start_time
,
arena
:
room
.
arena
});
}
}
else
if
(
room
.
duel_stage
===
ygopro
.
constants
.
DUEL_STAGE
.
SIDING
&&
client
.
pos
<
4
)
{
// side deck verified
client
.
selected_preduel
=
true
;
if
(
client
.
side_tcount
)
{
clearInterval
(
client
.
side_interval
);
client
.
side_interval
=
null
;
client
.
side_tcount
=
null
;
}
}
if
(
settings
.
modules
.
tips
.
enabled
)
{
ygopro
.
stoc_send_random_tip
(
client
);
}
...
...
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