From 94eeb39e507467c43eeb1166922344ead3434696 Mon Sep 17 00:00:00 2001 From: Thijs Stobbelaar Date: Mon, 13 Nov 2023 10:29:36 +0100 Subject: [PATCH 1/2] discord locks fix --- discord/report_new_matches.ps1 | 6 ++---- discord/report_to_discord.ps1 | 7 ++----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/discord/report_new_matches.ps1 b/discord/report_new_matches.ps1 index d0cf5d3..77a1641 100644 --- a/discord/report_new_matches.ps1 +++ b/discord/report_new_matches.ps1 @@ -1,13 +1,11 @@ -. .\..\includes\ps1\lockfile.ps1 - -new-lock - if ($PSScriptRoot.length -eq 0) { $scriptroot = Get-Location } else { $scriptroot = $PSScriptRoot } +. $scriptroot\..\includes\ps1\lockfile.ps1 +new-lock $fileContent = Get-Content -Path "$scriptroot/../config/config.php" -Raw diff --git a/discord/report_to_discord.ps1 b/discord/report_to_discord.ps1 index 2811502..4081a98 100644 --- a/discord/report_to_discord.ps1 +++ b/discord/report_to_discord.ps1 @@ -1,14 +1,11 @@ - -. .\..\includes\ps1\lockfile.ps1 - -new-lock - if ($PSScriptRoot.length -eq 0) { $scriptroot = Get-Location } else { $scriptroot = $PSScriptRoot } +. $scriptroot\..\includes\ps1\lockfile.ps1 +new-lock function IsValidEntry($entry) { return ($entry.KD_H -ne 'NaN' -and $entry.KD_ALL -ne 'NaN') -and ($entry.KD_H -ne 'Infinity' -and $entry.KD_ALL -ne 'Infinity') From f51baf15201ddef117bebab9856936ed07669c2a Mon Sep 17 00:00:00 2001 From: Thijs Stobbelaar Date: Mon, 13 Nov 2023 10:31:00 +0100 Subject: [PATCH 2/2] discord logging --- discord/report_new_matches.ps1 | 5 ++++- discord/report_to_discord.ps1 | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/discord/report_new_matches.ps1 b/discord/report_new_matches.ps1 index 77a1641..3f9294a 100644 --- a/discord/report_new_matches.ps1 +++ b/discord/report_new_matches.ps1 @@ -1,3 +1,5 @@ +Start-Transcript -Path '/var/log/dtch/report_new_matches.log' -Append + if ($PSScriptRoot.length -eq 0) { $scriptroot = Get-Location } @@ -167,4 +169,5 @@ $newJson = $player_matches | ConvertTo-Json -Depth 100 # Display the updated JSON $newJson | out-file "$scriptroot/../data/player_matches.json" -remove-lock \ No newline at end of file +remove-lock +Stop-Transcript \ No newline at end of file diff --git a/discord/report_to_discord.ps1 b/discord/report_to_discord.ps1 index 4081a98..5369ffd 100644 --- a/discord/report_to_discord.ps1 +++ b/discord/report_to_discord.ps1 @@ -1,3 +1,5 @@ +Start-Transcript -Path '/var/log/report_new_matches.log' -Append + if ($PSScriptRoot.length -eq 0) { $scriptroot = Get-Location } @@ -96,4 +98,5 @@ $payload = [PSCustomObject]@{ } Invoke-RestMethod -Uri $webhookurl -Method Post -Body ($payload | ConvertTo-Json) -ContentType 'Application/Json' -remove-lock \ No newline at end of file +remove-lock +Stop-Transcript \ No newline at end of file