mirror of
https://github.com/onyx-and-iris/q3rcon-ps.git
synced 2026-02-21 00:59:11 +00:00
the timeouts hash means we can simplify the logic in CLI, GUI examples
colour codes removed from response output.
This commit is contained in:
parent
9209c705ce
commit
fa02d0c65e
@ -12,20 +12,15 @@ function Read-HostUntilEmpty {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) {
|
$resp = $rcon.Send($line)
|
||||||
$cmd = $line -replace '(?:^|_)(\p{L})', { $_.Groups[1].Value.ToUpper() }
|
Write-Host (Remove-ColourCodes $resp)
|
||||||
$rcon.$cmd()
|
|
||||||
}
|
|
||||||
elseif ($line.StartsWith('map mp_')) {
|
|
||||||
$mapname = $line.Split()[1]
|
|
||||||
$rcon.SetMap($mapname)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$rcon.Send($line)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Remove-ColourCodes($str) {
|
||||||
|
return $str -replace '\^[0-9]', ''
|
||||||
|
}
|
||||||
|
|
||||||
function Get-ConnFromPSD1 {
|
function Get-ConnFromPSD1 {
|
||||||
$configpath = Join-Path $PSScriptRoot 'config.psd1'
|
$configpath = Join-Path $PSScriptRoot 'config.psd1'
|
||||||
return Import-PowerShellDataFile -Path $configpath
|
return Import-PowerShellDataFile -Path $configpath
|
||||||
|
|||||||
@ -75,27 +75,19 @@ function Send-RconCommand() {
|
|||||||
param($rcon)
|
param($rcon)
|
||||||
|
|
||||||
$line = $OTB.Text
|
$line = $OTB.Text
|
||||||
$line | Write-Debug
|
Write-Debug "Sending command: $line"
|
||||||
if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) {
|
$resp = $rcon.Send($line)
|
||||||
$RLbl.Text = ''
|
|
||||||
$cmd = $line -replace '(?:^|_)(\p{L})', { $_.Groups[1].Value.ToUpper() }
|
|
||||||
$rcon.$cmd()
|
|
||||||
}
|
|
||||||
elseif ($line.StartsWith('map mp_')) {
|
|
||||||
$RLbl.Text = ''
|
|
||||||
$mapname = $line.Split()[1]
|
|
||||||
$rcon.SetMap($mapname)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$resp = $rcon.Send($line)
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($resp -match '^["](?<name>[a-z_]+)["]\sis[:]\s["](?<value>.*?)\^7["]\s') {
|
if ($resp -match '^["](?<name>[a-z_]+)["]\sis[:]\s["](?<value>.*?)\^7["]\s') {
|
||||||
$RLbl.Text = $Matches.name + ': ' + $Matches.value
|
$RLbl.Text = Remove-ColourCodes "$($Matches.name): $($Matches.value)"
|
||||||
}
|
}
|
||||||
$OTB.Text = ''
|
$OTB.Text = ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Remove-ColourCodes($str) {
|
||||||
|
return $str -replace '\^[0-9]', ''
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function Get-ConnFromPSD1 {
|
function Get-ConnFromPSD1 {
|
||||||
$configpath = Join-Path $PSScriptRoot 'config.psd1'
|
$configpath = Join-Path $PSScriptRoot 'config.psd1'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user