$host.UI.RawUI.WindowTitle = "CMD Chat" $baseUrl = "https://vtgeddtsaulabwbsreae.supabase.co/functions/v1/chat" $sessionId = "" $userId = "" $username = "" $pfpIndex = 1 $nameColor = 1 $wallet = "" $lastMessageId = "" $inChat = $false $loggedIn = $false $colorMap = @{ 1 = "Cyan" 2 = "Green" 3 = "Yellow" 4 = "Magenta" 5 = "Red" 6 = "Blue" 7 = "White" 8 = "DarkCyan" 9 = "DarkGreen" 10 = "DarkYellow" 11 = "DarkMagenta" 12 = "DarkRed" } function Get-ColorName { param($index) return $colorMap[$index] } function Show-Banner { Clear-Host Write-Host "" Write-Host " ██████╗███╗ ███╗██████╗ " -ForegroundColor White Write-Host " ██╔════╝████╗ ████║██╔══██╗" -ForegroundColor White Write-Host " ██║ ██╔████╔██║██║ ██║" -ForegroundColor White Write-Host " ██║ ██║╚██╔╝██║██║ ██║" -ForegroundColor White Write-Host " ╚██████╗██║ ╚═╝ ██║██████╔╝" -ForegroundColor White Write-Host " ╚═════╝╚═╝ ╚═╝╚═════╝ " -ForegroundColor White Write-Host "" Write-Host " X is down, so CMD is the next best option." -ForegroundColor DarkGray Write-Host " Chat to others in CMD terminal." -ForegroundColor DarkGray Write-Host "" Write-Host " CA > " -NoNewline -ForegroundColor Gray Write-Host "F6z68sfxwMMSnZKHDUqLXd5nBncxiATgAzejh6Bipump" -ForegroundColor Cyan Write-Host "" } function Show-AuthMenu { Write-Host "" Write-Host " ═══════════════════════════════════" -ForegroundColor White Write-Host " WELCOME TO CMD" -ForegroundColor Cyan Write-Host " ═══════════════════════════════════" -ForegroundColor White Write-Host "" Write-Host " [1] Login - I have an account" -ForegroundColor Gray Write-Host " [2] Register - Create new account" -ForegroundColor Gray Write-Host "" } function Show-Help { Write-Host "" Write-Host " AVAILABLE COMMANDS:" -ForegroundColor White Write-Host " /join - enter the chatroom" -ForegroundColor Gray Write-Host " /help - show this help" -ForegroundColor Gray Write-Host " /refresh - fetch new messages" -ForegroundColor Gray Write-Host " /setname - set your display name" -ForegroundColor Gray Write-Host " /setpfp <1-12> - set your ascii profile pic" -ForegroundColor Gray Write-Host " /mypfp - preview your current pfp" -ForegroundColor Gray Write-Host " /pfps - show all available pfps" -ForegroundColor Gray Write-Host " /setcolor <1-12> - set your name color" -ForegroundColor Gray Write-Host " /mycolor - preview your current color" -ForegroundColor Gray Write-Host " /colors - show all available colors" -ForegroundColor Gray Write-Host " /setwallet - set your solana wallet" -ForegroundColor Gray Write-Host " /profile - view your profile" -ForegroundColor Gray Write-Host " /view - view someone's profile" -ForegroundColor Gray Write-Host " /top - show leaderboard" -ForegroundColor Gray Write-Host " /ca - show contract address" -ForegroundColor Gray Write-Host " /online - show online users" -ForegroundColor Gray Write-Host " /logout - logout and exit" -ForegroundColor Gray Write-Host " /exit - leave the chatroom" -ForegroundColor Gray Write-Host "" } $pfpList = @( @(" +--+ ", " |''| ", " +--+ "), @(" +--+ ", " |^^| ", " +--+ "), @(" +--+ ", " |..| ", " +--+ "), @(" +--+ ", " |><| ", " +--+ "), @(" +--+ ", " |@@| ", " +--+ "), @(" +--+ ", " |**| ", " +--+ "), @(" +--+ ", " |~~| ", " +--+ "), @(" +--+ ", " |==| ", " +--+ "), @(" +--+ ", " |::| ", " +--+ "), @(" +--+ ", " |<>| ", " +--+ "), @(" +--+ ", " |##| ", " +--+ "), @(" +--+ ", " |++| ", " +--+ ") ) function Show-Pfp { param($index) $pfp = $pfpList[$index - 1] foreach ($line in $pfp) { Write-Host $line -ForegroundColor Cyan } } function Show-AllPfps { Write-Host "" Write-Host " AVAILABLE PROFILE PICS:" -ForegroundColor White Write-Host "" for ($i = 1; $i -le 12; $i++) { Write-Host " [$i]" -ForegroundColor Yellow Show-Pfp -index $i Write-Host "" } } function Show-PfpGrid { Write-Host "" Write-Host " ╔══════════════════════════════════════════════════════════════════╗" -ForegroundColor White Write-Host " ║ CHOOSE YOUR PROFILE PIC ║" -ForegroundColor White Write-Host " ╚══════════════════════════════════════════════════════════════════╝" -ForegroundColor White Write-Host "" # Row 1: PFPs 1-4 Write-Host " [1] [2] [3] [4] " -ForegroundColor Yellow Write-Host " +--+ +--+ +--+ +--+ " -ForegroundColor Cyan Write-Host " |''| |^^| |..| |><| " -ForegroundColor Cyan Write-Host " +--+ +--+ +--+ +--+ " -ForegroundColor Cyan Write-Host "" # Row 2: PFPs 5-8 Write-Host " [5] [6] [7] [8] " -ForegroundColor Yellow Write-Host " +--+ +--+ +--+ +--+ " -ForegroundColor Cyan Write-Host " |@@| |**| |~~| |==| " -ForegroundColor Cyan Write-Host " +--+ +--+ +--+ +--+ " -ForegroundColor Cyan Write-Host "" # Row 3: PFPs 9-12 Write-Host " [9] [10] [11] [12] " -ForegroundColor Yellow Write-Host " +--+ +--+ +--+ +--+ " -ForegroundColor Cyan Write-Host " |::| |<>| |##| |++| " -ForegroundColor Cyan Write-Host " +--+ +--+ +--+ +--+ " -ForegroundColor Cyan Write-Host "" } function Show-ColorGrid { param($displayName) Write-Host "" Write-Host " ╔══════════════════════════════════════════════════════════════════╗" -ForegroundColor White Write-Host " ║ CHOOSE YOUR NAME COLOR ║" -ForegroundColor White Write-Host " ╚══════════════════════════════════════════════════════════════════╝" -ForegroundColor White Write-Host "" Write-Host " Preview how your name will appear in chat:" -ForegroundColor Gray Write-Host "" for ($i = 1; $i -le 12; $i++) { $color = Get-ColorName -index $i Write-Host " [$i] " -NoNewline -ForegroundColor Yellow Write-Host "$displayName" -ForegroundColor $color } Write-Host "" } function Run-Onboarding { Write-Host "" Write-Host " ╔══════════════════════════════════════════════════════════════════╗" -ForegroundColor Green Write-Host " ║ WELCOME TO CMD! ║" -ForegroundColor Green Write-Host " ║ Let's set up your profile... ║" -ForegroundColor Green Write-Host " ╚══════════════════════════════════════════════════════════════════╝" -ForegroundColor Green # Step 1: Choose PFP Show-PfpGrid while ($true) { Write-Host " Enter PFP number (1-12): " -NoNewline -ForegroundColor Cyan $pfpChoice = Read-Host if ($pfpChoice -match '^([1-9]|1[0-2])$') { $script:pfpIndex = [int]$pfpChoice Write-Host "" Write-Host " Great choice! Your PFP:" -ForegroundColor Green Show-Pfp -index $script:pfpIndex break } else { Write-Host " Please enter a number between 1 and 12" -ForegroundColor Red } } # Step 2: Choose Color Show-ColorGrid -displayName $username while ($true) { Write-Host " Enter color number (1-12): " -NoNewline -ForegroundColor Cyan $colorChoice = Read-Host if ($colorChoice -match '^([1-9]|1[0-2])$') { $script:nameColor = [int]$colorChoice $color = Get-ColorName -index $script:nameColor Write-Host "" Write-Host " Perfect! Your name will appear as: " -NoNewline -ForegroundColor Green Write-Host "$username" -ForegroundColor $color break } else { Write-Host " Please enter a number between 1 and 12" -ForegroundColor Red } } # Save choices to server Update-Profile -field "pfpIndex" -value $script:pfpIndex | Out-Null Update-Profile -field "nameColor" -value $script:nameColor | Out-Null Write-Host "" Write-Host " ╔══════════════════════════════════════════════════════════════════╗" -ForegroundColor Green Write-Host " ║ PROFILE SETUP COMPLETE! ║" -ForegroundColor Green Write-Host " ╚══════════════════════════════════════════════════════════════════╝" -ForegroundColor Green Write-Host "" } function Show-AllColors { Write-Host "" Write-Host " AVAILABLE NAME COLORS:" -ForegroundColor White Write-Host "" for ($i = 1; $i -le 12; $i++) { $color = Get-ColorName -index $i Write-Host " [$i] " -NoNewline -ForegroundColor Yellow Write-Host "Example Name" -ForegroundColor $color } Write-Host "" } function Send-Request { param($action, $data) try { $body = @{ action = $action sessionId = $sessionId userId = $userId data = $data } | ConvertTo-Json -Compress $response = Invoke-RestMethod -Uri $baseUrl -Method Post -Body $body -ContentType "application/json" -TimeoutSec 10 return $response } catch { return $null } } function Do-Login { param($user, $pass) $result = Send-Request -action "login" -data @{ username = $user; password = $pass } return $result } function Do-Register { param($user, $pass) $result = Send-Request -action "signup" -data @{ username = $user; password = $pass } return $result } function Do-GuestLogin { $result = Send-Request -action "guest" -data @{} return $result } function Register-Session { $result = Send-Request -action "register" -data @{ username = $username; pfpIndex = $pfpIndex; nameColor = $nameColor } return $result } function Get-Messages { $result = Send-Request -action "messages" -data @{ after = $lastMessageId } return $result } function Send-Message { param($content) $result = Send-Request -action "send" -data @{ content = $content } return $result } function Update-Profile { param($field, $value) $result = Send-Request -action "update" -data @{ field = $field; value = $value } return $result } function Get-Online { $result = Send-Request -action "online" -data @{} return $result } function Set-Offline { Send-Request -action "offline" -data @{} | Out-Null } function Get-Profile { param($targetUser) $result = Send-Request -action "profile" -data @{ username = $targetUser } return $result } function Get-Leaderboard { $result = Send-Request -action "leaderboard" -data @{} return $result } function Show-Leaderboard { param($users) Write-Host "" Write-Host " ╔══════════════════════════════════════════════╗" -ForegroundColor White Write-Host " ║ TOP 10 LEADERBOARD ║" -ForegroundColor White Write-Host " ╠══════════════════════════════════════════════╣" -ForegroundColor White $rank = 1 foreach ($u in $users) { $level = Get-Level -msgCount $u.message_count $colorName = if ($u.name_color) { Get-ColorName -index $u.name_color } else { "Cyan" } $pfpChar = Get-PfpChar -index $u.pfp_index $rankStr = "#$rank" $msgStr = "$($u.message_count) msgs" Write-Host " ║ " -NoNewline -ForegroundColor White Write-Host "$rankStr " -NoNewline -ForegroundColor Yellow Write-Host "[" -NoNewline -ForegroundColor DarkCyan Write-Host "$pfpChar" -NoNewline -ForegroundColor Cyan Write-Host "] " -NoNewline -ForegroundColor DarkCyan Write-Host "$($u.username)" -NoNewline -ForegroundColor $colorName $namePad = 20 - $u.username.Length Write-Host (" " * [Math]::Max(1, $namePad)) -NoNewline Write-Host "$level" -NoNewline -ForegroundColor Magenta $levelPad = 10 - $level.Length Write-Host (" " * [Math]::Max(1, $levelPad)) -NoNewline Write-Host "$msgStr" -ForegroundColor Gray $rank++ } Write-Host " ╚══════════════════════════════════════════════╝" -ForegroundColor White Write-Host "" } function Get-Level { param($msgCount) if ($msgCount -lt 10) { return "Newbie" } elseif ($msgCount -lt 50) { return "Regular" } elseif ($msgCount -lt 100) { return "Active" } elseif ($msgCount -lt 250) { return "Veteran" } elseif ($msgCount -lt 500) { return "Elite" } else { return "Legend" } } function Show-Profile { param($profile) $level = Get-Level -msgCount $profile.message_count $pfpChar = Get-PfpChar -index $profile.pfp_index $colorName = Get-ColorName -index $profile.name_color Write-Host "" Write-Host " ╔══════════════════════════════════╗" -ForegroundColor White Write-Host " ║ USER PROFILE ║" -ForegroundColor White Write-Host " ╠══════════════════════════════════╣" -ForegroundColor White Write-Host " ║ " -NoNewline -ForegroundColor White Write-Host "$($profile.username)" -NoNewline -ForegroundColor $colorName $padding = 32 - $profile.username.Length Write-Host (" " * $padding) -NoNewline Write-Host "║" -ForegroundColor White Write-Host " ╠══════════════════════════════════╣" -ForegroundColor White Write-Host " ║ PFP: [" -NoNewline -ForegroundColor White Write-Host "$pfpChar" -NoNewline -ForegroundColor Cyan Write-Host "]" -NoNewline -ForegroundColor White Write-Host " ║" -ForegroundColor White Write-Host " ║ Level: " -NoNewline -ForegroundColor White Write-Host "$level" -NoNewline -ForegroundColor Yellow $levelPad = 25 - $level.Length Write-Host (" " * $levelPad) -NoNewline Write-Host "║" -ForegroundColor White Write-Host " ║ Messages: " -NoNewline -ForegroundColor White $msgStr = "$($profile.message_count)" Write-Host "$msgStr" -NoNewline -ForegroundColor Cyan $msgPad = 22 - $msgStr.Length Write-Host (" " * $msgPad) -NoNewline Write-Host "║" -ForegroundColor White if ($profile.wallet_address) { $walletShort = $profile.wallet_address.Substring(0, [Math]::Min(20, $profile.wallet_address.Length)) + "..." Write-Host " ║ Wallet: " -NoNewline -ForegroundColor White Write-Host "$walletShort" -NoNewline -ForegroundColor Green $walletPad = 24 - $walletShort.Length Write-Host (" " * $walletPad) -NoNewline Write-Host "║" -ForegroundColor White } Write-Host " ╚══════════════════════════════════╝" -ForegroundColor White Write-Host "" } function Get-PfpChar { param($index) switch ($index) { 1 { return "''" } 2 { return "^^" } 3 { return ".." } 4 { return "><" } 5 { return "@@" } 6 { return "**" } 7 { return "~~" } 8 { return "==" } 9 { return "::" } 10 { return "<>" } 11 { return "##" } 12 { return "++" } default { return "''" } } } function Get-MsgColor { param($index) return Get-ColorName -index $index } function Format-Message { param($msg) $time = [DateTime]::Parse($msg.created_at).ToString("HH:mm") $name = $msg.username $pfpChar = Get-PfpChar -index $msg.pfp_index $msgColor = if ($msg.name_color) { Get-MsgColor -index $msg.name_color } else { "Cyan" } Write-Host "[$time] " -NoNewline -ForegroundColor DarkGray Write-Host "[" -NoNewline -ForegroundColor DarkCyan Write-Host "$pfpChar" -NoNewline -ForegroundColor Cyan Write-Host "] " -NoNewline -ForegroundColor DarkCyan Write-Host "$name" -NoNewline -ForegroundColor $msgColor Write-Host ": $($msg.content)" -ForegroundColor White } function Poll-Messages { $messages = Get-Messages if ($messages -and $messages.messages) { foreach ($msg in $messages.messages) { Format-Message -msg $msg $script:lastMessageId = $msg.id } } } Show-Banner Show-AuthMenu # Auth loop while (-not $loggedIn) { Write-Host " Choice: " -NoNewline -ForegroundColor Green $choice = Read-Host switch ($choice) { "1" { Write-Host "" Write-Host " Username: " -NoNewline -ForegroundColor Cyan $loginUser = Read-Host Write-Host " Password: " -NoNewline -ForegroundColor Cyan $loginPass = Read-Host -AsSecureString $loginPassPlain = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($loginPass)) Write-Host " Logging in..." -ForegroundColor Gray $result = Do-Login -user $loginUser -pass $loginPassPlain if ($result -and $result.success) { $loggedIn = $true $sessionId = $result.sessionId $userId = $result.userId $username = $result.username $pfpIndex = if ($result.pfpIndex) { $result.pfpIndex } else { 1 } $nameColor = if ($result.nameColor) { $result.nameColor } else { 1 } $wallet = if ($result.wallet) { $result.wallet } else { "" } Write-Host "" Write-Host " Welcome back, $username!" -ForegroundColor Green Write-Host " Your settings have been restored." -ForegroundColor Gray } else { $errMsg = if ($result.error) { $result.error } else { "Invalid username or password" } Write-Host " $errMsg" -ForegroundColor Red } } "2" { Write-Host "" Write-Host " Choose a username: " -NoNewline -ForegroundColor Cyan $regUser = Read-Host Write-Host " Choose a password: " -NoNewline -ForegroundColor Cyan $regPass = Read-Host -AsSecureString $regPassPlain = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($regPass)) Write-Host " Confirm password: " -NoNewline -ForegroundColor Cyan $regPass2 = Read-Host -AsSecureString $regPass2Plain = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($regPass2)) if ($regPassPlain -ne $regPass2Plain) { Write-Host " Passwords don't match!" -ForegroundColor Red continue } if ($regUser.Length -lt 3 -or $regUser.Length -gt 20) { Write-Host " Username must be 3-20 characters" -ForegroundColor Red continue } if ($regPassPlain.Length -lt 4) { Write-Host " Password must be at least 4 characters" -ForegroundColor Red continue } Write-Host " Creating account..." -ForegroundColor Gray $result = Do-Register -user $regUser -pass $regPassPlain if ($result -and $result.success) { $loggedIn = $true $sessionId = $result.sessionId $userId = $result.userId $username = $result.username $pfpIndex = 1 $nameColor = 1 Write-Host "" Write-Host " Account created! Welcome, $username!" -ForegroundColor Green # Run onboarding tutorial Run-Onboarding } else { $errMsg = if ($result.error) { $result.error } else { "Registration failed" } Write-Host " $errMsg" -ForegroundColor Red } } default { Write-Host " Please enter 1 or 2" -ForegroundColor Yellow } } } Write-Host "" Write-Host " Type /help for commands" -ForegroundColor DarkGray Write-Host " Type /join to enter the chatroom" -ForegroundColor DarkGray Write-Host "" $inputBuffer = "" $lastPollTime = [DateTime]::Now while ($true) { # Non-blocking input check with live polling if ($inChat) { # Check if it's time to poll (every 2 seconds) $now = [DateTime]::Now if (($now - $lastPollTime).TotalSeconds -ge 2) { Poll-Messages $lastPollTime = $now } # Check for input with short timeout if ([Console]::KeyAvailable) { $key = [Console]::ReadKey($true) if ($key.Key -eq 'Enter') { Write-Host "" $input = $inputBuffer $inputBuffer = "" } elseif ($key.Key -eq 'Backspace') { if ($inputBuffer.Length -gt 0) { $inputBuffer = $inputBuffer.Substring(0, $inputBuffer.Length - 1) [Console]::Write([char]8 + " " + [char]8) } continue } else { $inputBuffer += $key.KeyChar Write-Host $key.KeyChar -NoNewline continue } } else { Start-Sleep -Milliseconds 100 continue } } else { # Not in chat - use regular blocking input Write-Host "> " -NoNewline -ForegroundColor Green $input = Read-Host } if ($input -eq "/exit" -or $input -eq "/logout") { if ($inChat) { Set-Offline } Write-Host " Goodbye, $username!" -ForegroundColor Gray break } elseif ($input -eq "/help") { Show-Help } elseif ($input -eq "/ca") { Write-Host "" Write-Host " Contract Address:" -ForegroundColor White Write-Host " F6z68sfxwMMSnZKHDUqLXd5nBncxiATgAzejh6Bipump" -ForegroundColor Cyan Write-Host "" if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/refresh" -or $input -eq "/r") { if ($inChat) { Poll-Messages Write-Host "> " -NoNewline -ForegroundColor Green } else { Write-Host " Type /join to enter the chatroom first" -ForegroundColor Yellow } } elseif ($input -eq "/join") { Write-Host " Connecting..." -ForegroundColor Gray $result = Register-Session if ($result -and $result.success) { $inChat = $true Write-Host " Connected! You are now in the chatroom." -ForegroundColor Green Write-Host " Loading message history..." -ForegroundColor Gray Poll-Messages Write-Host "" $lastPollTime = [DateTime]::Now Write-Host "> " -NoNewline -ForegroundColor Green } else { Write-Host " Failed to connect. Try again." -ForegroundColor Red } } elseif ($input -match "^/setname (.+)$") { $newName = $matches[1].Trim() if ($newName.Length -gt 20) { Write-Host " Username too long (max 20 chars)" -ForegroundColor Red } elseif ($newName.Length -lt 3) { Write-Host " Username too short (min 3 chars)" -ForegroundColor Red } else { $result = Update-Profile -field "username" -value $newName if ($result -and $result.success) { $username = $newName Write-Host " Username set to: $username" -ForegroundColor Green } else { $errMsg = if ($result.error) { $result.error } else { "Username already taken" } Write-Host " $errMsg" -ForegroundColor Red } } if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -match "^/setpfp ([1-9]|1[0-2])$") { $pfpIndex = [int]$matches[1] if ($inChat) { Update-Profile -field "pfpIndex" -value $pfpIndex } Write-Host " Profile pic set to #$pfpIndex" -ForegroundColor Green Show-Pfp -index $pfpIndex if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/mypfp") { Write-Host "" Write-Host " YOUR PROFILE PIC (#$pfpIndex):" -ForegroundColor White Show-Pfp -index $pfpIndex Write-Host "" if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/pfps") { Show-AllPfps if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -match "^/setcolor ([1-9]|1[0-2])$") { $nameColor = [int]$matches[1] if ($inChat) { Update-Profile -field "nameColor" -value $nameColor } $colorName = Get-ColorName -index $nameColor Write-Host " Name color set to #$nameColor" -ForegroundColor Green Write-Host " Preview: " -NoNewline -ForegroundColor Gray Write-Host "$username" -ForegroundColor $colorName if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/mycolor") { Write-Host "" $colorName = Get-ColorName -index $nameColor Write-Host " YOUR NAME COLOR (#$nameColor):" -ForegroundColor White Write-Host " $username" -ForegroundColor $colorName Write-Host "" if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/colors") { Show-AllColors if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -match "^/setwallet (.+)$") { $wallet = $matches[1].Trim() if ($inChat) { Update-Profile -field "wallet" -value $wallet } Write-Host " Wallet set to: $wallet" -ForegroundColor Green if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/profile") { $result = Get-Profile -targetUser $username if ($result -and $result.success) { Show-Profile -profile $result.profile } else { Write-Host " Could not load profile" -ForegroundColor Red } if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -match "^/view (.+)$") { $targetUser = $matches[1].Trim() $result = Get-Profile -targetUser $targetUser if ($result -and $result.success) { Show-Profile -profile $result.profile } else { Write-Host " User not found: $targetUser" -ForegroundColor Red } if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/online") { $result = Get-Online if ($result -and $result.users) { Write-Host "" Write-Host " ONLINE USERS:" -ForegroundColor White foreach ($u in $result.users) { $userColor = if ($u.name_color) { Get-ColorName -index $u.name_color } else { "Cyan" } Write-Host " - " -NoNewline -ForegroundColor Gray Write-Host "$($u.username)" -ForegroundColor $userColor } Write-Host "" } else { Write-Host " No users online" -ForegroundColor Gray } if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input -eq "/top") { $result = Get-Leaderboard if ($result -and $result.users) { Show-Leaderboard -users $result.users } else { Write-Host " Could not load leaderboard" -ForegroundColor Red } if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input.StartsWith("/")) { Write-Host " Unknown command. Type /help" -ForegroundColor Red if ($inChat) { Write-Host "> " -NoNewline -ForegroundColor Green } } elseif ($input.Trim() -ne "" -and $inChat) { # Move cursor up to overwrite prompt line [Console]::Write("") $result = Send-Message -content $input if ($result -and $result.success -and $result.message) { # Display sent message with server timestamp $msg = $result.message $time = if ($msg.created_at) { ([DateTime]$msg.created_at).ToString("HH:mm") } else { (Get-Date).ToString("HH:mm") } $pfpChar = Get-PfpChar -index $pfpIndex $colorName = Get-ColorName -index $nameColor Write-Host "[$time] " -NoNewline -ForegroundColor Gray Write-Host "[" -NoNewline -ForegroundColor DarkCyan Write-Host "$pfpChar" -NoNewline -ForegroundColor Cyan Write-Host "] " -NoNewline -ForegroundColor DarkCyan Write-Host "$username" -NoNewline -ForegroundColor $colorName Write-Host ": $input" -ForegroundColor White if ($msg.id) { $script:lastMessageId = $msg.id } # Also fetch new messages from others Start-Sleep -Milliseconds 200 Poll-Messages } elseif (-not $result -or -not $result.success) { Write-Host " Failed to send message" -ForegroundColor Red } Write-Host "> " -NoNewline -ForegroundColor Green } elseif ($input.Trim() -ne "" -and -not $inChat) { Write-Host " Type /join to enter the chatroom first" -ForegroundColor Yellow } }