mirror of
https://github.com/aclist/dztui.git
synced 2025-07-24 16:38:48 +02:00
chore: uncomment
This commit is contained in:
parent
dda35074fb
commit
3a47ee9057
6 changed files with 115 additions and 53 deletions
helpers
|
@ -43,6 +43,7 @@ _cache_history="$cache_dir/$prefix.history"
|
|||
_cache_launch="$cache_dir/$prefix.launch_mods"
|
||||
_cache_address="$cache_dir/$prefix.launch_address"
|
||||
_cache_coords="$cache_path/$prefix.coords"
|
||||
_cache_cooldown="$cache_path/$prefix.cooldown"
|
||||
|
||||
#XDG
|
||||
freedesktop_path="$HOME/.local/share/applications"
|
||||
|
@ -107,7 +108,9 @@ declare -A funcs=(
|
|||
["dump_servers"]="dump_servers"
|
||||
["get_unique_maps"]="get_unique_maps"
|
||||
["get_dist"]="get_dist"
|
||||
["test_cooldown"]="test_cooldown"
|
||||
["query_config"]="query_config"
|
||||
["start_cooldown"]="start_cooldown"
|
||||
["list_mods"]="list_mods"
|
||||
["delete"]="delete_local_mod"
|
||||
["show_server_modlist"]="show_server_modlist"
|
||||
|
@ -117,7 +120,7 @@ declare -A funcs=(
|
|||
["gen_log"]="generate_log"
|
||||
["open_workshop_page"]="open_workshop_page"
|
||||
["Add to my servers"]="update_favs_from_table"
|
||||
["Remove from favorites"]="update_favs_from_table"
|
||||
["Remove from my servers"]="update_favs_from_table"
|
||||
["Remove from history"]="remove_from_history"
|
||||
["force_update"]="force_update"
|
||||
["Handshake"]="final_handshake"
|
||||
|
@ -132,7 +135,8 @@ get_player_count(){
|
|||
res=$(a2s $ip $qport info)
|
||||
[[ ! $? -eq 0 ]] && return 1
|
||||
local players="$(<<< $res jq -r '.[].players')"
|
||||
printf "%s" "$players"
|
||||
local queue="$(<<< $res jq -r '.[].gametype|split("lqs")[1]|split(",")[0]')"
|
||||
printf "%s\n%s" "$players" "$queue"
|
||||
}
|
||||
|
||||
validate_and_connect(){
|
||||
|
@ -252,6 +256,10 @@ connect_by_id(){
|
|||
fi
|
||||
#res contains modlist
|
||||
}
|
||||
start_cooldown(){
|
||||
logger WARN "API response empty. Started 60s cooldown at $(date +%s)"
|
||||
date +%s > $_cache_cooldown
|
||||
}
|
||||
initialize_remote_servers(){
|
||||
local file="$_cache_servers"
|
||||
[[ -f $file ]] && rm "$file"
|
||||
|
@ -513,6 +521,7 @@ parse_server_json(){
|
|||
"\(if .gametype == null then "null" else (.gametype as $time|$time|test("[0-9]{2}:[0-9]{2}$") as $match|(if $match == true then ($time|scan("[0-9]{2}:[0-9]{2}$")) else "XXXX" end)) end)␞" +
|
||||
"\(.players)␞" +
|
||||
"\(.max_players)␞" +
|
||||
"\(if .gametype == null then "0" else .gametype|split("lqs")[1]|split(",")[0] end)␞" +
|
||||
"\(.addr|split(":")[0]):\(if .gameport == null then "XXXX" else .gameport end)␞" +
|
||||
"\(.addr|split(":")[1])"
|
||||
' | sort -k1
|
||||
|
@ -526,6 +535,19 @@ delete_local_mod(){
|
|||
#SC2115
|
||||
rm -rf "${workshop_dir:?}/$dir" && unlink "$game_dir/$symlink" || return 1
|
||||
}
|
||||
test_cooldown(){
|
||||
[[ ! -f $_cache_cooldown ]] && return 0
|
||||
local old_time=$(< $_cache_cooldown)
|
||||
local cur_time=$(date +%s)
|
||||
local delta=$(($cur_time - $old_time))
|
||||
local suffix="seconds"
|
||||
if [[ $delta -lt 60 ]]; then
|
||||
local remains=$((60 - $delta))
|
||||
[[ $remains -eq 1 ]] && suffix="second"
|
||||
printf "Global API cooldown in effect. Please wait %s %s." "$remains" "$suffix"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
dump_servers(){
|
||||
local context="$1"
|
||||
local subcontext="$2"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue