]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/TokenizedMessage.php
more classifications
[alttp.git] / app / TwitchBot / TokenizedMessage.php
index 42d6ca8ca8f08c05cc625e3b32df236ef4683932..61ca5c8dee40d346e575342e7494512ac055a562 100644 (file)
@@ -9,10 +9,10 @@ use Illuminate\Support\Str;
 class TokenizedMessage {
 
        public function __construct($text, $tags = []) {
-               $this->text = $text;
+               $this->text = trim($text);
                $this->tags = $tags;
-               $this->raw = strtolower(preg_replace('/[^\w]/u', '', $text));
-               $this->tokens = array_values(array_map('trim', array_filter(preg_split('/\b/', strtolower($text)))));
+               $this->raw = strtolower(preg_replace('/[^\w]/u', '', $this->text));
+               $this->tokens = array_values(array_map('trim', array_filter(preg_split('/\b/', strtolower($this->text)))));
 
                $this->emoteless = $this->text;
                if (isset($this->tags['emotes']) && !empty($this->tags['emotes'])) {
@@ -224,7 +224,7 @@ class TokenizedMessage {
 
        public function classify() {
                if (is_null($this->classification)) {
-                       if (empty($this->raw)) {
+                       if (empty($this->text)) {
                                $this->classification = 'unclassified';
                        } else if ($this->startsWith('!')) {
                                $this->classification = 'cmd';
@@ -246,6 +246,14 @@ class TokenizedMessage {
                                $this->classification = 'love';
                        } else if ($this->hasToken(['nani', 'wat', 'wtf']) || $this->hasEmoteThatEndsWith(['wat', 'wtf'])) {
                                $this->classification = 'wtf';
+                       } else if ($this->hasConsecutiveTokens([':', 'eyes', ':']) || $this->hasEmoteThatEndsWith(['eyes'])) {
+                               $this->classification = 'eyes';
+                       } else if ($this->hasEmoteThatEndsWith(['angry', 'rage', 'ree'])) {
+                               $this->classification = 'rage';
+                       } else if ($this->hasToken([':(']) || $this->hasEmoteThatEndsWith(['cry', 'sad'])) {
+                               $this->classification = 'sad';
+                       } else if ($this->hasToken(['monkas', 'sweat_smile']) || $this->hasEmoteThatEndsWith(['sweat'])) {
+                               $this->classification = 'sweat';
                        } else if ($this->endsWithEmoteless('?')) {
                                $this->classification = 'question';
                        } else if ($this->startsOrEndsWithRaw(['o7']) || $this->hasEmoteThatContains('salut')) {