mirror of
https://github.com/onyx-and-iris/q3rcon-ps.git
synced 2026-03-03 05:49:10 +00:00
Compare commits
No commits in common. "eeae1c76b4cff7aa51dd06b003a2414e9a9ab4fd" and "cb90ad8030f30830c4949b37df53a615c6256207" have entirely different histories.
eeae1c76b4
...
cb90ad8030
15
Taskfile.yml
15
Taskfile.yml
@ -1,15 +0,0 @@
|
|||||||
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}}
|
|
||||||
@ -12,13 +12,18 @@ function Read-HostUntilEmpty {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
$resp = $rcon.Send($line)
|
if ($line -in @('fast_restart', 'map_rotate', 'map_restart')) {
|
||||||
Write-Host (Remove-ColourCodes $resp)
|
$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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Remove-ColourCodes($str) {
|
|
||||||
return $str -replace '\^[0-9]', ''
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-ConnFromPSD1 {
|
function Get-ConnFromPSD1 {
|
||||||
|
|||||||
@ -75,19 +75,27 @@ function Send-RconCommand() {
|
|||||||
param($rcon)
|
param($rcon)
|
||||||
|
|
||||||
$line = $OTB.Text
|
$line = $OTB.Text
|
||||||
Write-Debug "Sending command: $line"
|
$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)
|
$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 = Remove-ColourCodes "$($Matches.name): $($Matches.value)"
|
$RLbl.Text = $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'
|
||||||
|
|||||||
@ -122,7 +122,7 @@ class Base {
|
|||||||
try {
|
try {
|
||||||
$bytesReceived = $this._socket.Receive($this._receiveBuffer)
|
$bytesReceived = $this._socket.Receive($this._receiveBuffer)
|
||||||
if ($bytesReceived -gt 0) {
|
if ($bytesReceived -gt 0) {
|
||||||
$dataStartIndex = [Math]::Min($headerLength - 1, $bytesReceived)
|
$dataStartIndex = [Math]::Min($headerLength, $bytesReceived)
|
||||||
$responseText = [System.Text.Encoding]::ASCII.GetString($this._receiveBuffer, $dataStartIndex, $bytesReceived - $dataStartIndex)
|
$responseText = [System.Text.Encoding]::ASCII.GetString($this._receiveBuffer, $dataStartIndex, $bytesReceived - $dataStartIndex)
|
||||||
$responseData.Append($responseText) | Out-Null
|
$responseData.Append($responseText) | Out-Null
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user