Skip to content

Instantly share code, notes, and snippets.

@Geczy
Created January 16, 2024 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Geczy/3b59a819a8afb9ac12fad55971dd4bb5 to your computer and use it in GitHub Desktop.
Save Geczy/3b59a819a8afb9ac12fad55971dd4bb5 to your computer and use it in GitHub Desktop.
dotabod debugging
## .\debug.ps1 -Token c123123123123123 -Online $true -Name poecco -Steam32Id 33365540
## powershell -c "irm bun.sh/debug.ps1 | iex -Args 'param1Value', 'param2Value'"
param (
[parameter(mandatory=$true)] [ValidateNotNullOrEmpty()] [string]$Token,
[bool]$Online = $false,
[string]$Name,
[int]$Steam32Id
)
$asciiArt = @"
@
@@
@@
@@@
@@
@@
@@@ @ @
@@@ @ @@
@@ @ @
@ @@ @@
@@@ @@ @@
@ @@ @@@
@@ @@ @@
@@@ @@@ @
@@ @ @
@@ @@ @@
@@ @ @@
@@ @@ @@
@@ @@@
@ @@@
@ @@
@
@@@
@@
@
"@
# Calculate the width of the console window
$windowWidth = [Console]::WindowWidth
# Split the ASCII art into lines
$lines = $asciiArt -split "`n"
# Echo each line, centered
foreach ($line in $lines) {
# Calculate the padding needed to center the line
$padding = [Math]::Max(0, ($windowWidth - $line.Length) / 2)
# Write the line with padding
Write-Host (" " * $padding + $line)
}
if($Name -ne $null) { $Name = $Name.ToLower() }
Write-Host "`n"
Write-Host ('=' * 40) "dotabod installation debugger" ('=' * 40) -b darkgray -f black
Write-Host "`n"
# Detect STEAM Path
$steamRegistryPath = 'HKCU:\SOFTWARE\Valve\Steam'
if (Test-Path -Path $steamRegistryPath) {
$steamRegistry = Get-ItemProperty -Path $steamRegistryPath -Name 'SteamPath'
if ($steamRegistry -ne $null) {
$steam = $steamRegistry.SteamPath -replace '/', '\'
$libfs = $null
if (-not (Test-Path "$steam\steamapps\libraryfolders.vdf")) {
$steam = (Get-Item -LiteralPath $steam).FullName
}
}
} else {
Write-Host "Error: Steam registry path not found. Please ensure Steam is installed correctly." -f darkred
}
if ($null -eq $steam) {
Write-Host "Error: Steam path is null. Please verify the Steam installation." -f darkred
return
}
# Detect DOTA2 Path
$libraryFolders = Get-Content "$steam\steamapps\libraryfolders.vdf" -Raw
if ($libraryFolders -ne $null) {
$libfs = $libraryFolders | Select-String -Pattern '\"[a-zA-Z]:\\.+\"' | ForEach-Object { $_.Matches.Groups[0].Value } | ForEach-Object {
$libfsPath = $_ -replace '"', '' -replace "\\\\", "\"
if ((Test-Path "$libfsPath\steamapps\appmanifest_570.acf") -and (Test-Path "$libfsPath\steamapps\common\dota 2 beta\game\core\pak01_dir.vpk")) {
$_
}
}
}
# Assign Paths
$steamapps = if ($libfs -ne $null) {
$libfs = $libfs -replace '"', '' -replace "\\\\", "\"
$libfs = $libfs.ToLower()
Join-Path $libfs 'steamapps'
} else { Join-Path $steam 'steamapps' }
$dota2 = Join-Path $steamapps 'common\dota 2 beta'
$gsi = Join-Path $dota2 '\game\dota\cfg\gamestate_integration'
# Check Paths
if (Test-Path -Path $steam -PathType Container) {
Write-Host "Steam path: $steam" -f darkgreen
} else {
Write-Host "Steam path: Path not found ($steam)" -f darkred
}
if (Test-Path -Path $dota2 -PathType Container) {
Write-Host "Dota path: $dota2" -f darkgreen
} else {
Write-Host "Dota path: Path not found ($dota2)" -f darkred
}
if (Test-Path -Path $gsi -PathType Container) {
Write-Host "GSI path: $gsi" -f darkgreen
} else {
Write-Host "GSI path: Path not found ($gsi)" -f darkred
}
Write-Host "`n"
# Check config(s)
$configs = @()
Get-ChildItem -Path $gsi\ -Filter gamestate_integration_dotabod*.cfg | ForEach-Object {
$configs += $_.name
}
if ($configs.Count -gt 1) {
$configsTemp = $configs -join ", "
if ($Name -ne $null) {
if (Test-Path -Path "$gsi\gamestate_integration_dotabod-$Name.cfg" -PathType Leaf) {
$config = "gamestate_integration_dotabod-$Name.cfg"
Write-Host "Config: Found multiple configs, $configsTemp." -f darkyellow
} else {
$config = $configs[0]
Write-Host "Config: Found multiple configs, $configsTemp." -f darkred
}
}
} elseif ($configs.Count -eq 1) {
Write-Host "Config: Found config, $configs." -f darkgreen
$config = $configs[0]
} else {
Write-Host "Config: Not found in GSI." -f darkred
}
# Check token in Config
try {
$configContent = Get-Content "$gsi\$config" -Raw
} catch {
Write-Host "Error: Access denied when trying to read from $gsi\$config. Please ensure the script has the necessary permissions." -f darkred
return
}
if ($configContent -ne $null) {
$tokenRegex = '"token"\s+"([^"]+)"'
$tokenMatch = [regex]::Match($configContent, $tokenRegex)
if ($tokenMatch.Success) {
$configToken = $tokenMatch.Groups[1].Value
if ($configToken -eq $Token) {
Write-Host "Token: Found & matches." -f darkgreen
} else {
Write-Host "Token: Found but doesn't match." -f darkred
}
} else {
Write-Host "Token: Not found in the configuration file."
}
}
# Check Launch Options
$userdata = Join-Path $steam 'userdata'
$userdataFolders = Get-ChildItem -Path $userdata -Directory
foreach ($userdataFolder in $userdataFolders) {
if ($userdataFolder.Name -eq $Steam32Id) {
$localConfig = $($userdataFolder.FullName)
break # exit early if found
}
}
if ($localConfig -ne $null) {
$localConfig = Join-Path $localConfig -ChildPath 'config' | Join-Path -ChildPath 'localconfig.vdf'
$searchTerm = '"570"'
$followingLineStart = '\s*{'
$targetKeyword = "LaunchOptions"
$substringToCheck = "-gamestateintegration"
$content = Get-Content $localConfig
$searchPattern = [regex]::Escape($searchTerm)
$followingLinePattern = "$followingLineStart.*"
$targetKeywordPattern = [regex]::Escape($targetKeyword)
for ($i = 0; $i -lt $content.Count; $i++) {
$line = $content[$i]
if ($line -match $searchPattern) {
$followingLine = $content[$i + 1]
if ($followingLine -match $followingLinePattern) {
for ($j = $i + 2; $j -lt $content.Count; $j++) {
$launchOptionsLine = $content[$j]
if ($launchOptionsLine -match $targetKeywordPattern) {
$launchOptionsValue = $launchOptionsLine -replace '.*"([^"]*)".*', '$1'
if ($launchOptionsValue -like "*$substringToCheck*") {
Write-Host "Launch Options: Contains '$substringToCheck'" -f darkgreen
} else {
Write-Host "Launch Options: Does not contain '$substringToCheck'" -f darkred
}
break
}
}
}
}
}
} else {
Write-host "Launch options: Not found, please verify that you have -gamestateintegration in your launch options." -f darkred
}
# Check stream_online status
if ($Online) {
Write-Host "Stream online: Yes." -f darkgreen
} else {
Write-Host "Stream online: Not online, dotabod only works when you are streaming." -f darkred
}
# Check OBS version/installation
$ObsVersion = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\OBS Studio' -Name 'DisplayVersion' -ErrorAction SilentlyContinue
$ObsColor = 'white' # Default color
switch -regex ($ObsVersion) {
'^30.0.0-rc1$' { # 30.0.0-rc1 doesn't work
$ObsColor = 'darkred'
$ObsMessage = 'please update to the latest stable release from https://obsproject.com/'
break
}
'^(29|3[0-9])\.\d\.\d-[a-zA-Z0-9]+$' { # >= v29 rc & beta
$ObsColor = 'darkyellow'
$ObsMessage = 'this is a RC/BETA version, might or might not work'
break
}
'^(29|3[0-9])\.\d\.\d$' { # >= 29 stable
$ObsColor = 'darkgreen'
$ObsMessage = 'looks good'
break
}
'^[0-2][0-9]?\.\d{1,2}\.\d?(-[a-zA-Z0-9]+)?$' { # <= 29 stable, rc & beta
$ObsColor = 'darkred'
$ObsMessage = 'this version is too old, please update to the latest stable release from https://obsproject.com/'
break
}
default {
$ObsColor = 'darkyellow'
$ObsMessage = "couldn't determine OBS version"
break
}
}
Write-Host "OBS version: $ObsVersion, $ObsMessage." -f $ObsColor
Write-Host "`n"
Write-Host "Still not working?" -f white
Write-Host "Copy (or screenshot) this window and get help in our discord: https://discord.dotabod.com" -f white
Write-Host ('=' * 110) -b darkgray -f black
Read-Host -Prompt "Press Enter to exit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment