mirror of
				https://github.com/onyx-and-iris/q3rcon-ps.git
				synced 2025-11-04 06:41:44 +00:00 
			
		
		
		
	lowercase login method to indicate it as internal method
added method overload for {Rcon}.Send
			
			
This commit is contained in:
		
							parent
							
								
									e446a45a6c
								
							
						
					
					
						commit
						7683665c7c
					
				@ -1,5 +1,10 @@
 | 
				
			|||||||
. $PSScriptRoot\packet.ps1
 | 
					try {
 | 
				
			||||||
. $PSScriptRoot\base.ps1    
 | 
					    . (Join-Path $PSScriptRoot packet.ps1)
 | 
				
			||||||
 | 
					    . (Join-Path $PSScriptRoot base.ps1)     
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					catch {
 | 
				
			||||||
 | 
					    throw "unable to dot source module files"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class Rcon {
 | 
					class Rcon {
 | 
				
			||||||
@ -9,8 +14,8 @@ class Rcon {
 | 
				
			|||||||
        $this.base = New-Base -hostname $hostname -port $port -passwd $passwd
 | 
					        $this.base = New-Base -hostname $hostname -port $port -passwd $passwd
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [Rcon] Login() {
 | 
					    [Rcon] _login() {
 | 
				
			||||||
        $resp = $this.base._send("login")
 | 
					        $resp = $this.Send("login")
 | 
				
			||||||
        if ($resp -in @("Bad rcon", "Bad rconpassword.", "Invalid password.")) {
 | 
					        if ($resp -in @("Bad rcon", "Bad rconpassword.", "Invalid password.")) {
 | 
				
			||||||
            throw "invalid rcon password"
 | 
					            throw "invalid rcon password"
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@ -18,55 +23,59 @@ class Rcon {
 | 
				
			|||||||
        return $this
 | 
					        return $this
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [string] Send($msg) {
 | 
					    [string] Send([string]$msg) {
 | 
				
			||||||
        return $this.base._send($msg)
 | 
					        return $this.base._send($msg)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    [string] Send([string]$msg, [int]$timeout) {
 | 
				
			||||||
 | 
					        return $this.base._send($msg, $timeout)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] Say($msg) {
 | 
					    [void] Say($msg) {
 | 
				
			||||||
        $this.base._send($msg)
 | 
					        $this.Send("say $msg")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] FastRestart() {
 | 
					    [void] FastRestart() {
 | 
				
			||||||
        $this.base._send("fast_restart", 2000)
 | 
					        $this.Send("fast_restart", 2000)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] MapRotate() {
 | 
					    [void] MapRotate() {
 | 
				
			||||||
        $this.base._send("map_rotate", 2000)
 | 
					        $this.Send("map_rotate", 2000)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] MapRestart() {
 | 
					    [void] MapRestart() {
 | 
				
			||||||
        $this.base._send("map_restart", 2000)
 | 
					        $this.Send("map_restart", 2000)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [string] Map() {
 | 
					    [string] Map() {
 | 
				
			||||||
        return $this.base._send("mapname")
 | 
					        return $this.Send("mapname")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] SetMap($mapname) {
 | 
					    [void] SetMap($mapname) {
 | 
				
			||||||
        $this.base._send("map mp_$mapname")
 | 
					        $this.Send("map mp_" + $mapname.TrimStart("mp_"), 2000)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [string] Gametype() {
 | 
					    [string] Gametype() {
 | 
				
			||||||
        return $this.base._send("g_gametype")
 | 
					        return $this.Send("g_gametype")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] SetGametype($gametype) {
 | 
					    [void] SetGametype($gametype) {
 | 
				
			||||||
        $this.base._send("g_gametype $gametype")
 | 
					        $this.Send("g_gametype $gametype")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [string] HostName() {
 | 
					    [string] HostName() {
 | 
				
			||||||
        return $this.base._send("sv_hostname")
 | 
					        return $this.Send("sv_hostname")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [void] SetHostName($hostname) {
 | 
					    [void] SetHostName($hostname) {
 | 
				
			||||||
        $this.base._send("sv_hostname $hostname")
 | 
					        $this.Send("sv_hostname $hostname")
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Function Connect-Rcon {
 | 
					Function Connect-Rcon {
 | 
				
			||||||
    param([string]$hostname, [int]$port, [string]$passwd)
 | 
					    param([string]$hostname, [int]$port, [string]$passwd)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    [Rcon]::new($hostname, $port, $passwd).Login()
 | 
					    [Rcon]::new($hostname, $port, $passwd)._login()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Function Disconnect-Rcon {
 | 
					Function Disconnect-Rcon {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user