From: Daniel Karbach Date: Thu, 11 Apr 2024 10:04:54 +0000 (+0200) Subject: more classification X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=13ffde5b2abcf831af9c794044350737066c5933;hp=6a1dfa72436b2f5e5b34485da7d7ef1053d89ccc;p=alttp.git more classification --- diff --git a/app/Console/Commands/ReevaluateChatCommand.php b/app/Console/Commands/ReevaluateChatCommand.php new file mode 100644 index 0000000..69a8374 --- /dev/null +++ b/app/Console/Commands/ReevaluateChatCommand.php @@ -0,0 +1,61 @@ +where('banned', false) + ->orderBy('created_at') + ->chunk(10000, function ($logs) use (&$good, &$bad) { + foreach ($logs as $line) { + try { + $line->evaluate(); + $line->evaluated_at = now(); + $line->save(); + ++$good; + } catch (\Exception $e) { + ++$bad; + $this->error('unable to evaluate line '.$line->id.': '.$e->getMessage()); + $line->type = 'error'; + $line->text_content = $e->getMessage(); + $line->evaluated_at = now(); + $line->save(); + } + } + echo $good; + if ($bad) { + echo ' +', $bad, ' errors'; + } + echo PHP_EOL; + }); + + return Command::SUCCESS; + } + +} diff --git a/app/TwitchBot/TokenizedMessage.php b/app/TwitchBot/TokenizedMessage.php index 0e241d5..82b4d47 100644 --- a/app/TwitchBot/TokenizedMessage.php +++ b/app/TwitchBot/TokenizedMessage.php @@ -234,7 +234,7 @@ class TokenizedMessage { $this->classification = 'thx'; } else if ($this->hasToken(['<3']) || $this->hasEmoteThatEndsWith(['herz', 'hug', 'love'])) { $this->classification = 'love'; - } else if ($this->hasTokenThatStartsWith(['wat', 'wtf']) || $this->hasEmoteThatStartsWith(['wat', 'wtf'])) { + } else if ($this->hasToken(['wat', 'wat?']) || $this->hasTokenThatStartsWith(['wtf']) || $this->hasEmoteThatEndsWith(['wat', 'wtf'])) { $this->classification = 'wtf'; } else if ($this->endsWithEmoteless('?')) { $this->classification = 'question'; diff --git a/app/TwitchBot/TwitchChatBot.php b/app/TwitchBot/TwitchChatBot.php index 5b067a6..479a9ab 100644 --- a/app/TwitchBot/TwitchChatBot.php +++ b/app/TwitchBot/TwitchChatBot.php @@ -140,9 +140,11 @@ class TwitchChatBot extends TwitchBot { 'hi' => 2, 'hype' => 2, 'lol' => 2, + 'love' => 2, 'number' => 2, 'pog' => 2, 'o7' => 2, + 'wtf' => 2, ]; $time_quotas = [ 'gg' => 600, @@ -150,9 +152,11 @@ class TwitchChatBot extends TwitchBot { 'hi' => 60, 'hype' => 60, 'lol' => 60, + 'love' => 60, 'number' => 300, 'pog' => 60, 'o7' => 300, + 'wtf' => 60, ]; foreach ($classifications as $classification => $count) { if ($classification == $last) continue; diff --git a/resources/js/components/twitch-bot/Controls.js b/resources/js/components/twitch-bot/Controls.js index 51f0633..9c5701e 100644 --- a/resources/js/components/twitch-bot/Controls.js +++ b/resources/js/components/twitch-bot/Controls.js @@ -13,7 +13,20 @@ import ChannelSelect from '../common/ChannelSelect'; import Icon from '../common/Icon'; import ToggleSwitch from '../common/ToggleSwitch'; -const CHAT_CATEGORIES = ['unclassified', 'hi', 'gl', 'gg', 'lol', 'pog', 'hype', 'o7']; +const CHAT_CATEGORIES = [ + 'unclassified', + 'hi', + 'gl', + 'gg', + 'love', + 'lol', + 'wtf', + 'pog', + 'hype', + 'o7', + 'question', + 'thx', +]; const Controls = () => { const [channel, setChannel] = React.useState(null); diff --git a/resources/js/i18n/de.js b/resources/js/i18n/de.js index 8a24991..a88d150 100644 --- a/resources/js/i18n/de.js +++ b/resources/js/i18n/de.js @@ -692,9 +692,13 @@ export default { hi: 'Begrüßung', hype: 'Hype', lol: 'Gelächter', + love: 'Love', o7: 'Salutieren', pog: 'Pog', + question: 'Frage', + thx: 'Danke', unclassified: 'Generisch', + wtf: 'WTF', }, chatError: 'Fehler beim Senden', chatSettings: 'Chat Bot Einstellungen', diff --git a/resources/js/i18n/en.js b/resources/js/i18n/en.js index f33d4f0..9563eed 100644 --- a/resources/js/i18n/en.js +++ b/resources/js/i18n/en.js @@ -692,9 +692,13 @@ export default { hi: 'Greeting', hype: 'Hype', lol: 'Laughter', + love: 'Love', o7: 'Salute', pog: 'Pog', + question: 'Question', + thx: 'Thanks', unclassified: 'Generic', + wtf: 'WTF', }, chatError: 'Error sending message', chatSettings: 'Chat Bot Settings', diff --git a/tests/Unit/TwitchBot/TokenizedMessageTest.php b/tests/Unit/TwitchBot/TokenizedMessageTest.php index 6fe2e0d..37e516a 100644 --- a/tests/Unit/TwitchBot/TokenizedMessageTest.php +++ b/tests/Unit/TwitchBot/TokenizedMessageTest.php @@ -53,6 +53,7 @@ class TokenizedMessageTest extends TestCase { $this->assertEquals('thx', TokenizedMessage::fromString('danke für den tipp')->classify()); $this->assertEquals('wtf', TokenizedMessage::fromString('wtf? lol')->classify()); + $this->assertNotEquals('wtf', TokenizedMessage::fromString('ein waterwalk aufgesetzt')->classify()); $this->assertEquals('unclassified', TokenizedMessage::fromString('')->classify()); $this->assertEquals('unclassified', TokenizedMessage::fromString('bitte boots locked in desert und bib')->classify());