]> git.localhorst.tv Git - alttp.git/blobdiff - app/TwitchBot/TokenizedMessage.php
revamp chatlib tokenization
[alttp.git] / app / TwitchBot / TokenizedMessage.php
index b460020a3e2e2a42a5683cf7ba78c41f1e01792b..72817c1dbc6066556f77e134684e74137d64f863 100644 (file)
@@ -11,10 +11,13 @@ class TokenizedMessage {
        public function __construct($text, $tags = []) {
                $this->text = trim($text);
                $this->tags = $tags;
+               if (isset($tags['reply-parent-display-name'])) {
+                       $this->text = mb_substr($text, mb_strlen($tags['reply-parent-display-name']) + 2);
+               }
                $this->raw = strtolower(preg_replace('/[^\w]/u', '', $this->text));
                $this->tokens = array_values(array_map('trim', array_filter(preg_split('/\b/u', strtolower($this->text)))));
 
-               $this->emoteless = $this->text;
+               $this->emoteless = $text;
                if (isset($this->tags['emotes']) && !empty($this->tags['emotes'])) {
                        $emotes = explode('/', $this->tags['emotes']);
                        foreach ($emotes as $emote) {
@@ -253,7 +256,7 @@ class TokenizedMessage {
                if ($this->contains(['€', '$', '@', '://'])) {
                        return true;
                }
-               if ($this->containsRaw(['followers', 'promotion', 'viewers'])) {
+               if ($this->containsRaw(['follow', 'promotion', 'viewer'])) {
                        return true;
                }
                if ($this->containsRaw('horsti')) {