These modules are meant to be used with my dotfiles.
They live in $Profile\profile.d
or ~/.config/zsh/.zshrc.d
of their respective shell.
Last active
November 15, 2024 16:24
-
-
Save hoang-himself/185642cedf1103c65e0e7c662fba3112 to your computer and use it in GitHub Desktop.
Local runcoms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Update-WoTAslain { | |
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')] | |
[CmdletBinding(SupportsShouldProcess)] | |
param( | |
[string]$Path = 'D:\Games\World_of_Tanks_ASIA', | |
[string]$Version = (Select-Xml -Path "$Path\version.xml" -XPath '/version.xml/version' ` | |
| ForEach-Object { $_.Node }).InnerXml.Split(' ')[1].Substring(2) | |
) | |
$ErrorActionPreference = 'Stop' | |
$scriptBlockList = @() | |
if ($PSCmdlet.ShouldProcess('Generate jobs to download mods')) { | |
$scriptBlockList += { | |
Start-Process -FilePath 'https://wotinspector.com/baactivate' | |
Start-Process -FilePath 'https://wgmods.net/46/' | |
} | |
} | |
if ($PSCmdlet.ShouldProcess('Execute jobs to download mods')) { | |
$scriptBlockList | ForEach-Object { Start-Job -ScriptBlock $_ } | |
Get-Job | Wait-Job; | |
} | |
} | |
function Update-WoTSpeak { | |
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', '')] | |
[CmdletBinding(SupportsShouldProcess)] | |
param( | |
[string]$Path = 'D:\Games\World_of_Tanks_ASIA', | |
[string]$Version = (Select-Xml -Path "$Path\version.xml" -XPath '/version.xml/version' ` | |
| ForEach-Object { $_.Node }).InnerXml.Split(' ')[1].Substring(2) | |
) | |
$ErrorActionPreference = 'Stop' | |
$scriptBlockList = @() | |
if ($PSCmdlet.ShouldProcess('Create temporary directory')) { | |
mktmp | |
} | |
if ($PSCmdlet.ShouldProcess('Generate jobs to download mods')) { | |
$scriptBlockList += { | |
Invoke-WebRequest -Uri 'https://down.wotspeak.org/zj_mod/TargetDirection.rar' ` | |
-OutFile 'TargetDirection.rar' | |
&"$env:ProgramFiles\7-zip\7z.exe" x '-oTargetDirection' 'TargetDirection.rar' | |
Copy-Item -Path 'TargetDirection' -Exclude @('*.url', '*.txt') ` | |
-Destination "_WoT\res_mods\$using:Version" -Recurse -Force | |
} | |
$scriptBlockList += { | |
Invoke-WebRequest -Uri 'https://down.wotspeak.org/mods_no_work/525-mod_atac.zip' ` | |
-OutFile 'ATAC.zip' | |
Expand-Archive -Path 'ATAC.zip' -DestinationPath 'ATAC' | |
$variant = Get-ChildItem -Path 'ATAC' | Select-String -Pattern '150' | |
Copy-Item -Path "$variant\*" -Exclude @('*.url', '*.txt') ` | |
-Destination "_WoT\res_mods\$using:Version" -Recurse -Force | |
} | |
$scriptBlockList += { | |
Invoke-WebRequest -Uri 'https://down.wotspeak.org/armor/wg/mod_MGM.zip' ` | |
-OutFile 'MinimapGunMarkers.zip' | |
Expand-Archive -Path 'MinimapGunMarkers.zip' -DestinationPath 'MinimapGunMarkers' | |
Copy-Item -Path 'MinimapGunMarkers\mods' -Exclude @('*.url', '*.txt') ` | |
-Destination '_WoT' -Recurse -Force | |
} | |
# 'lesta' for RU, 'wg' for others | |
@( | |
'WotspeakDestructionsBeholder', | |
'WotspeakRedBall' | |
) | ForEach-Object { | |
$scriptBlockList += [scriptblock]::Create(@" | |
Invoke-WebRequest -Uri "https://down.wotspeak.org/wotspeakmods/wg/$_.zip" `` | |
-OutFile "$_.zip" | |
Expand-Archive -Path "$_.zip" -DestinationPath "$_" | |
Copy-Item -Path "$_\mods" -Exclude @('*.url', '*.txt') `` | |
-Destination '_WoT' -Recurse -Force | |
"@) | |
} | |
} | |
if ($PSCmdlet.ShouldProcess('Execute jobs to download mods')) { | |
$scriptBlockList | ForEach-Object { Start-Job -ScriptBlock $_ } | |
Get-Job | Wait-Job; | |
} | |
if ($PSCmdlet.ShouldProcess("Copy mods from temporary directory to $Path")) { | |
Copy-Item -Path '_WoT\*' -Destination "$Path" -Recurse -Force | |
} | |
if ($PSCmdlet.ShouldProcess('Remove temporary directory')) { | |
rmtmp | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment