X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FConsole%2FCommands%2FTwitchTopEmotes.php;fp=app%2FConsole%2FCommands%2FTwitchTopEmotes.php;h=81436d9ba013399379b659a4c6bb9f1faa02ab33;hb=ac6921da72ff4b0beab9e5f1308788a55aae3ad9;hp=0000000000000000000000000000000000000000;hpb=72253eedb80a978c5442621049cc0f28b7182687;p=alttp.git diff --git a/app/Console/Commands/TwitchTopEmotes.php b/app/Console/Commands/TwitchTopEmotes.php new file mode 100644 index 0000000..81436d9 --- /dev/null +++ b/app/Console/Commands/TwitchTopEmotes.php @@ -0,0 +1,62 @@ +where('banned', '=', false) + ->whereNotNull('evaluated_at') + ->chunk(5000, function ($msgs) use (&$counts) { + foreach ($msgs as $msg) { + $tokenized = $msg->tokenize(); + foreach ($tokenized->getOriginalEmotes() as $emote) { + if (!isset($counts[$emote])) { + $counts[$emote] = 1; + } else { + ++$counts[$emote]; + } + } + } + }); + + arsort($counts); + + $amount = intval($this->argument('amount')); + $counts = array_slice($counts, 0, $amount); + + foreach ($counts as $emote => $count) { + $this->line(mb_str_pad($emote, 20).$count); + } + + return 0; + } + +} + +?>