This commit is contained in:
HolgerHatGarKeineNode
2023-04-25 23:09:21 +02:00
parent 5a4322b035
commit ed54b25567
32 changed files with 683 additions and 12 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Http\Livewire;
use Illuminate\Support\Facades\File;
use Livewire\Component;
use WireUi\Traits\Actions;
@@ -9,21 +10,60 @@ class LaravelEcho extends Component
{
use Actions;
protected $listeners = ['echo:plebchannel,.App\Events\PlebLoggedInEvent' => 'plebLoggedIn'];
public $audioSrc = '';
protected $listeners = [
'echo:plebchannel,.App\Events\PlebLoggedInEvent' => 'plebLoggedIn',
'echo:plebchannel,.App\Events\AudioTextToSpeechChangedEvent' => 'audioTextToSpeechChanged',
'echo:plebchannel,.App\Events\PaidMessageEvent' => 'paidMessage',
];
public function rules()
{
return [
'audioSrc' => 'required',
];
}
public function paidMessage($data)
{
$text = sprintf("
%s
%s.
",
'Nachricht aus dem Publikum.',
str($data['message'])
->stripTags()
->toString()
);
File::put(storage_path('app/public/tts/'.$data['checkid'].'.txt'), $text);
dispatch(new \App\Jobs\CodeIsSpeech($data['checkid']))->delay(now()->addSecond());
}
public function audioTextToSpeechChanged($data)
{
$this->audioSrc = $data['src'];
}
public function plebLoggedIn($data)
{
if (auth()->check()) {
$text = sprintf("
%s hat sich gerade eingeloggt. Markus Turm ist begeistert.
", $data['name']);
File::put(storage_path('app/public/tts/userLoggedIn.txt'), $text);
dispatch(new \App\Jobs\CodeIsSpeech('userLoggedIn'))->delay(now()->addSecond());
$this->notification()
->confirm([
'img' => $data['img'],
'title' => 'Pleb alert!',
'img' => $data['img'],
'title' => 'Pleb alert!',
'description' => $data['name'].' logged in',
'icon' => 'bell',
'icon' => 'bell',
'acceptLabel' => '',
'rejectLabel' => '',
'iconColor' => 'primary',
'timeout' => 60000,
'iconColor' => 'primary',
'timeout' => 60000,
]);
}
}