Skip to content

Commit

Permalink
updated - gamedig query
Browse files Browse the repository at this point in the history
  • Loading branch information
Robomikel committed May 3, 2023
1 parent ae241dc commit 5160e7d
Showing 1 changed file with 48 additions and 8 deletions.
56 changes: 48 additions & 8 deletions functions/command_query.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,29 @@ Function Get-GamedigServerv2 {
Write-log "info: Using port $querytype ${extip}:${port} "
If (!(test-path $nodejsprogramexecutable)) {
$query = (.\gamedig --type $querytype ${extip}:${port} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
}
Else {
# saps powershell -args (" $queryOutput = ((((( gamedig --type $querytype ${extip}:${port} --pretty ).trim()).replace(`'`"`',`'`')).replace(`'{`',`'`')).replace(`',`',`'`')).replace(`'}`',`'`') ; $queryOutput")
# $queryOutput = saps powershell -args ("gamedig --type $querytype ${extip}:${port} --pretty") -wait -nnw
# $queryOutput = ((((($queryOutput).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
$query = (gamedig --type $querytype ${extip}:${port} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput

}
}
Else {
Write-log "info: Using queryport $querytype ${extip}:${queryport}"
If (!(test-path $nodejsprogramexecutable)) {
$query = (.\gamedig --type $querytype ${extip}:${queryport} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
}
Else {
# saps powershell -args (" $queryOutput = ((((( gamedig --type $querytype ${extip}:${port} --pretty ).trim()).replace(`'`"`',`'`')).replace(`'{`',`'`')).replace(`',`',`'`')).replace(`'}`',`'`') ; $queryOutput")
# $queryOutput = saps powershell -args ("gamedig --type $querytype ${extip}:${queryport} --pretty") -wait -nnw
# $queryOutput = ((((($queryOutput).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
$query = (gamedig --type $querytype ${extip}:${queryOutput} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput

}
}
Expand All @@ -50,35 +50,75 @@ Function Get-GamedigServerv2 {
Write-log "info: Using port $querytype ${ip}:${port} "
If (!(test-path $nodejsprogramexecutable)) {
$query = (.\gamedig --type $querytype ${ip}:${port} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
}
Else {
# saps powershell -args (" $queryOutput = ((((( gamedig --type $querytype ${extip}:${port} --pretty ).trim()).replace(`'`"`',`'`')).replace(`'{`',`'`')).replace(`',`',`'`')).replace(`'}`',`'`') ; $queryOutput")
# $queryOutput = saps powershell -args ("gamedig --type $querytype ${ip}:${port} --pretty") -wait -nnw
# $queryOutput = ((((($queryOutput).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
$query = (gamedig --type $querytype ${ip}:${port} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput

}
}
Else {
Write-log "info: Using queryport $querytype ${ip}:${queryport}"
If (!(test-path $nodejsprogramexecutable)) {
$query = (.\gamedig --type $querytype ${ip}:${queryport} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
}
Else {
# saps powershell -args (" $queryOutput = ((((( gamedig --type $querytype ${extip}:${port} --pretty ).trim()).replace(`'`"`',`'`')).replace(`'{`',`'`')).replace(`',`',`'`')).replace(`'}`',`'`') ; $queryOutput")
# $queryOutput = saps powershell -args ("gamedig --type $querytype ${ip}:${queryport} --pretty") -wait -nnw
# $queryOutput = ((((($queryOutput).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
$query = (gamedig --type $querytype ${ip}:${queryport} --pretty)
$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput
#$queryOutput = ((((( $query ).trim()).replace('"', '')).replace('{', '')).replace(',', '')).replace('}', '') ; $queryOutput

}
}
#$queryOutput
$query = $query | ConvertFrom-Json
$properties = ($query | Get-Member -MemberType Properties).Name
[hashtable]$table = @{
PSTypeName = "GAMEDIG"
}
If ($query.players) {
# write-host "players $($query.players)" -F R
$test = ($query.players | Get-Member -MemberType Properties).Name
ForEach ($property in $test) {
# write-host "$property" -F C
If ($query.players."$property") {
$n = $property + ": " + $query.players."$property"
$table.Add($property, $query.players."$property")
Write-log "[GAMEDIG] $n"
}

}
}
If ($query.raw) {
# write-host "raw $($query.raw)" -F R
$test = ($query.raw | Get-Member -MemberType Properties).Name
ForEach ($property in $test) {
# write-host "$property" -F C
If ($query.raw."$property") {
$n = $property + ": " + $query.raw."$property"
$table.Add($property, $query.raw."$property")
Write-log "[GAMEDIG] $n"
}

}
}
ForEach ($property in $properties) {
If ($query."$property") {
$n = $property + ": " + $query."$property"
$table.Add($property, $query."$property")
Write-log "[GAMEDIG] $n"
}
}
if ($table) {
$htable = New-Object -TypeName psobject -Property $table
$htable | Format-List
}
# Write-Host "Name: $($queryOutput.name)"
# Write-Host "Map: $($queryOutput.map)"
# Write-Host "Password: $($queryOutput.password)"
Expand Down

0 comments on commit 5160e7d

Please sign in to comment.