From bddaf411295fb4308b991c65e24603ed7c7456c4 Mon Sep 17 00:00:00 2001 From: Emad Adel <19177373+emadadel4@users.noreply.github.com> Date: Thu, 21 Nov 2024 08:52:15 +0200 Subject: [PATCH] Update itt.ps1 --- itt.ps1 | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/itt.ps1 b/itt.ps1 index 0cb5c2e3..02229cc7 100644 --- a/itt.ps1 +++ b/itt.ps1 @@ -7226,41 +7226,36 @@ function Startup { param ( [string]$FirebaseUrl = "https://ittools-7d9fe-default-rtdb.firebaseio.com/Users" ) - + try { # Get PC and user information $Key = "$env:COMPUTERNAME $env:USERNAME" $firebaseUrlWithKey = "$FirebaseUrl/$Key.json" $firebaseUrlRoot = "$FirebaseUrl.json" $win = [System.Environment]::OSVersion - - - - # Display information - - + # Fetch existing data for the key, if available $existingData = Invoke-RestMethod -Uri $firebaseUrlWithKey -Method Get -ErrorAction SilentlyContinue - $runs = if ($existingData) { - - $existingData.runs + 1 + # Determine run count and message + if ($existingData) { + $runs = $existingData.runs + 1 Telegram -Message "💻 '$env:USERNAME' has opened ITT again." - } - else - { - 1 - Telegram -Message "🎉A new device 👤'$env:USERNAME' is now running ITT!`n`💻 $Win" + } else { + $runs = 1 + Telegram -Message "🎉 A new device 👤 '$env:USERNAME' is now running ITT!" } - # Update Firebase with the new value + # Update Firebase with the new run count $updateData = @{ runs = $runs } | ConvertTo-Json -Depth 10 Invoke-RestMethod -Uri $firebaseUrlWithKey -Method Put -Body $updateData -Headers @{ "Content-Type" = "application/json" } -ErrorAction SilentlyContinue - - # Count the number of keys under the root + + # Count the number of keys under the root AFTER the update $response = Invoke-RestMethod -Uri $firebaseUrlRoot -Method Get -ErrorAction SilentlyContinue $totalKeys = ($response | Get-Member -MemberType NoteProperty | Measure-Object).Count - + + # Use the same totalKeys for both the Telegram message and Write-Host + Telegram -Message "🌍 Total users worldwide: $totalKeys" Write-Host "`nITT has been used on $totalKeys devices worldwide.`n" -ForegroundColor White # Force garbage collection to free memory @@ -7272,6 +7267,7 @@ function Startup { } } + function LOG { param ( $message,