Compare commits

...

3 Commits

Author SHA1 Message Date
eeae1c76b4 add Taskfile for bumping manifest version 2026-02-18 11:27:20 +00:00
fa02d0c65e the timeouts hash means we can simplify the logic in CLI, GUI examples
colour codes removed from response output.
2026-02-18 11:19:09 +00:00
9209c705ce fixes bug skipping first char of response 2026-02-18 11:18:25 +00:00
4 changed files with 29 additions and 27 deletions

15
Taskfile.yml Normal file
View File

@ -0,0 +1,15 @@
version: '3'
tasks:
bump:
desc: 'Bump the module version in the .psd1 file. Usage: "task bump -- show" or "task bump -- [patch|minor|major]".'
preconditions:
- sh: 'pwsh -c "if (Get-Command bump) { exit 0 } else { exit 1 }"'
msg: "The 'bump' command is not available. Please install the required tools to use this command."
cmds:
- |
{{if eq .CLI_ARGS "show"}}
pwsh -c "bump show -f lib/Q3Rcon.psd1 -p \"ModuleVersion\s*=\s'(\d+\.\d+\.\d+)'\""
{{else}}
pwsh -c "bump {{.CLI_ARGS}} -w -f lib/Q3Rcon.psd1 -p \"ModuleVersion\s*=\s'(\d+\.\d+\.\d+)'\""
{{end}}

View File

@ -12,20 +12,15 @@ function Read-HostUntilEmpty {
break
}
if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) {
$cmd = $line -replace '(?:^|_)(\p{L})', { $_.Groups[1].Value.ToUpper() }
$rcon.$cmd()
}
elseif ($line.StartsWith('map mp_')) {
$mapname = $line.Split()[1]
$rcon.SetMap($mapname)
}
else {
$rcon.Send($line)
}
$resp = $rcon.Send($line)
Write-Host (Remove-ColourCodes $resp)
}
}
function Remove-ColourCodes($str) {
return $str -replace '\^[0-9]', ''
}
function Get-ConnFromPSD1 {
$configpath = Join-Path $PSScriptRoot 'config.psd1'
return Import-PowerShellDataFile -Path $configpath

View File

@ -75,27 +75,19 @@ function Send-RconCommand() {
param($rcon)
$line = $OTB.Text
$line | Write-Debug
if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) {
$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)
}
Write-Debug "Sending command: $line"
$resp = $rcon.Send($line)
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 = ''
}
function Remove-ColourCodes($str) {
return $str -replace '\^[0-9]', ''
}
function Get-ConnFromPSD1 {
$configpath = Join-Path $PSScriptRoot 'config.psd1'

View File

@ -122,7 +122,7 @@ class Base {
try {
$bytesReceived = $this._socket.Receive($this._receiveBuffer)
if ($bytesReceived -gt 0) {
$dataStartIndex = [Math]::Min($headerLength, $bytesReceived)
$dataStartIndex = [Math]::Min($headerLength - 1, $bytesReceived)
$responseText = [System.Text.Encoding]::ASCII.GetString($this._receiveBuffer, $dataStartIndex, $bytesReceived - $dataStartIndex)
$responseData.Append($responseText) | Out-Null
}