3 namespace App\Console\Commands;
5 use App\Models\ChatLog;
6 use Illuminate\Console\Command;
8 class TwitchTopEmotes extends Command {
11 * The name and signature of the console command.
15 protected $signature = 'twitch:top-emotes {amount=10}';
18 * The console command description.
22 protected $description = 'Compiles a list of top N emotes in the chatbot catalog';
25 * Execute the console command.
29 public function handle() {
32 ChatLog::where('type', '=', 'chat')
33 ->where('banned', '=', false)
34 ->whereNotNull('evaluated_at')
35 ->chunk(5000, function ($msgs) use (&$counts) {
36 foreach ($msgs as $msg) {
37 $tokenized = $msg->tokenize();
38 foreach ($tokenized->getOriginalEmotes() as $emote) {
39 if (!isset($counts[$emote])) {
50 $amount = intval($this->argument('amount'));
51 $counts = array_slice($counts, 0, $amount);
53 foreach ($counts as $emote => $count) {
54 $this->line(mb_str_pad($emote, 20).$count);