$this->tagChannelSpecialSent($channel, $classification);
}
$this->clearQueuedSpecial($channel);
- if ($classification == 'number') {
- return $this->randomContextualNumber($channel);
- }
- if ($classification == 'lol') {
- return $this->randomLaughter($channel);
- }
- return $channel->randomOfClass($classification);
+ 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);
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);
- if ($classification == 'number') {
- return $this->randomContextualNumber($channel);
- }
- if ($classification == 'lol') {
- return $this->randomLaughter($channel);
- }
- return $channel->randomOfClass($classification);
+ $reaction = $this->getChimeInReaction($channel, $classification);
+ return $this->getRandomOfClass($channel, $reaction);
}
return false;
}
if ($this->isDirectedAtMe($msg->getText()) && $this->shouldRespond($channel)) {
$this->notes[$channel->id]['wait_msgs'] = 0;
$this->notes[$channel->id]['wait_time'] = 0;
- $response = $this->getResponseTo($tokenized);
+ $response = $tokenized->getResponseCategory();
if ($response) {
$this->queueSpecial($channel, $response);
}
$this->notes[$channel->id]['last_special'][$classification] = time();
}
+ private function getLatestMessage(Channel $channel) {
+ $this->getNotes($channel);
+ if (!empty($notes['latest_msgs'])) {
+ return $notes['latest_msgs'][count($notes['latest_msgs']) - 1];
+ }
+ return TokenizedMessage::fromString('');
+ }
+
private function getLastSpecialSent(Channel $channel) {
$notes = $this->getNotes($channel);
$max_time = 0;
return false;
}
- private function getResponseTo(TokenizedMessage $msg) {
- switch ($msg->classify()) {
- case 'gg':
- return ['love', 'eyes', 'thx', 'pog', 'kappa'];
- case 'gl':
- return ['love', 'eyes', 'thx'];
+ private function getRandomOfClass(Channel $channel, $classification) {
+ if ($classification == 'number') {
+ return $this->randomContextualNumber($channel);
+ }
+ if ($classification == 'lol') {
+ return $this->randomLaughter($channel);
+ }
+ return $channel->randomOfClass($classification);
+ }
+
+ private function getChimeInReaction(Channel $channel, $classification) {
+ switch ($classification) {
case 'hi':
- return ['hi', 'love', 'eyes', 'hype', 'pog'];
- case 'kappa':
- return ['kappa', 'lol', 'eyes'];
- case 'love':
- return ['hi', 'love', 'eyes', 'thx'];
- case 'question':
- return ['yes', 'no', 'kappa', 'lol', 'wtf', 'number'];
- case 'rage':
- return ['kappa', 'lol', 'rage'];
+ return ['hi', 'love'];
+ case 'hype':
+ return ['hype', 'love', 'pog'];
+ case 'lol':
+ return ['kappa', 'lol'];
+ case 'pog':
+ return ['hype', 'pog'];
case 'wtf':
- return ['kappa', 'lol', 'rage'];
+ return ['lol', 'wtf'];
}
- return false;
+ return $classification;
}
private $channels;