}
public function randomOfClass($class) {
+ if (is_array($class)) {
+ return $this->queryChatlog()
+ ->whereIn('classification', $class)
+ ->first();
+ }
return $this->queryChatlog()
->where('classification', '=', $class)
->first();
if ($this->containsRaw('horstie')) {
return true;
}
- if ($this->containsRaw(['vielendankfürdenraid', 'thanksfortheraid', 'willkommenaufstarbase47'])) {
+ if ($this->containsRaw(['folgtjetzt', 'vielendankfürdenraid', 'thanksfortheraid', 'willkommenaufstarbase47'])) {
return true;
}
return false;
$this->classification = 'unclassified';
} else if ($this->startsWith('!')) {
$this->classification = 'cmd';
- } else if (is_numeric($this->raw)) {
- $this->classification = 'number';
} else if ($this->hasTokenThatStartsOrEndsWith(['gg']) || $this->hasEmoteThatEndsWith(['gg'])) {
$this->classification = 'gg';
} else if ($this->containsRaw(['glgl', 'glhf', 'goodluck', 'hfgl'])) {
$this->classification = 'gl';
+ } else if ($this->hasToken(['danke', 'thanks', 'thx', 'ty']) && !$this->hasToken(['nah', 'nee', 'nein', 'no'])) {
+ $this->classification = 'thx';
} else if ($this->startsWithRaw(['ahoi', 'hallo', 'hello', 'hey', 'huhu', 'moin']) || $this->hasEmoteThatEndsWith(['hello', 'heyguys', 'hi', 'vohiyo', 'wave']) || $this->hasToken(['hi', 'hey', 'yo']) || $this->containsRaw(['gutenmorgen', 'gutenabend'])) {
$this->classification = 'hi';
} else if ($this->hasTokenThatStartsOrEndsWith(['pog', 'wow'])) {
$this->classification = 'pog';
} else if ($this->containsRaw(['hype']) || $this->hasEmoteThatEndsWith(['dance', 'jam', 'party', 'rave', 'troete'])) {
$this->classification = 'hype';
- } else if ($this->hasToken(['danke', 'thanks', 'thx', 'ty'])) {
- $this->classification = 'thx';
} else if ($this->hasToken(['<3']) || $this->hasEmoteThatEndsWith(['heart', 'herz', 'hug', 'love'])) {
$this->classification = 'love';
} else if ($this->hasToken(['nani', 'wat', 'wtf']) || $this->hasEmoteThatEndsWith(['wat', 'wtf'])) {
$this->classification = 'sweat';
} else if ($this->endsWithEmoteless('?')) {
$this->classification = 'question';
+ } else if ($this->hasToken(['ja', 'jo', 'yep', 'yes']) || $this->containsRaw('nodders') || $this->hasEmoteThatEndsWith(['nod', 'nodders', 'yea'])) {
+ $this->classification = 'yes';
+ } else if ($this->hasToken(['nah', 'nee', 'nein', 'no']) || $this->containsRaw('nopers') || $this->hasEmoteThatEndsWith(['nay', 'nope', 'nopers'])) {
+ $this->classification = 'no';
+ } else if ($this->hasEmoteThatContains(['kappa', 'keepo'])) {
+ $this->classification = 'kappa';
} else if ($this->startsOrEndsWithRaw(['o7']) || $this->hasEmoteThatContains('salut')) {
$this->classification = 'o7';
} else if ($this->containsRaw(['haha', 'hehe', 'hihi', 'kekw', 'lol', 'lul']) || $this->hasTokenThatStartsWith(['xd']) || $this->hasConsecutiveTokens([':', 'd'])) {
$this->classification = 'lol';
+ } else if (is_numeric($this->raw)) {
+ $this->classification = 'number';
} else {
$this->classification = 'unclassified';
}
'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 = [];
'eyes',
'love',
'lol',
+ 'yes',
+ 'no',
'rage',
'sad',
'sweat',
'wtf',
'pog',
'hype',
+ 'kappa',
'o7',
'question',
'thx',
gl: 'Good Luck',
hi: 'Begrüßung',
hype: 'Hype',
+ kappa: 'Kappa',
lol: 'Gelächter',
love: 'Love',
+ no: 'Nein',
o7: 'Salutieren',
pog: 'Pog',
question: 'Frage',
thx: 'Danke',
unclassified: 'Generisch',
wtf: 'WTF',
+ yes: 'Ja',
},
chatError: 'Fehler beim Senden',
chatSettings: 'Chat Bot Einstellungen',
gl: 'Good Luck',
hi: 'Greeting',
hype: 'Hype',
+ kappa: 'Kappa',
lol: 'Laughter',
love: 'Love',
+ no: 'No',
o7: 'Salute',
pog: 'Pog',
question: 'Question',
thx: 'Thanks',
unclassified: 'Generic',
wtf: 'WTF',
+ yes: 'Yes',
},
chatError: 'Error sending message',
chatSettings: 'Chat Bot Settings',
$this->assertEquals('hype', TokenizedMessage::fromString('122 Hype!')->classify());
+ $this->assertEquals('kappa', TokenizedMessage::fromString('Kappa', ['emotes' => 'blah:0-4'])->classify());
+ $this->assertEquals('kappa', TokenizedMessage::fromString('KappaClaus', ['emotes' => 'blah:0-9'])->classify());
+ $this->assertEquals('kappa', TokenizedMessage::fromString('Keepo', ['emotes' => 'blah:0-4'])->classify());
+ $this->assertNotEquals('kappa', TokenizedMessage::fromString('I keep order')->classify());
+
$this->assertEquals('number', TokenizedMessage::fromString('13')->classify());
$this->assertEquals('number', TokenizedMessage::fromString('22')->classify());