This commit is contained in:
Lanta 2023-11-13 20:00:20 +01:00
parent 54c561ee10
commit 246ab2be65

View file

@ -1,4 +1,4 @@
Start-Transcript -Path '/var/log/dtch/report_new_matches.log' -Append Start-Transcript -Path '/var/log/dtch/report_new_matches.log' -Append
if ($PSScriptRoot.length -eq 0) { if ($PSScriptRoot.length -eq 0) {
$scriptroot = Get-Location $scriptroot = Get-Location
@ -73,19 +73,21 @@ foreach ($winid in $new_win_matches) {
if ($null -eq $winid) { continue } if ($null -eq $winid) { continue }
$winmatches = $player_matches.player_matches | Where-Object { $_.id -eq $winid } $winmatches = $player_matches.player_matches | Where-Object { $_.id -eq $winid }
$telemetry = (invoke-webrequest @($winmatches.telemetry_url)[0]).content | convertfrom-json | where-object { ($_._T -eq 'LOGPLAYERTAKEDAMAGE') -or ($_._T -eq 'LOGPLAYERKILLV2') } $telemetry = (invoke-webrequest @($winmatches.telemetry_url)[0]).content | convertfrom-json | where-object { ($_._T -eq 'LOGPLAYERTAKEDAMAGE') -or ($_._T -eq 'LOGPLAYERKILLV2') }
$winners = @(($winmatches | where-object {$_.stats.winPlace -eq 1}).stats.name) $winners = @(($winmatches | where-object { $_.stats.winPlace -eq 1 }).stats.name)
$2D_replay_url = @($winmatches.telemetry_url)[0] -replace 'https://telemetry-cdn.pubg.com/bluehole-pubg', 'https://chickendinner.gg' $2D_replay_url = @($winmatches.telemetry_url)[0] -replace 'https://telemetry-cdn.pubg.com/bluehole-pubg', 'https://chickendinner.gg'
$2D_replay_url = $2D_replay_url -replace '-telemetry.json', '' $2D_replay_url = $2D_replay_url -replace '-telemetry.json', ''
$2D_replay_url = $2D_replay_url + "?follow=$($winners[0])" $2D_replay_url = $2D_replay_url + "?follow=$($winners[0])"
$match_stats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/matches/$winid" -Method GET -Headers $headers $match_stats = Invoke-RestMethod -Uri "https://api.pubg.com/shards/steam/matches/$winid" -Method GET -Headers $headers
if($winmatches[0].matchType -eq 'custom'){ if ($winmatches[0].matchType -eq 'custom') {
$players_to_report = $match_stats.included.attributes.stats $players_to_report = $match_stats.included.attributes.stats
}else{ }
else {
$players_to_report = ($match_stats.included.attributes.stats | where-object { $_.winplace -eq 1 }) $players_to_report = ($match_stats.included.attributes.stats | where-object { $_.winplace -eq 1 })
} }
if ($new_win_matches.count -le 10) {
#fail safe
send-discord -content ":chicken: :chicken: **WINNER WINNER CHICKEN DINNER!!** :chicken: :chicken:" send-discord -content ":chicken: :chicken: **WINNER WINNER CHICKEN DINNER!!** :chicken: :chicken:"
send-discord -content ":partying_face::partying_face::partying_face: Gefeliciteerd $($winners -join ', ') :partying_face::partying_face::partying_face:" send-discord -content ":partying_face::partying_face::partying_face: Gefeliciteerd $($winners -join ', ') :partying_face::partying_face::partying_face:"
$match_settings = @" $match_settings = @"
@ -97,9 +99,12 @@ id $($winmatches[0].id)
`````` ``````
"@ "@
send-discord -content $match_settings send-discord -content $match_settings
}
else {
write-output "Something went wrong (more then 10 matches to report)"
}
foreach ($player in $players_to_report.name) { foreach ($player in $players_to_report.name) {
if($null -eq $player){continue} if ($null -eq $player) { continue }
write-output "creating table for player $player" write-output "creating table for player $player"
$win_stats += [PSCustomObject]@{ $win_stats += [PSCustomObject]@{
Name = $player Name = $player
@ -130,18 +135,21 @@ id $($winmatches[0].id)
} }
if ($new_win_matches.count -le 10) {
$content_winstats = '```' + ($win_stats | Format-Table | out-string) + '```' $content_winstats = '```' + ($win_stats | Format-Table | out-string) + '```'
send-discord -content $content_winstats send-discord -content $content_winstats
if($victims.count -ge 1){ if ($victims.count -ge 1) {
send-discord -content ":skull::skull: Helaas hebben we deze keer ook team killers :skull::skull: " send-discord -content ":skull::skull: Helaas hebben we deze keer ook team killers :skull::skull: "
$content_victims = '```' + ($victims | Format-Table | out-string) + '```' $content_victims = '```' + ($victims | Format-Table | out-string) + '```'
send-discord -content $content_victims send-discord -content $content_victims
} }
send-discord -content "[2D replay](<$2D_replay_url>)" send-discord -content "[2D replay](<$2D_replay_url>)"
}
else {
write-output "Something went wrong (more then 10 matches to report)"
}
$legenda = ' $legenda = '
``` ```
dmg_h = Schade aangericht aan echte spelers dmg_h = Schade aangericht aan echte spelers