Merge pull request #215 from OpzekerIT/dev

Report losers
This commit is contained in:
Lanta 2025-04-15 11:59:24 +02:00 committed by GitHub
commit e95ee0614e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 46 additions and 3 deletions

View file

@ -36,13 +36,19 @@ $headers = @{
$fileContent = Get-Content -Path "$scriptroot/../discord/config.php" -Raw
# Use regex to match the apiKey value
if ($fileContent -match "\`$webhookurl\s*=\s*\'([^\']+)\'") {
if ($fileContent -match "\`$webhookurl\s*=\s*'([^']+)'") {
$webhookurl = $matches[1]
}
else {
} else {
Write-Output "No web url found"
}
# Use regex to match the losers webhook url
if ($fileContent -match "\`$webhookurl_losers\s*=\s*'([^']+)'") {
$webhookurl_losers = $matches[1]
} else {
Write-Output "No losers web url found"
}
function send-discord {
param (
$content
@ -56,6 +62,16 @@ function send-discord {
Invoke-RestMethod -Uri $webhookurl -Method Post -Body ($payload | ConvertTo-Json) -ContentType 'Application/Json'
}
function send-discord-losers {
param (
$content
)
$payload = [PSCustomObject]@{
content = $content
}
Invoke-RestMethod -Uri $webhookurl_losers -Method Post -Body ($payload | ConvertTo-Json) -ContentType 'Application/Json'
}
$map_map = @{
"Baltic_Main" = "Erangel"
"Chimera_Main" = "Paramo"
@ -81,7 +97,25 @@ Write-Output $player_matches
Write-Output $new_win_matches
$new_win_matches = $player_matches[-1].new_win_matches
# Gebruik nu de lijst van nieuwe verloren matches uit het JSON-bestand
$new_loss_matches = $player_matches[-1].new_loss_matches
# Post verloren matches naar #losers kanaal
foreach ($lossid in $new_loss_matches) {
$lossmatch = $player_matches.player_matches | Where-Object { $_.id -eq $lossid }
if ($null -eq $lossmatch) { continue }
if ($lossmatch[0].gameMode -eq 'tdm') { continue }
$losers = $lossmatch[0].stats.name
$map = $map_map[$lossmatch[0].mapName]
$place = $lossmatch[0].stats.winPlace
$replay_url = $lossmatch[0].telemetry_url -replace 'https://telemetry-cdn.pubg.com/bluehole-pubg', 'https://chickendinner.gg'
$replay_url = $replay_url -replace '-telemetry.json', ''
$replay_url = $replay_url + "?follow=$losers"
$msg = ":skull: **Verloren pot** :skull:`nTeam: $losers`nMap: $map`nPlaats: $place`n[2D replay]($replay_url)`nMeer details: https://dtch.online/matchinfo.php?matchid=$($lossmatch[0].id)"
send-discord-losers -content $msg
}
foreach ($winid in $new_win_matches) {
$win_stats = @()

View file

@ -87,6 +87,15 @@ if (test-path "$scriptroot/../data/player_matches.json") {
new_win_matches = $new_win_matches
}
# Nieuwe verloren matches bepalen
$new_loss_ids = ($player_matches.player_matches | Where-Object { $_.stats.winplace -ne 1 }).id
$old_loss_ids = ($old_player_data.player_matches | Where-Object { $_.stats.winplace -ne 1 }).id
$new_loss_matches = ((Compare-Object -ReferenceObject $old_loss_ids -DifferenceObject $new_loss_ids) | Where-Object { $_.SideIndicator -eq '=>' }).InputObject | Select-Object -Unique
$new_loss_matches = $old_player_data.new_loss_matches + $new_loss_matches | Select-Object -Unique
$player_matches += [PSCustomObject]@{
new_loss_matches = $new_loss_matches
}
}
$currentDateTime = Get-Date