--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\ChatLog;
+use Illuminate\Console\Command;
+
+class EvaluateChatCommand extends Command {
+
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'chat:reevaluate';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Reevaluate chat log entries';
+
+ /**
+ * Execute the console command.
+ *
+ * @return int
+ */
+ public function handle() {
+ $good = 0;
+ $bad = 0;
+ ChatLog::where('type', '=', 'chat')
+ ->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;
+ }
+
+}
$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';
'hi' => 2,
'hype' => 2,
'lol' => 2,
+ 'love' => 2,
'number' => 2,
'pog' => 2,
'o7' => 2,
+ 'wtf' => 2,
];
$time_quotas = [
'gg' => 600,
'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;
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);
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',
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',
$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());