'last_special' => [],
'last_write' => time(),
'latest_msgs' => [],
+ 'queued_special' => false,
'read_since_last_write' => 0,
'wait_msgs' => $this->randomWaitMsgs($channel),
'wait_time' => $this->randomWaitTime($channel),
}
private function contextualMsg(Channel $channel) {
+ if ($this->hasQueuedSpecial($channel)) {
+ $classification = $this->getQueuedSpecial($channel);
+ if (is_string($classification)) {
+ $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);
+ }
$last = $this->getLastSpecialSent($channel);
$classifications = $this->collectClassifications($channel);
$count_quotas = [
private function randomChat(Channel $channel) {
return $channel->queryChatlog()
- ->whereNotIn('classification', ['gg', 'gl', 'o7'])
+ ->whereNotIn('classification', ['gg', 'gl', 'number', 'o7'])
->first();
}
return random_int($min, $max);
}
+ private function queueSpecial(Channel $channel, $classification) {
+ $this->getNotes($channel);
+ $this->notes[$channel->id]['queued_special'] = $classification;
+ }
+
+ private function hasQueuedSpecial(Channel $channel) {
+ return !!$this->getQueuedSpecial($channel);
+ }
+
+ private function getQueuedSpecial(Channel $channel) {
+ $notes = $this->getNotes($channel);
+ return $notes['queued_special'];
+ }
+
+ private function clearQueuedSpecial(Channel $channel) {
+ $this->getNotes($channel);
+ $this->notes[$channel->id]['queued_special'] = false;
+ }
+
private function tagChannelRead(Channel $channel, IRCMessage $msg) {
$this->getNotes($channel);
$this->notes[$channel->id]['last_read'] = time();
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);
+ if ($response) {
+ $this->queueSpecial($channel, $response);
+ }
}
}
return false;
}
+ private function getResponseTo(TokenizedMessage $msg) {
+ switch ($msg->classify()) {
+ case 'gg':
+ return ['love', 'eyes', 'thx', 'pog', 'kappa'];
+ case 'gl':
+ return ['love', 'eyes', 'thx'];
+ 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'];
+ case 'wtf':
+ return ['kappa', 'lol', 'rage'];
+ }
+ return false;
+ }
+
private $channels;
private $notes = [];