- $last = $this->getNote($channel, 'last_special');
- if ($last != 'gg' && $this->checkForGG($channel)) {
- $this->setNote($channel, 'last_special', 'gg');
- return $this->randomOfClass($channel, 'gg');
- }
- if ($last != 'number' && $this->checkForNumbers($channel)) {
- $this->setNote($channel, 'last_special', 'number');
- return $this->randomContextualNumber($channel);
- }
- if ($last != 'lol' && $this->checkForLaughter($channel)) {
- $this->setNote($channel, 'last_special', 'lol');
- return $this->randomLaughter($channel);
- }
- if ($last != 'glhf' && $this->checkForGLHF($channel)) {
- $this->setNote($channel, 'last_special', 'glhf');
- return $this->randomOfClass($channel, 'gl');
- }
- if ($last != 'hi' && $this->checkForGreeting($channel)) {
- $this->setNote($channel, 'last_special', 'hi');
- return $this->randomOfClass($channel, 'hi');
- }
- if ($last != 'hype' && $this->checkForHype($channel)) {
- $this->setNote($channel, 'last_special', 'hype');
- return $this->randomOfClass($channel, 'hype');
- }
- if ($last != 'pog' && $this->checkForPog($channel)) {
- $this->setNote($channel, 'last_special', 'pog');
- return $this->randomOfClass($channel, 'pog');
- }
- if ($last != 'o7' && $this->checkForSalute($channel)) {
- $this->setNote($channel, 'last_special', 'o7');
- return $this->randomOfClass($channel, 'o7');
+ if ($this->hasQueuedSpecial($channel)) {
+ $classification = $this->getQueuedSpecial($channel);
+ if (is_string($classification)) {
+ $this->tagChannelSpecialSent($channel, $classification);
+ }
+ $this->clearQueuedSpecial($channel);
+ return $this->getRandomOfClass($channel, $classification);
+ }
+ $latest_msg = $this->getLatestMessage($channel);
+ if ($latest_msg->classify() == 'question') {
+ $response = $latest_msg->getResponseCategory();
+ return $this->getRandomOfClass($channel, $response);
+ }
+ $last = $this->getLastSpecialSent($channel);
+ $classifications = $this->collectClassifications($channel);
+ $count_quotas = [
+ 'gg' => 2,
+ 'gl' => 2,
+ 'hi' => 2,
+ 'hype' => 2,
+ 'lol' => 2,
+ 'love' => 2,
+ 'number' => 2,
+ 'pog' => 2,
+ 'o7' => 2,
+ 'wtf' => 2,
+ ];
+ $time_quotas = [
+ 'gg' => 600,
+ 'gl' => 900,
+ 'hi' => 60,
+ 'hype' => 60,
+ 'lol' => 60,
+ 'love' => 60,
+ 'number' => 300,
+ 'pog' => 60,
+ 'o7' => 300,
+ 'wtf' => 60,
+ ];
+ foreach ($classifications as $classification => $count) {
+ if ($classification == $last) continue;
+ if (!isset($count_quotas[$classification]) || $count < $count_quotas[$classification]) continue;
+ if (!isset($time_quotas[$classification]) || $this->getTimeSinceSpecial($channel, $classification) < $time_quotas[$classification]) continue;
+ $this->tagChannelSpecialSent($channel, $classification);
+ $reaction = $this->getChimeInReaction($channel, $classification);
+ return $this->getRandomOfClass($channel, $reaction);