$notes = $this->getNotes($channel);
$ggs = 0;
foreach ($notes['latest_msgs'] as $text) {
- $rawText = strtolower(preg_replace('/[^\w]/', '', $text));
- if (Str::startsWith($rawText, 'gg') || Str::endsWith($rawText, 'gg')) {
+ if (ChatLog::classify($text) == 'gg') {
++$ggs;
}
}
$notes = $this->getNotes($channel);
$gls = 0;
foreach ($notes['latest_msgs'] as $text) {
- $rawText = strtolower(preg_replace('/[^\w]/', '', $text));
- if (Str::contains($rawText, ['glgl', 'glhf', 'hfgl'])) {
+ if (ChatLog::classify($text) == 'gl') {
++$gls;
}
}
return $gls > 2;
}
+ private function checkForGreeting(Channel $channel) {
+ $notes = $this->getNotes($channel);
+ $his = 0;
+ foreach ($notes['latest_msgs'] as $text) {
+ if (ChatLog::classify($text) == 'hi') {
+ ++$his;
+ }
+ }
+ return $his > 2;
+ }
+
+ private function checkForHype(Channel $channel) {
+ $notes = $this->getNotes($channel);
+ $hypes = 0;
+ foreach ($notes['latest_msgs'] as $text) {
+ if (ChatLog::classify($text) == 'hype') {
+ ++$hypes;
+ }
+ }
+ return $hypes > 2;
+ }
+
private function checkForLaughter(Channel $channel) {
$notes = $this->getNotes($channel);
$lulz = 0;
foreach ($notes['latest_msgs'] as $text) {
- $rawText = strtolower(preg_replace('/[^\w]/', '', $text));
- if (Str::contains($rawText, ['haha', 'kekw', 'lol', 'lul', 'xd'])) {
+ if (ChatLog::classify($text) == 'lol') {
++$lulz;
}
}
return $numbers > 2;
}
+ private function checkForPog(Channel $channel) {
+ $notes = $this->getNotes($channel);
+ $pogs = 0;
+ foreach ($notes['latest_msgs'] as $text) {
+ if (ChatLog::classify($text) == 'pog') {
+ ++$pogs;
+ }
+ }
+ return $pogs > 2;
+ }
+
private function contextualMsg(Channel $channel) {
$last = $this->getNote($channel, 'last_special');
if ($last != 'gg' && $this->checkForGG($channel)) {
$this->setNote($channel, 'last_special', 'gg');
- return $this->randomGG($channel);
+ return $this->randomOfClass($channel, 'gg');
}
if ($last != 'number' && $this->checkForNumbers($channel)) {
$this->setNote($channel, 'last_special', 'number');
}
if ($last != 'glhf' && $this->checkForGLHF($channel)) {
$this->setNote($channel, 'last_special', 'glhf');
- return $this->randomGLHF($channel);
+ 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');
}
return false;
}
return random_int($min, $max);
}
- private function randomGG(Channel $channel) {
- $line = $this->queryChatlog($channel)
- ->where('text_content', 'LIKE', '%gg')
- ->whereRaw('LENGTH(`text_content`) < 30')
- ->first();
- return $line->text_content;
- }
-
- private function randomGLHF(Channel $channel) {
+ private function randomOfClass(Channel $channel, $class) {
$line = $this->queryChatlog($channel)
- ->where('text_content', 'LIKE', '%glhf%')
- ->whereRaw('LENGTH(`text_content`) < 30')
+ ->where('classification', '=', $class)
->first();
return $line->text_content;
}
'SUBprise',
'xD',
'YouDontSay',
+ $this->randomOfClass($channel, 'lol'),
]);
}