charset = utf-8
end_of_line = lf
insert_final_newline = true
-indent_style = space
+indent_style = tab
indent_size = 4
trim_trailing_whitespace = true
}
$channel->short_name = $sgChannel['initials'];
$channel->title = $sgChannel['name'];
- $channel->stream_link = 'https://twitch.tv/'.strtolower($sgChannel['name']);
+ $channel->stream_link = 'https://twitch.tv/'.strtolower($sgChannel['slug']);
$channel->languages = [$sgChannel['language']];
$channel->save();
return $channel;
} else {
$episode->title = $entry['summary'];
}
- if (preg_match('/Restream: https?:\/\/(www\.)?twitch\.tv\/(\w+)/u', $entry['description'], $matches)) {
- $channel = $this->syncChannel($episode, $matches[2]);
- if ($channel) {
- $episode->channels()->syncWithoutDetaching([$channel->id]);
- }
- }
- if (preg_match('/^(.*) - (.*?) vs (.*?)$/u', $episode->title, $matches)) {
- $episode->title = $matches[1];
- $this->syncPlayer($episode, $matches[2]);
- $this->syncPlayer($episode, $matches[3]);
- }
$start = Carbon::parse($entry['start']['dateTime'])->setTimezone('UTC');
if (!$episode->start || $start->ne($episode->start)) {
$episode->start = $start;
$end = Carbon::parse($entry['end']['dateTime'])->setTimezone('UTC');
$episode->estimate = $start->diffInSeconds($end);
$episode->confirmed = true;
- $episode->save();
+ if (preg_match('/^(.*) - (.*?) vs\.? (.*?) vs\.? (.*?) vs\.? (.*?)$/u', $episode->title, $matches)) {
+ $episode->title = $matches[1];
+ $episode->save();
+ $this->syncPlayer($episode, $matches[2]);
+ $this->syncPlayer($episode, $matches[3]);
+ $this->syncPlayer($episode, $matches[4]);
+ $this->syncPlayer($episode, $matches[5]);
+ } else if (preg_match('/^(.*) - (.*?) vs\.? (.*?) vs\.? (.*?)$/u', $episode->title, $matches)) {
+ $episode->title = $matches[1];
+ $episode->save();
+ $this->syncPlayer($episode, $matches[2]);
+ $this->syncPlayer($episode, $matches[3]);
+ $this->syncPlayer($episode, $matches[4]);
+ } else if (preg_match('/^(.*) - (.*?) vs\.? (.*?)$/u', $episode->title, $matches)) {
+ $episode->title = $matches[1];
+ $episode->save();
+ $this->syncPlayer($episode, $matches[2]);
+ $this->syncPlayer($episode, $matches[3]);
+ } else {
+ $episode->save();
+ }
+ if (preg_match('/Restream: https?:\/\/(www\.)?twitch\.tv\/(\w+)/u', $entry['description'], $matches)) {
+ $channel = $this->syncChannel($episode, $matches[2]);
+ if ($channel) {
+ $episode->channels()->syncWithoutDetaching([$channel->id]);
+ }
+ }
}
private function syncChannel(Episode $episode, $zsrChannel) {
$schedule->command('sync:ladder')->daily();
$schedule->command('sync:speedgaming')->everyFiveMinutes();
$schedule->command('sync:sra')->everyFifteenMinutes();
+ $schedule->command('sync:zsr')->everyFifteenMinutes();
$schedule->command('sync:avatars')->everyFiveMinutes();
$schedule->command('sync:racetime')->everyFiveMinutes();
$schedule->command('chat:evaluate 100')->everyMinute();
class ChatLib {
- public function __construct($size = 7) {
+ public function __construct($size = 6) {
$this->size = $size;
$converted = [];
if ($end - $i < 5) break;
}
}
+ $this->addExample(array_slice($tokens, 0, $num), $token);
}
}
public function compile() {
- foreach ($this->transitions as $key => $value) {
- $this->transitions[$key] = $this->index($this->transitions[$key]);
+ foreach ($this->transitions as $key => $values) {
+ $this->transitions[$key] = $this->index($values, 2);
if (empty($this->transitions[$key])) {
unset($this->transitions[$key]);
}
}
+ foreach ($this->examples as $key => $values) {
+ if (in_array($key, ['', ' '])) {
+ unset($this->examples[$key]);
+ continue;
+ }
+ $this->examples[$key] = $this->index($values, 1);
+ if (empty($this->examples[$key]) || (count($this->examples[$key]) === 1 && $this->examples[$key][0][0] === $key)) {
+ unset($this->examples[$key]);
+ }
+ }
}
public function generate($limit = 100) {
$data = [
'size' => $this->size,
'transitions' => $this->transitions,
+ 'examples' => $this->examples,
];
Storage::disk('chatlib')->put($name.'.json', json_encode($data));
}
$data = json_decode(Storage::disk('chatlib')->get($name.'.json'), true);
$this->size = $data['size'];
$this->transitions = $data['transitions'];
+ $this->examples = $data['examples'];
}
- private function index($arr) {
+ private function index($arr, $min_weight = 2) {
$result = [];
$sum = 0;
- foreach ($arr as $key => $entry) {
- $weight = $entry[0];
- if ($weight == 1) continue;
+ foreach ($arr as $key => $weight) {
+ if ($weight < $min_weight) continue;
$lower = $sum;
$sum += $weight;
- $examples = [];
- if ($key === ' ') {
- $examples = [[' ', 0, 1]];
- } else {
- $subsum = 0;
- foreach ($entry[1] as $example => $subweight) {
- $sublower = $subsum;
- $subsum += $subweight;
- $examples[] = [$example, $sublower, $subsum];
- }
- }
- $result[] = [$key, $lower, $sum, $examples];
+ $result[] = [$key, $lower, $sum];
}
return $result;
}
if (isset($this->transitions[$cmb])) {
$pick = $this->pick($this->transitions[$cmb]);
if (!is_null($pick)) {
- return $this->exampleOf($pick);
+ return $this->exampleOf($pick, $tokens);
}
}
}
}
private function addTransition($state, $next) {
- $cmb = $this->generalize($state);
- if (!isset($this->transitions[$cmb])) {
- $this->transitions[$cmb] = [];
+ $ctx = $this->generalize($state);
+ $cmb = $this->generalize([$next]);
+ if (!isset($this->transitions[$ctx])) {
+ $this->transitions[$ctx] = [];
+ }
+ if (!isset($this->transitions[$ctx][$cmb])) {
+ $this->transitions[$ctx][$cmb] = 1;
+ } else {
+ ++$this->transitions[$ctx][$cmb];
}
- $this->increment($this->transitions[$cmb], $next);
}
- private function increment(&$which, $token) {
- $generalized = $this->generalize([$token]);
- if (!isset($which[$generalized])) {
- $which[$generalized] = [
- 1,
- [],
- ];
- $which[$generalized][1][$token] = 1;
+ private function addExample($context, $token) {
+ $cmb = $this->generalize([$token]);
+ if (!isset($this->examples[$cmb])) {
+ $this->examples[$cmb] = [];
+ }
+ if (!isset($this->examples[$cmb][$token])) {
+ $this->examples[$cmb][$token] = 1;
} else {
- ++$which[$generalized][0];
- if (!isset($which[$generalized][1][$token])) {
- $which[$generalized][1][$token] = 1;
- } else {
- ++$which[$generalized][1][$token];
- }
+ ++$this->examples[$cmb][$token];
}
}
return $str;
}
- private function exampleOf($pick) {
- $example = $this->pick($pick[3]);
- return $example[0];
+ private function exampleOf($pick, $context) {
+ if (!isset($this->examples[$pick[0]])) {
+ return $pick[0];
+ }
+ if (isset($this->examples[$pick[0]])) {
+ $example = $this->pick($this->examples[$pick[0]]);
+ return $example[0];
+ }
+ return $pick[0];
}
- private $size = 7;
+ private $size;
private $transitions = [];
+ private $examples = [];
private $aliases = [
'chest' => ['kiste'],
'wave' => [
'dennsenhi',
'dergoawave',
+ 'falcnwavehi',
'heyguys',
'holysm0heyguys',
'muftaahey',
if ($this->containsRaw('horsti')) {
return true;
}
- if ($this->containsRaw(['folgtjetzt', 'vielendankfürdenraid', 'thanksfortheraid', 'willkommenaufstarbase47'])) {
+ if ($this->containsRaw([
+ 'folgtjetzt',
+ 'hatdeinenkanalgeraided',
+ 'isnowlivestreaming',
+ 'stürmtdenladenmit',
+ 'thanksfortheraid',
+ 'verschwindetfürneweileindenlurk',
+ 'vielendankfürdenraid',
+ 'willkommenaufstarbase47',
+ ])) {
return true;
}
return false;
setShowResults(false);
}
};
- document.addEventListener('click', handleEventOutside, true);
+ document.addEventListener('mousedown', handleEventOutside, true);
document.addEventListener('focus', handleEventOutside, true);
return () => {
- document.removeEventListener('click', handleEventOutside, true);
+ document.removeEventListener('mousedown', handleEventOutside, true);
document.removeEventListener('focus', handleEventOutside, true);
};
}, []);
const DiscordChannelSelect = ({
guild,
- isInvalid,
name,
- onBlur,
onChange,
types,
value,
setShowResults(false);
}
};
- document.addEventListener('click', handleEventOutside, true);
+ document.addEventListener('mousedown', handleEventOutside, true);
document.addEventListener('focus', handleEventOutside, true);
return () => {
- document.removeEventListener('click', handleEventOutside, true);
+ document.removeEventListener('mousedown', handleEventOutside, true);
document.removeEventListener('focus', handleEventOutside, true);
};
}, []);
setShowResults(false);
}
};
- document.addEventListener('click', handleEventOutside, true);
+ document.addEventListener('mousedown', handleEventOutside, true);
document.addEventListener('focus', handleEventOutside, true);
return () => {
- document.removeEventListener('click', handleEventOutside, true);
+ document.removeEventListener('mousedown', handleEventOutside, true);
document.removeEventListener('focus', handleEventOutside, true);
};
}, []);
setShowResults(false);
}
};
- document.addEventListener('click', handleEventOutside, true);
+ document.addEventListener('mousedown', handleEventOutside, true);
document.addEventListener('focus', handleEventOutside, true);
return () => {
- document.removeEventListener('click', handleEventOutside, true);
+ document.removeEventListener('mousedown', handleEventOutside, true);
document.removeEventListener('focus', handleEventOutside, true);
};
}, []);
$this->assertTrue(TokenizedMessage::fromString('hello would you like some followers?')->isSpammy());
$this->assertTrue(TokenizedMessage::fromString('get view ers for free')->isSpammy());
+ $this->assertTrue(TokenizedMessage::fromString('yayklaygaming verschwindet für \'ne Weile in den Lurk. Cool, dass Du vorbeigeschaut hast xallggCheers PogChamp')->isSpammy());
+ $this->assertTrue(TokenizedMessage::fromString('XallGG is now live! Streaming The Legend of Zelda: A Link to the Past: Casual Boots Seed zum Spaß/Practice')->isSpammy());
$this->assertTrue(TokenizedMessage::fromString('also bitte, horstie')->isSpammy());
$this->assertTrue(TokenizedMessage::fromString('hey maengi, vielen dank für den raid')->isSpammy());