diff --git a/app/Console/Commands/AutoNerdStat.php b/app/Console/Commands/AutoNerdStat.php index 68644a3c9f..8e41ea3d6e 100644 --- a/app/Console/Commands/AutoNerdStat.php +++ b/app/Console/Commands/AutoNerdStat.php @@ -20,7 +20,6 @@ use App\Models\Warning; use App\Repositories\ChatRepository; use Illuminate\Console\Command; -use Illuminate\Support\Carbon; use Exception; /** @@ -58,84 +57,40 @@ public function __construct(private readonly ChatRepository $chatRepository) public function handle(): void { if (config('chat.nerd_bot')) { - // Site Birthday - $bday = config('other.birthdate'); - - // Logins Count Last 24hours - $logins = User::whereNotNull('last_login')->where('last_login', '>', Carbon::now()->subDay())->count(); - - // Torrents Uploaded Count Last 24hours - $uploads = Torrent::where('created_at', '>', Carbon::now()->subDay())->count(); - - // New Users Count Last 24hours - $users = User::where('created_at', '>', Carbon::now()->subDay())->count(); - - // Top Banker - $banker = User::latest('seedbonus')->first(); - - // Most Snatched Torrent - $snatched = Torrent::latest('times_completed')->first(); - - // Most Seeded Torrent - $seeded = Torrent::latest('seeders')->first(); - - // Most Leeched Torrent - $leeched = Torrent::latest('leechers')->first(); - - // 25% FL Torrents - $fl25 = Torrent::where('free', '=', 25)->count(); - - // 50% FL Torrents - $fl50 = Torrent::where('free', '=', 50)->count(); - - // 75% FL Torrents - $fl75 = Torrent::where('free', '=', 75)->count(); - - // 100% FL Torrents - $fl100 = Torrent::where('free', '=', 100)->count(); - - // DU Torrents - $du = Torrent::where('doubleup', '=', 1)->count(); - - // Peers Count - $peers = Peer::where('active', '=', 1)->count(); - - // New User Bans Count Last 24hours - $bans = Ban::whereNull('unban_reason')->whereNull('removed_at')->where('created_at', '>', Carbon::now()->subDay())->count(); - - // Hit and Run Warning Issued In Last 24hours - $warnings = Warning::where('created_at', '>', Carbon::now()->subDay())->count(); - - // URL Helpers - $bankerUrl = href_profile($banker); - $seededUrl = href_torrent($seeded); - $leechedUrl = href_torrent($leeched); - $snatchedUrl = href_torrent($snatched); - - // Select A Random Nerd Stat - $statArray = [ - sprintf('In The Last 24 Hours [color=#93c47d][b]%s[/b][/color] Unique Users Have Logged Into ', $logins).config('other.title').'!', - sprintf('In The Last 24 Hours [color=#93c47d][b]%s[/b][/color] Torrents Have Been Uploaded To ', $uploads).config('other.title').'!', - sprintf('In The Last 24 Hours [color=#93c47d][b]%s[/b][/color] Users Have Registered To ', $users).config('other.title').'!', - sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] 25%% Freeleech Torrents On ', $fl25).config('other.title').'!', - sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] 50%% Freeleech Torrents On ', $fl50).config('other.title').'!', - sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] 75%% Freeleech Torrents On ', $fl75).config('other.title').'!', - sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] 100%% Freeleech Torrents On ', $fl100).config('other.title').'!', - sprintf('There Are Currently [color=#93c47d][b]%s[/b][/color] Double Upload Torrents On ', $du).config('other.title').'!', - sprintf('Currently [url=%s]%s[/url] Is The Best Seeded Torrent On ', $seededUrl, $seeded->name).config('other.title').'!', - sprintf('Currently [url=%s]%s[/url] Is The Most Leeched Torrent On ', $leechedUrl, $leeched->name).config('other.title').'!', - sprintf('Currently [url=%s]%s[/url] Is The Most Snatched Torrent On ', $snatchedUrl, $snatched->name).config('other.title').'!', - sprintf('Currently [url=%s]%s[/url] Is The Top BON Holder On ', $bankerUrl, $banker->username).config('other.title').'!', - sprintf('Currently There Are [color=#93c47d][b]%s[/b][/color] Peers On ', $peers).config('other.title').'!', - sprintf('In The Last 24 Hours [color=#dd7e6b][b]%s[/b][/color] Users Have Been Banned From ', $bans).config('other.title').'!', - sprintf('In The Last 24 Hours [color=#dd7e6b][b]%s[/b][/color] Hit and Run Warnings Have Been Issued On ', $warnings).config('other.title').'!', - config('other.title').sprintf(' Birthday Is [b]%s[/b]!', $bday), - config('other.title').' Is King!', - ]; - $selected = random_int(0, \count($statArray) - 1); + $stats = collect([ + 'birthday', + 'logins', + 'uploads', + 'users', + 'fl25', + 'fl50', + 'fl75', + 'fl100', + 'du', + 'peers', + 'bans', + 'warnings', + 'king', + ])->random(); + + $message = match ($stats) { + 'birthday' => config('other.title').' Birthday Is [b]'.config('other.birthdate').'[/b]!', + 'logins' => 'In The Last 24 Hours [color=#93c47d][b]'.User::whereNotNull('last_login')->where('last_login', '>', now()->subDay())->count().'[/b][/color] Unique Users Have Logged Into '.config('other.title').'!', + 'uploads' => 'In The Last 24 Hours [color=#93c47d][b]'.Torrent::where('created_at', '>', now()->subDay())->count().'[/b][/color] Torrents Have Been Uploaded To '.config('other.title').'!', + 'users' => 'In The Last 24 Hours [color=#93c47d][b]'.User::where('created_at', '>', now()->subDay())->count().'[/b][/color] Users Have Registered To '.config('other.title').'!', + 'fl25' => 'There Are Currently [color=#93c47d][b]'.Torrent::where('free', '=', 25)->count().'[/b][/color] 25% Freeleech Torrents On '.config('other.title').'!', + 'fl50' => 'There Are Currently [color=#93c47d][b]'.Torrent::where('free', '=', 50)->count().'[/b][/color] 50% Freeleech Torrents On '.config('other.title').'!', + 'fl75' => 'There Are Currently [color=#93c47d][b]'.Torrent::where('free', '=', 75)->count().'[/b][/color] 75% Freeleech Torrents On '.config('other.title').'!', + 'fl100' => 'There Are Currently [color=#93c47d][b]'.Torrent::where('free', '=', 100)->count().'[/b][/color] 100% Freeleech Torrents On '.config('other.title').'!', + 'du' => 'There Are Currently [color=#93c47d][b]'.Torrent::where('doubleup', '=', 1)->count().'[/b][/color] Double Upload Torrents On '.config('other.title').'!', + 'peers' => 'Currently There Are [color=#93c47d][b]'.Peer::where('active', '=', 1)->count().'[/b][/color] Peers On '.config('other.title').'!', + 'bans' => 'In The Last 24 Hours [color=#dd7e6b][b]'.Ban::whereNull('unban_reason')->whereNull('removed_at')->where('created_at', '>', now()->subDay())->count().'[/b][/color] Users Have Been Banned From '.config('other.title').'!', + 'warnings' => 'In The Last 24 Hours [color=#dd7e6b][b]'.Warning::where('created_at', '>', now()->subDay())->count().'[/b][/color] Hit and Run Warnings Have Been Issued On '.config('other.title').'!', + 'king' => config('other.title').' Is King!', + }; // Auto Shout Nerd Stat - $this->chatRepository->systemMessage($statArray[$selected], 2); + $this->chatRepository->systemMessage($message); } $this->comment('Automated Nerd Stat Command Complete');