Apply fixes from StyleCI

This commit is contained in:
HDVinnie
2019-02-09 20:56:26 +00:00
committed by StyleCI Bot
parent 9507d0749f
commit f711b767a2
18 changed files with 421 additions and 440 deletions
-1
View File
@@ -46,5 +46,4 @@ class Bot extends Model
* @var array
*/
protected $dates = ['deleted_at'];
}
+2 -2
View File
@@ -31,7 +31,6 @@ class BotTransaction extends Model
*/
public $timestamps = true;
/**
* Belongs To A User.
*
@@ -71,9 +70,10 @@ class BotTransaction extends Model
*/
public function forHumans()
{
if($this->type == 'bon') {
if ($this->type == 'bon') {
return 'BON';
}
return 'Unknown';
}
}
+66 -69
View File
@@ -1,6 +1,6 @@
<?php
/**
* NOTICE OF LICENSE
* NOTICE OF LICENSE.
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
@@ -9,22 +9,22 @@
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author singularity43
*/
namespace App\Bots;
use App\User;
use App\UserAudible;
use App\Bot;
use App\BotTransaction;
use App\User;
use App\UserEcho;
use App\Events\Chatter;
use Carbon\Carbon;
use App\Http\Resources\UserAudibleResource;
use App\Http\Resources\UserEchoResource;
use App\UserAudible;
use App\BotTransaction;
use App\Events\Chatter;
use App\Repositories\ChatRepository;
use App\Http\Resources\UserEchoResource;
use App\Http\Resources\UserAudibleResource;
class CasinoBot
{
private $bot;
private $chat;
private $target;
@@ -42,7 +42,7 @@ class CasinoBot
*/
public function __construct(ChatRepository $chat)
{
$bot = Bot::where('id','=','3')->firstOrFail();
$bot = Bot::where('id', '=', '3')->firstOrFail();
$this->chat = $chat;
$this->bot = $bot;
$this->expiresAt = Carbon::now()->addMinutes(60);
@@ -50,39 +50,36 @@ class CasinoBot
}
/**
* Replace Vars
*
* Replace Vars.
*/
public function replaceVars($output)
{
$output=str_replace("{me}",$this->bot->name,$output);
$output=str_replace("{command}",$this->bot->command,$output);
if(strstr($output,"{bots}")) {
$bot_help = "";
$bots = Bot::where('active','=',1)->where('id','!=',$this->bot->id)->orderBy('position','asc')->get();
foreach($bots as $bot) {
$bot_help.="( ! | / | @)".$bot->command." help triggers help file for ".$bot->name."\n";
$output = str_replace('{me}', $this->bot->name, $output);
$output = str_replace('{command}', $this->bot->command, $output);
if (strstr($output, '{bots}')) {
$bot_help = '';
$bots = Bot::where('active', '=', 1)->where('id', '!=', $this->bot->id)->orderBy('position', 'asc')->get();
foreach ($bots as $bot) {
$bot_help .= '( ! | / | @)'.$bot->command.' help triggers help file for '.$bot->name."\n";
}
$output=str_replace("{bots}",$bot_help,$output);
$output = str_replace('{bots}', $bot_help, $output);
}
return $output;
}
/**
* Send Bot Donation
*
* Send Bot Donation.
*/
public function putDonate($amount = 0,$note = '')
public function putDonate($amount = 0, $note = '')
{
$output = implode(" ",$note);
$output = implode(' ', $note);
$v = validator(['bot_id' => $this->bot->id, 'amount'=> $amount, 'note'=> $output], [
'bot_id' => 'required|exists:bots,id|max:999',
'amount' => "required|numeric|min:1|max:{$this->target->seedbonus}",
'note' => 'required|string',
]);
if ($v->passes()) {
$value = $amount;
$this->bot->seedbonus += $value;
$this->bot->save();
@@ -99,29 +96,29 @@ class CasinoBot
$transaction->comment = $output;
$transaction->save();
$donations = BotTransaction::with('user','bot')->where('bot_id','=',$this->bot->id)->where('to_bot','=',1)->latest()->limit(10)->get();
$donations = BotTransaction::with('user', 'bot')->where('bot_id', '=', $this->bot->id)->where('to_bot', '=', 1)->latest()->limit(10)->get();
cache()->put('casinobot-donations', $donations, $this->expiresAt);
return "Your donation to ".$this->bot->name." for ".$amount." BON has been sent!";
return 'Your donation to '.$this->bot->name.' for '.$amount.' BON has been sent!';
}
return "Your donation to ".$output." could not be sent.";
return 'Your donation to '.$output.' could not be sent.';
}
/**
* Get Bot Donations
*
* Get Bot Donations.
*/
public function getDonations($duration = 'default')
{
$donations = cache()->get('casinobot-donations');
if(!$donations|| $donations == null) {
$donations = BotTransaction::with('user','bot')->where('bot_id','=',$this->bot->id)->where('to_bot','=',1)->latest()->limit(10)->get();
if (! $donations || $donations == null) {
$donations = BotTransaction::with('user', 'bot')->where('bot_id', '=', $this->bot->id)->where('to_bot', '=', 1)->latest()->limit(10)->get();
cache()->put('casinobot-donations', $donations, $this->expiresAt);
}
$donation_dump = "";
$donation_dump = '';
$i = 1;
foreach($donations as $donation) {
$donation_dump .= "#" . $i . ". " . $donation->user->username . " sent ".$donation->cost." ".$donation->forHumans()." with note: ".$donation->comment.".\n";
foreach ($donations as $donation) {
$donation_dump .= '#'.$i.'. '.$donation->user->username.' sent '.$donation->cost.' '.$donation->forHumans().' with note: '.$donation->comment.".\n";
$i++;
}
@@ -129,8 +126,7 @@ class CasinoBot
}
/**
* Get Help
*
* Get Help.
*/
public function getHelp()
{
@@ -138,13 +134,12 @@ class CasinoBot
}
/**
* Process Message
*
* Process Message.
*/
public function process($type, User $target, $message = "", $targeted = 0)
public function process($type, User $target, $message = '', $targeted = 0)
{
$this->target = $target;
if($type == 'message') {
if ($type == 'message') {
$x = 0;
$y = 1;
$z = 2;
@@ -154,20 +149,20 @@ class CasinoBot
$z = 3;
}
if($message == "") {
$log = "";
if ($message == '') {
$log = '';
} else {
$log = "All ".$this->bot->name." commands must be a private message or begin with /".$this->bot->command." or !".$this->bot->command.". Need help? Type /".$this->bot->command." help and you shall be helped.";
$log = 'All '.$this->bot->name.' commands must be a private message or begin with /'.$this->bot->command.' or !'.$this->bot->command.'. Need help? Type /'.$this->bot->command.' help and you shall be helped.';
}
$command = @explode(" ",$message);
$command = @explode(' ', $message);
$wildcard = null;
$params = null;
if(array_key_exists($y,$command)) {
if (array_key_exists($y, $command)) {
$params = $command[$y];
}
if($params != null) {
if ($params != null) {
$clone = $command;
array_shift($clone);
array_shift($clone);
@@ -175,24 +170,24 @@ class CasinoBot
$wildcard = $clone;
}
if(array_key_exists($x,$command)) {
if($command[$x] == "donations") {
if (array_key_exists($x, $command)) {
if ($command[$x] == 'donations') {
$log = $this->getDonations($params);
}
if($command[$x] == "donate") {
$log = $this->putDonate($params,$wildcard);
if ($command[$x] == 'donate') {
$log = $this->putDonate($params, $wildcard);
}
}
$this->targeted = $targeted;
$this->type = $type;
$this->message = $message;
$this->log = $log;
return $this->pm();
}
/**
* Output Message
*
* Output Message.
*/
public function pm()
{
@@ -202,15 +197,14 @@ class CasinoBot
$message = $this->message;
$targeted = $this->targeted;
if($targeted) {
if ($targeted) {
// future holder
}
if($type == 'message' || $type == 'private') {
if ($type == 'message' || $type == 'private') {
$receiver_dirty = 0;
$receiver_echoes = cache()->get('user-echoes' . $target->id);
if (!$receiver_echoes || !is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = cache()->get('user-echoes'.$target->id);
if (! $receiver_echoes || ! is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$target->id])->get();
}
$receiver_listening = false;
@@ -219,7 +213,7 @@ class CasinoBot
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserEcho();
$receiver_port->user_id = $target->id;
$receiver_port->bot_id = $this->bot->id;
@@ -229,12 +223,12 @@ class CasinoBot
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $target->id, $receiver_echoes, $expiresAt);
event(New Chatter('echo', $target->id, UserEchoResource::collection($receiver_echoes)));
cache()->put('user-echoes'.$target->id, $receiver_echoes, $expiresAt);
event(new Chatter('echo', $target->id, UserEchoResource::collection($receiver_echoes)));
}
$receiver_dirty = 0;
$receiver_audibles = cache()->get('user-audibles' . $target->id);
if (!$receiver_audibles || !is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = cache()->get('user-audibles'.$target->id);
if (! $receiver_audibles || ! is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$target->id])->get();
}
$receiver_listening = false;
@@ -243,7 +237,7 @@ class CasinoBot
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserAudible();
$receiver_port->user_id = $target->id;
$receiver_port->bot_id = $this->bot->id;
@@ -253,8 +247,8 @@ class CasinoBot
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $target->id, $receiver_audibles, $expiresAt);
event(New Chatter('audible', $target->id, UserAudibleResource::collection($receiver_audibles)));
cache()->put('user-audibles'.$target->id, $receiver_audibles, $expiresAt);
event(new Chatter('audible', $target->id, UserAudibleResource::collection($receiver_audibles)));
}
if ($txt != '') {
@@ -262,21 +256,24 @@ class CasinoBot
$message = $this->chat->privateMessage($target->id, $room_id, $message, 1, $this->bot->id);
$message = $this->chat->privateMessage(1, $room_id, $txt, $target->id, $this->bot->id);
}
return response('success', 200);
} else if($type == 'echo') {
return response('success', 200);
} elseif ($type == 'echo') {
if ($txt != '') {
$room_id = 0;
$message = $this->chat->botMessage($this->bot->id, $room_id, $txt, $target->id);
}
return response('success', 200);
} else if($type == 'public') {
} elseif ($type == 'public') {
if ($txt != '') {
$dumproom = $this->chat->message($target->id, $target->chatroom->id, $message, null, null);
$dumproom = $this->chat->message(1, $target->chatroom->id, $txt, null, $this->bot->id);
}
return response('success', 200);
}
return true;
}
}
}
+133 -147
View File
@@ -1,6 +1,6 @@
<?php
/**
* NOTICE OF LICENSE
* NOTICE OF LICENSE.
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
@@ -9,26 +9,26 @@
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author singularity43
*/
namespace App\Bots;
use App\Torrent;
use App\User;
use App\Bot;
use App\BotTransaction;
use App\Warning;
use App\Ban;
use App\Bot;
use App\Peer;
use App\User;
use App\Torrent;
use App\Warning;
use App\UserEcho;
use App\UserAudible;
use App\Events\Chatter;
use Carbon\Carbon;
use App\Http\Resources\UserAudibleResource;
use App\Http\Resources\UserEchoResource;
use App\UserAudible;
use App\BotTransaction;
use App\Events\Chatter;
use App\Repositories\ChatRepository;
use App\Http\Resources\UserEchoResource;
use App\Http\Resources\UserAudibleResource;
class NerdBot
{
private $bot;
private $chat;
private $target;
@@ -46,7 +46,7 @@ class NerdBot
*/
public function __construct(ChatRepository $chat)
{
$bot = Bot::where('id','=','2')->firstOrFail();
$bot = Bot::where('id', '=', '2')->firstOrFail();
$this->chat = $chat;
$this->bot = $bot;
$this->expiresAt = Carbon::now()->addMinutes(60);
@@ -54,218 +54,206 @@ class NerdBot
}
/**
* Replace Vars
*
* Replace Vars.
*/
public function replaceVars($output)
{
$output=str_replace("{me}",$this->bot->name,$output);
$output=str_replace("{command}",$this->bot->command,$output);
if(strstr($output,"{bots}")) {
$bot_help = "";
$bots = Bot::where('active','=',1)->where('id','!=',$this->bot->id)->orderBy('position','asc')->get();
foreach($bots as $bot) {
$bot_help.="( ! | / | @)".$bot->command." help triggers help file for ".$bot->name."\n";
$output = str_replace('{me}', $this->bot->name, $output);
$output = str_replace('{command}', $this->bot->command, $output);
if (strstr($output, '{bots}')) {
$bot_help = '';
$bots = Bot::where('active', '=', 1)->where('id', '!=', $this->bot->id)->orderBy('position', 'asc')->get();
foreach ($bots as $bot) {
$bot_help .= '( ! | / | @)'.$bot->command.' help triggers help file for '.$bot->name."\n";
}
$output=str_replace("{bots}",$bot_help,$output);
$output = str_replace('{bots}', $bot_help, $output);
}
return $output;
}
/**
* Get Banker
*
* Get Banker.
*/
public function getBanker($duration = 'default')
{
$banker = cache()->get('nerdbot-banker');
if(!$banker || $banker == null) {
if (! $banker || $banker == null) {
$banker = User::latest('seedbonus')->first();
cache()->put('nerdbot-banker', $banker, $this->expiresAt);
}
return "Currently [url=/{$banker->slug}.{$banker->id}]{$banker->username}[/url] Is The Top BON Holder On ".config('other.title')."!";
return "Currently [url=/{$banker->slug}.{$banker->id}]{$banker->username}[/url] Is The Top BON Holder On ".config('other.title').'!';
}
/**
* Get Snatched
*
* Get Snatched.
*/
public function getSnatched($duration = 'default')
{
$snatched = cache()->get('nerdbot-snatched');
if(!$snatched || $snatched == null) {
if (! $snatched || $snatched == null) {
$snatched = Torrent::latest('times_completed')->first();
cache()->put('nerdbot-snatched', $snatched, $this->expiresAt);
}
return "Currently [url=/torrents/{$snatched->slug}.{$snatched->id}]{$snatched->name}[/url] Is The Most Snatched Torrent On ".config('other.title')."!";
return "Currently [url=/torrents/{$snatched->slug}.{$snatched->id}]{$snatched->name}[/url] Is The Most Snatched Torrent On ".config('other.title').'!';
}
/**
* Get Leeched
*
* Get Leeched.
*/
public function getLeeched($duration = 'default')
{
$leeched = cache()->get('nerdbot-leeched');
if(!$leeched || $leeched == null) {
if (! $leeched || $leeched == null) {
$leeched = Torrent::latest('leechers')->first();
cache()->put('nerdbot-leeched', $leeched, $this->expiresAt);
}
return "Currently [url=/torrents/{$leeched->slug}.{$leeched->id}]{$leeched->name}[/url] Is The Most Leeched Torrent On ".config('other.title')."!";
return "Currently [url=/torrents/{$leeched->slug}.{$leeched->id}]{$leeched->name}[/url] Is The Most Leeched Torrent On ".config('other.title').'!';
}
/**
* Get Seeded
*
* Get Seeded.
*/
public function getSeeded($duration = 'default')
{
$seeded = cache()->get('nerdbot-seeded');
if(!$seeded || $seeded == null) {
if (! $seeded || $seeded == null) {
$seeded = Torrent::latest('seeders')->first();
cache()->put('nerdbot-seeded', $seeded, $this->expiresAt);
}
return "Currently [url=/torrents/{$seeded->slug}.{$seeded->id}]{$seeded->name}[/url] Is The Most Seeded Torrent On ".config('other.title')."!";
return "Currently [url=/torrents/{$seeded->slug}.{$seeded->id}]{$seeded->name}[/url] Is The Most Seeded Torrent On ".config('other.title').'!';
}
/**
* Get FL
*
* Get FL.
*/
public function getFreeleech($duration = 'default')
{
$fl = cache()->get('nerdbot-fl');
if(!$fl || $fl == null) {
if (! $fl || $fl == null) {
$fl = Torrent::where('free', '=', 1)->count();
cache()->put('nerdbot-fl', $fl, $this->expiresAt);
}
return "There Are Currently {$fl} Freeleech Torrents On ".config('other.title')."!";
return "There Are Currently {$fl} Freeleech Torrents On ".config('other.title').'!';
}
/**
* Get DU
*
* Get DU.
*/
public function getDoubleUpload($duration = 'default')
{
$du = cache()->get('nerdbot-doubleup');
if(!$du || $du == null) {
if (! $du || $du == null) {
$du = Torrent::where('doubleup', '=', 1)->count();
cache()->put('nerdbot-doubleup', $du, $this->expiresAt);
}
return "There Are Currently {$du} Double Upload Torrents On ".config('other.title')."!";
return "There Are Currently {$du} Double Upload Torrents On ".config('other.title').'!';
}
/**
* Get Peers
*
* Get Peers.
*/
public function getPeers($duration = 'default')
{
$peers = cache()->get('nerdbot-peers');
if(!$peers || $peers == null) {
if (! $peers || $peers == null) {
$peers = Peer::count();
cache()->put('nerdbot-peers', $peers, $this->expiresAt);
}
return "Currently There Are {$peers} Peers On ".config('other.title')."!";
return "Currently There Are {$peers} Peers On ".config('other.title').'!';
}
/**
* Get Bans
*
* Get Bans.
*/
public function getBans($duration = 'default')
{
$bans = cache()->get('nerdbot-bans');
if(!$bans || $bans == null) {
if (! $bans || $bans == null) {
$bans = Ban::whereNull('unban_reason')->whereNull('removed_at')->where('created_at', '>', $this->current->subDay())->count();
cache()->put('nerdbot-bans', $bans, $this->expiresAt);
}
return "In The Last 24 Hours {$bans} Users Have Been Banned From ".config('other.title')."!";
return "In The Last 24 Hours {$bans} Users Have Been Banned From ".config('other.title').'!';
}
/**
* Get Warnings
*
* Get Warnings.
*/
public function getWarnings($duration = 'default')
{
$warnings = cache()->get('nerdbot-warnings');
if(!$warnings || $warnings == null) {
if (! $warnings || $warnings == null) {
$warnings = Warning::where('created_at', '>', $this->current->subDay())->count();
cache()->put('nerdbot-warnings', $warnings, $this->expiresAt);
}
return "In The Last 24 Hours {$warnings} Hit and Run Warnings Have Been Issued On ".config('other.title')."!";
return "In The Last 24 Hours {$warnings} Hit and Run Warnings Have Been Issued On ".config('other.title').'!';
}
/**
* Get Uploads
*
* Get Uploads.
*/
public function getUploads($duration = 'default')
{
$uploads = cache()->get('nerdbot-uploads');
if(!$uploads || $uploads == null) {
if (! $uploads || $uploads == null) {
$uploads = Torrent::where('created_at', '>', $this->current->subDay())->count();
cache()->put('nerdbot-uploads', $uploads, $this->expiresAt);
}
return "In The Last 24 Hours {$uploads} Torrents Have Been Uploaded To ".config('other.title')."!";
return "In The Last 24 Hours {$uploads} Torrents Have Been Uploaded To ".config('other.title').'!';
}
/**
* Get Logins
*
* Get Logins.
*/
public function getLogins($duration = 'default')
{
$logins = cache()->get('nerdbot-logins');
if(!$logins || $logins == null) {
if (! $logins || $logins == null) {
$logins = User::whereNotNull('last_login')->where('last_login', '>', $this->current->subDay())->count();
cache()->put('nerdbot-logins', $logins, $this->expiresAt);
}
return "In The Last 24 Hours {$logins} Unique Users Have Logged Into ".config('other.title')."!";
return "In The Last 24 Hours {$logins} Unique Users Have Logged Into ".config('other.title').'!';
}
/**
* Get Registrations
*
* Get Registrations.
*/
public function getRegistrations($duration = 'default')
{
$registrations = cache()->get('nerdbot-users');
if(!$registrations || $registrations == null) {
if (! $registrations || $registrations == null) {
$users = User::where('created_at', '>', $this->current->subDay())->count();
cache()->put('nerdbot-users', $users, $this->expiresAt);
}
return "In The Last 24 Hours {$users} Users Have Registered To ".config('other.title')."!";
return "In The Last 24 Hours {$users} Users Have Registered To ".config('other.title').'!';
}
/**
* Get Bot Donations
*
* Get Bot Donations.
*/
public function getDonations($duration = 'default')
{
$donations = cache()->get('nerdbot-donations');
if(!$donations|| $donations == null) {
$donations = BotTransaction::with('user','bot')->where('to_bot','=',1)->latest()->limit(10)->get();
if (! $donations || $donations == null) {
$donations = BotTransaction::with('user', 'bot')->where('to_bot', '=', 1)->latest()->limit(10)->get();
cache()->put('nerdbot-donations', $donations, $this->expiresAt);
}
$donation_dump = "";
$donation_dump = '';
$i = 1;
foreach($donations as $donation) {
$donation_dump .= "#" . $i . ". " . $donation->user->username . " sent " . $donation->bot->name . " ".$donation->cost." ".$donation->forHumans().".\n";
foreach ($donations as $donation) {
$donation_dump .= '#'.$i.'. '.$donation->user->username.' sent '.$donation->bot->name.' '.$donation->cost.' '.$donation->forHumans().".\n";
$i++;
}
@@ -273,8 +261,7 @@ class NerdBot
}
/**
* Get Help
*
* Get Help.
*/
public function getHelp()
{
@@ -282,8 +269,7 @@ class NerdBot
}
/**
* Get King
*
* Get King.
*/
public function getKing()
{
@@ -291,19 +277,17 @@ class NerdBot
}
/**
* Send Bot Donation
*
* Send Bot Donation.
*/
public function putDonate($amount = 0,$note = '')
public function putDonate($amount = 0, $note = '')
{
$output = implode(" ",$note);
$output = implode(' ', $note);
$v = validator(['bot_id' => $this->bot->id, 'amount'=> $amount, 'note'=> $output], [
'bot_id' => 'required|exists:bots,id|max:999',
'amount' => "required|numeric|min:1|max:{$this->target->seedbonus}",
'note' => 'required|string',
]);
if ($v->passes()) {
$value = $amount;
$this->bot->seedbonus += $value;
$this->bot->save();
@@ -320,22 +304,22 @@ class NerdBot
$transaction->comment = $output;
$transaction->save();
$donations = BotTransaction::with('user','bot')->where('bot_id','=',$this->bot->id)->where('to_bot','=',1)->latest()->limit(10)->get();
$donations = BotTransaction::with('user', 'bot')->where('bot_id', '=', $this->bot->id)->where('to_bot', '=', 1)->latest()->limit(10)->get();
cache()->put('casinobot-donations', $donations, $this->expiresAt);
return "Your donation to ".$this->bot->name." for ".$amount." BON has been sent!";
return 'Your donation to '.$this->bot->name.' for '.$amount.' BON has been sent!';
}
return "Your donation to ".$output." could not be sent.";
return 'Your donation to '.$output.' could not be sent.';
}
/**
* Process Message
*
* Process Message.
*/
public function process($type, User $target, $message = "", $targeted = 0)
public function process($type, User $target, $message = '', $targeted = 0)
{
$this->target = $target;
if($type == 'message') {
if ($type == 'message') {
$x = 0;
$y = 1;
$z = 2;
@@ -345,20 +329,20 @@ class NerdBot
$z = 3;
}
if($message == "") {
$log = "";
if ($message == '') {
$log = '';
} else {
$log = "All ".$this->bot->name." commands must be a private message or begin with /".$this->bot->command." or !".$this->bot->command.". Need help? Type /".$this->bot->command." help and you shall be helped.";
$log = 'All '.$this->bot->name.' commands must be a private message or begin with /'.$this->bot->command.' or !'.$this->bot->command.'. Need help? Type /'.$this->bot->command.' help and you shall be helped.';
}
$command = @explode(" ",$message);
$command = @explode(' ', $message);
$wildcard = null;
$params = null;
if(array_key_exists($y,$command)) {
if (array_key_exists($y, $command)) {
$params = $command[$y];
}
if($params != null) {
if ($params != null) {
$clone = $command;
array_shift($clone);
array_shift($clone);
@@ -366,56 +350,56 @@ class NerdBot
$wildcard = $clone;
}
if(array_key_exists($x,$command)) {
if($command[$x] == "banker") {
if (array_key_exists($x, $command)) {
if ($command[$x] == 'banker') {
$log = $this->getBanker($params);
}
if($command[$x] == "bankers") {
if ($command[$x] == 'bankers') {
$log = $this->getBankers($params);
}
if($command[$x] == "bans") {
if ($command[$x] == 'bans') {
$log = $this->getBans($params);
}
if($command[$x] == "donations") {
if ($command[$x] == 'donations') {
$log = $this->getDonations($params);
}
if($command[$x] == "donate") {
$log = $this->putDonate($params,$wildcard);
if ($command[$x] == 'donate') {
$log = $this->putDonate($params, $wildcard);
}
if($command[$x] == "doubleupload") {
if ($command[$x] == 'doubleupload') {
$log = $this->getDoubleUpload($params);
}
if($command[$x] == "freeleech") {
if ($command[$x] == 'freeleech') {
$log = $this->getFreeleech($params);
}
if($command[$x] == "help") {
if ($command[$x] == 'help') {
$log = $this->getHelp();
}
if($command[$x] == "king") {
if ($command[$x] == 'king') {
$log = $this->getKing();
}
if($command[$x] == "logins") {
if ($command[$x] == 'logins') {
$log = $this->getLogins($params);
}
if($command[$x] == "peers") {
if ($command[$x] == 'peers') {
$log = $this->getPeers($params);
}
if($command[$x] == "registrations") {
if ($command[$x] == 'registrations') {
$log = $this->getRegistrations($params);
}
if($command[$x] == "uploads") {
if ($command[$x] == 'uploads') {
$log = $this->getUploads($params);
}
if($command[$x] == "warnings") {
if ($command[$x] == 'warnings') {
$log = $this->getWarnings($params);
}
if($command[$x] == "seeded") {
if ($command[$x] == 'seeded') {
$log = $this->getSeeded($params);
}
if($command[$x] == "leeched") {
if ($command[$x] == 'leeched') {
$log = $this->getLeeched($params);
}
if($command[$x] == "snatched") {
if ($command[$x] == 'snatched') {
$log = $this->getSnatched($params);
}
}
@@ -423,12 +407,12 @@ class NerdBot
$this->type = $type;
$this->message = $message;
$this->log = $log;
return $this->pm();
}
/**
* Output Message
*
* Output Message.
*/
public function pm()
{
@@ -438,15 +422,14 @@ class NerdBot
$message = $this->message;
$targeted = $this->targeted;
if($targeted) {
if ($targeted) {
// future holder
}
if($type == 'message' || $type == 'private') {
if ($type == 'message' || $type == 'private') {
$receiver_dirty = 0;
$receiver_echoes = cache()->get('user-echoes' . $target->id);
if (!$receiver_echoes || !is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = cache()->get('user-echoes'.$target->id);
if (! $receiver_echoes || ! is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$target->id])->get();
}
$receiver_listening = false;
@@ -455,7 +438,7 @@ class NerdBot
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserEcho();
$receiver_port->user_id = $target->id;
$receiver_port->bot_id = $this->bot->id;
@@ -465,12 +448,12 @@ class NerdBot
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $target->id, $receiver_echoes, $expiresAt);
event(New Chatter('echo', $target->id, UserEchoResource::collection($receiver_echoes)));
cache()->put('user-echoes'.$target->id, $receiver_echoes, $expiresAt);
event(new Chatter('echo', $target->id, UserEchoResource::collection($receiver_echoes)));
}
$receiver_dirty = 0;
$receiver_audibles = cache()->get('user-audibles' . $target->id);
if (!$receiver_audibles || !is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = cache()->get('user-audibles'.$target->id);
if (! $receiver_audibles || ! is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$target->id])->get();
}
$receiver_listening = false;
@@ -479,7 +462,7 @@ class NerdBot
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserAudible();
$receiver_port->user_id = $target->id;
$receiver_port->bot_id = $this->bot->id;
@@ -489,8 +472,8 @@ class NerdBot
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $target->id, $receiver_audibles, $expiresAt);
event(New Chatter('audible', $target->id, UserAudibleResource::collection($receiver_audibles)));
cache()->put('user-audibles'.$target->id, $receiver_audibles, $expiresAt);
event(new Chatter('audible', $target->id, UserAudibleResource::collection($receiver_audibles)));
}
if ($txt != '') {
@@ -498,21 +481,24 @@ class NerdBot
$message = $this->chat->privateMessage($target->id, $room_id, $message, 1, $this->bot->id);
$message = $this->chat->privateMessage(1, $room_id, $txt, $target->id, $this->bot->id);
}
return response('success', 200);
} else if($type == 'echo') {
return response('success', 200);
} elseif ($type == 'echo') {
if ($txt != '') {
$room_id = 0;
$message = $this->chat->botMessage($this->bot->id, $room_id, $txt, $target->id);
}
return response('success', 200);
} else if($type == 'public') {
} elseif ($type == 'public') {
if ($txt != '') {
$dumproom = $this->chat->message($target->id, $target->chatroom->id, $message, null, null);
$dumproom = $this->chat->message(1, $target->chatroom->id, $txt, null, $this->bot->id);
}
return response('success', 200);
}
return true;
}
}
}
+61 -62
View File
@@ -1,6 +1,6 @@
<?php
/**
* NOTICE OF LICENSE
* NOTICE OF LICENSE.
*
* UNIT3D is open-sourced software licensed under the GNU General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
@@ -9,23 +9,23 @@
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author singularity43
*/
namespace App\Bots;
use App\User;
use App\Bot;
use App\User;
use App\UserEcho;
use Carbon\Carbon;
use App\UserAudible;
use App\Events\Chatter;
use Carbon\Carbon;
use App\Notifications\NewBon;
use App\BonTransactions;
use App\Http\Resources\UserAudibleResource;
use App\Http\Resources\UserEchoResource;
use App\Notifications\NewBon;
use App\Repositories\ChatRepository;
use App\Http\Resources\UserEchoResource;
use App\Http\Resources\UserAudibleResource;
class SystemBot
{
private $bot;
private $chat;
private $target;
@@ -41,34 +41,32 @@ class SystemBot
*/
public function __construct(ChatRepository $chat)
{
$bot = Bot::where('id','=','1')->firstOrFail();
$bot = Bot::where('id', '=', '1')->firstOrFail();
$this->chat = $chat;
$this->bot = $bot;
}
/**
* Replace Vars
*
* Replace Vars.
*/
public function replaceVars($output)
{
$output=str_replace("{me}",$this->bot->name,$output);
$output=str_replace("{command}",$this->bot->command,$output);
if(strstr($output,"{bots}")) {
$bot_help = "";
$bots = Bot::where('active','=',1)->where('id','!=',$this->bot->id)->orderBy('position','asc')->get();
foreach($bots as $bot) {
$bot_help.="( ! | / | @)".$bot->command." help triggers help file for ".$bot->name."\n";
$output = str_replace('{me}', $this->bot->name, $output);
$output = str_replace('{command}', $this->bot->command, $output);
if (strstr($output, '{bots}')) {
$bot_help = '';
$bots = Bot::where('active', '=', 1)->where('id', '!=', $this->bot->id)->orderBy('position', 'asc')->get();
foreach ($bots as $bot) {
$bot_help .= '( ! | / | @)'.$bot->command.' help triggers help file for '.$bot->name."\n";
}
$output=str_replace("{bots}",$bot_help,$output);
$output = str_replace('{bots}', $bot_help, $output);
}
return $output;
}
/**
* Get Help
*
* Get Help.
*/
public function getHelp()
{
@@ -76,23 +74,21 @@ class SystemBot
}
/**
* Send Gift
*
* Send Gift.
*/
public function putGift($receiver = "",$amount = 0,$note = '')
public function putGift($receiver = '', $amount = 0, $note = '')
{
$output = implode(" ",$note);
$output = implode(' ', $note);
$v = validator(['receiver' => $receiver, 'amount'=> $amount, 'note'=> $output], [
'receiver' => 'required|string|exists:users,username',
'amount' => "required|numeric|min:1|max:{$this->target->seedbonus}",
'note' => 'required|string',
]);
if ($v->passes()) {
$recipient = User::where('username', 'LIKE',$receiver)->first();
$recipient = User::where('username', 'LIKE', $receiver)->first();
if (! $recipient || $recipient->id == $this->target->id) {
return "Your BON gift could not be sent.";
return 'Your BON gift could not be sent.';
}
$value = $amount;
@@ -124,43 +120,44 @@ class SystemBot
$this->chat->systemMessage(
"[url={$profile_url}]{$this->target->username}[/url] has gifted {$value} BON to [url={$recipient_url}]{$recipient->username}[/url]"
);
return "Your gift to ".$recipient->username." for ".$amount." BON has been sent!";
return 'Your gift to '.$recipient->username.' for '.$amount.' BON has been sent!';
}
return "Your BON gift could not be sent.";
return 'Your BON gift could not be sent.';
}
/**
* Process Message
*
* Process Message.
*/
public function process($type, User $target, $message = "", $targeted = 0)
public function process($type, User $target, $message = '', $targeted = 0)
{
$this->target = $target;
if($type == 'message') {
if ($type == 'message') {
$x = 0;
} else {
$x = 1;
}
$y = $x+1;
$z = $y+1;
$y = $x + 1;
$z = $y + 1;
if($message == "") {
$log = "";
if ($message == '') {
$log = '';
} else {
$log = "All ".$this->bot->name." commands must be a private message or begin with /".$this->bot->command." or !".$this->bot->command.". Need help? Type /".$this->bot->command." help and you shall be helped.";
$log = 'All '.$this->bot->name.' commands must be a private message or begin with /'.$this->bot->command.' or !'.$this->bot->command.'. Need help? Type /'.$this->bot->command.' help and you shall be helped.';
}
$command = @explode(" ",$message);
if(array_key_exists($x,$command)) {
if($command[$x] == "gift" && array_key_exists($y,$command) && array_key_exists($z,$command) && array_key_exists($z+1,$command)) {
$command = @explode(' ', $message);
if (array_key_exists($x, $command)) {
if ($command[$x] == 'gift' && array_key_exists($y, $command) && array_key_exists($z, $command) && array_key_exists($z + 1, $command)) {
$clone = $command;
array_shift($clone);
array_shift($clone);
array_shift($clone);
array_shift($clone);
$log = $this->putGift($command[$y],$command[$z],$clone);
$log = $this->putGift($command[$y], $command[$z], $clone);
}
if($command[$x] == "help") {
if ($command[$x] == 'help') {
$log = $this->getHelp();
}
}
@@ -168,12 +165,12 @@ class SystemBot
$this->type = $type;
$this->message = $message;
$this->log = $log;
return $this->pm();
}
/**
* Output Message
*
* Output Message.
*/
public function pm()
{
@@ -183,15 +180,14 @@ class SystemBot
$message = $this->message;
$targeted = $this->targeted;
if($targeted) {
if ($targeted) {
// future holder
}
if($type == 'message' || $type == 'private') {
if ($type == 'message' || $type == 'private') {
$receiver_dirty = 0;
$receiver_echoes = cache()->get('user-echoes' . $target->id);
if (!$receiver_echoes || !is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = cache()->get('user-echoes'.$target->id);
if (! $receiver_echoes || ! is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$target->id])->get();
}
$receiver_listening = false;
@@ -200,7 +196,7 @@ class SystemBot
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserEcho();
$receiver_port->user_id = $target->id;
$receiver_port->bot_id = $this->bot->id;
@@ -210,12 +206,12 @@ class SystemBot
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $target->id, $receiver_echoes, $expiresAt);
event(New Chatter('echo', $target->id, UserEchoResource::collection($receiver_echoes)));
cache()->put('user-echoes'.$target->id, $receiver_echoes, $expiresAt);
event(new Chatter('echo', $target->id, UserEchoResource::collection($receiver_echoes)));
}
$receiver_dirty = 0;
$receiver_audibles = cache()->get('user-audibles' . $target->id);
if (!$receiver_audibles || !is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = cache()->get('user-audibles'.$target->id);
if (! $receiver_audibles || ! is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$target->id])->get();
}
$receiver_listening = false;
@@ -224,7 +220,7 @@ class SystemBot
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserAudible();
$receiver_port->user_id = $target->id;
$receiver_port->bot_id = $this->bot->id;
@@ -234,8 +230,8 @@ class SystemBot
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $target->id, $receiver_audibles, $expiresAt);
event(New Chatter('audible', $target->id, UserAudibleResource::collection($receiver_audibles)));
cache()->put('user-audibles'.$target->id, $receiver_audibles, $expiresAt);
event(new Chatter('audible', $target->id, UserAudibleResource::collection($receiver_audibles)));
}
if ($txt != '') {
@@ -243,21 +239,24 @@ class SystemBot
$message = $this->chat->privateMessage($target->id, $room_id, $message, 1, $this->bot->id);
$message = $this->chat->privateMessage(1, $room_id, $txt, $target->id, $this->bot->id);
}
return response('success', 200);
} else if($type == 'echo') {
return response('success', 200);
} elseif ($type == 'echo') {
if ($txt != '') {
$room_id = 0;
$message = $this->chat->botMessage($this->bot->id, $room_id, $txt, $target->id);
}
return response('success', 200);
} else if($type == 'public') {
} elseif ($type == 'public') {
if ($txt != '') {
$dumproom = $this->chat->message($target->id, $target->chatroom->id, $message, null, null);
$dumproom = $this->chat->message(1, $target->chatroom->id, $txt, null, $this->bot->id);
}
return response('success', 200);
}
return true;
}
}
}
-1
View File
@@ -17,7 +17,6 @@ use Illuminate\Database\Eloquent\Model;
class ChatStatus extends Model
{
/**
* The Database Table Used By The Model.
*
+2 -3
View File
@@ -16,9 +16,9 @@ namespace App\Console\Commands;
use App\Ban;
use App\Peer;
use App\User;
use Carbon\Carbon;
use App\Torrent;
use App\Warning;
use Carbon\Carbon;
use Illuminate\Console\Command;
use App\Repositories\ChatRepository;
@@ -58,7 +58,6 @@ class AutoNerdStat extends Command
public function handle()
{
if (config('chat.nerd_bot') == true) {
$expiresAt = Carbon::now()->addMinutes(60);
// Current Timestamp
@@ -135,7 +134,7 @@ class AutoNerdStat extends Command
$selected = mt_rand(0, count($statArray) - 1);
// Auto Shout Nerd Stat
$this->chat->systemMessage("{$statArray[$selected]}",2);
$this->chat->systemMessage("{$statArray[$selected]}", 2);
}
}
}
+6 -7
View File
@@ -45,15 +45,15 @@ class Chatter implements ShouldBroadcastNow
public function __construct($type, $target, $payload)
{
$this->type = $type;
if($type == 'echo') {
if ($type == 'echo') {
$this->echoes = $payload;
} else if($type == 'audible') {
} elseif ($type == 'audible') {
$this->audibles = $payload;
} else if($type == 'new.message') {
} elseif ($type == 'new.message') {
$this->message = $payload;
} else if($type == 'new.bot') {
} elseif ($type == 'new.bot') {
$this->message = $payload;
} else if($type == 'new.ping') {
} elseif ($type == 'new.ping') {
$this->ping = $payload;
}
$this->target = $target;
@@ -70,5 +70,4 @@ class Chatter implements ShouldBroadcastNow
return new PrivateChannel('chatter.'.$this->target);
}
}
}
+1 -1
View File
@@ -40,7 +40,7 @@ class MessageEdited implements ShouldBroadcastNow
*/
public function __construct(Message $message)
{
$message = Message::with(['bot','user.group', 'user.chatStatus'])->find($message->id);
$message = Message::with(['bot', 'user.group', 'user.chatStatus'])->find($message->id);
$this->message = new ChatMessageResource($message);
}
+1 -1
View File
@@ -45,7 +45,7 @@ class MessageSent implements ShouldBroadcastNow
'user.group',
'user.chatStatus',
'receiver.group',
'receiver.chatStatus'
'receiver.chatStatus',
])->find($message->id);
$this->message = new ChatMessageResource($message);
-1
View File
@@ -15,7 +15,6 @@ namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use App\Http\Resources\ChatMessageResource;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Broadcasting\InteractsWithSockets;
+110 -106
View File
@@ -15,22 +15,22 @@ namespace App\Http\Controllers\API;
use App\Bot;
use App\User;
use App\UserAudible;
use App\UserEcho;
use App\Events\Chatter;
use App\Bots\SystemBot;
use Carbon\Carbon;
use App\UserAudible;
use App\Bots\NerdBot;
use App\Bots\CasinoBot;
use Carbon\Carbon;
use App\Bots\SystemBot;
use App\Events\Chatter;
use Illuminate\Http\Request;
use Illuminate\Auth\AuthManager;
use App\Http\Resources\BotResource;
use App\Http\Controllers\Controller;
use App\Repositories\ChatRepository;
use App\Http\Resources\BotResource;
use App\Http\Resources\UserAudibleResource;
use App\Http\Resources\UserEchoResource;
use App\Http\Resources\ChatRoomResource;
use App\Http\Resources\UserEchoResource;
use App\Http\Resources\ChatMessageResource;
use App\Http\Resources\UserAudibleResource;
class ChatController extends Controller
{
@@ -61,7 +61,7 @@ class ChatController extends Controller
{
$user = User::with(['echoes'])->findOrFail($this->auth->user()->id);
if(!$user->echoes || count($user->echoes->toArray()) < 1) {
if (! $user->echoes || count($user->echoes->toArray()) < 1) {
$echoes = new UserEcho();
$echoes->user_id = $this->auth->user()->id;
$echoes->room_id = 1;
@@ -74,10 +74,9 @@ class ChatController extends Controller
/* AUDIBLES */
public function audibles()
{
$user = User::with(['audibles'])->findOrFail($this->auth->user()->id);
if(!$user->audibles || count($user->audibles->toArray()) < 1) {
if (! $user->audibles || count($user->audibles->toArray()) < 1) {
$audibles = new UserAudible();
$audibles->user_id = $this->auth->user()->id;
$audibles->room_id = 1;
@@ -114,26 +113,25 @@ class ChatController extends Controller
/* MESSAGES */
public function privateMessages($target_id)
{
return ChatMessageResource::collection($this->chat->privateMessages($this->auth->user()->id,$target_id));
return ChatMessageResource::collection($this->chat->privateMessages($this->auth->user()->id, $target_id));
}
/* MESSAGES */
public function botMessages($bot_id)
{
$bot = Bot::where('id','=',$bot_id)->firstOrFail();
if($bot->is_systembot) {
$runbot = New SystemBot($this->chat);
}
else if($bot->is_nerdbot) {
$runbot = New NerdBot($this->chat);
$bot = Bot::where('id', '=', $bot_id)->firstOrFail();
if ($bot->is_systembot) {
$runbot = new SystemBot($this->chat);
} elseif ($bot->is_nerdbot) {
$runbot = new NerdBot($this->chat);
}
$runbot->process('message', $this->auth->user(), '', 0);
return ChatMessageResource::collection($this->chat->botMessages($this->auth->user()->id,$bot->id));
return ChatMessageResource::collection($this->chat->botMessages($this->auth->user()->id, $bot->id));
}
public function createMessage(Request $request)
{
$user_id = (int) $request->input('user_id');
$receiver_id = $request->input('receiver_id');
$room_id = $request->input('chatroom_id');
@@ -155,91 +153,88 @@ class ChatController extends Controller
return response('error', 401);
}
$bots = Bot::where('active','=',1)->orderBy('position','asc')->get();
$bots = Bot::where('active', '=', 1)->orderBy('position', 'asc')->get();
$which = null;
$target = null;
$runbot = null;
$trip = "msg";
if ($message && substr($message, 0, 1 + (strlen($trip))) == "/" . $trip) {
$trip = 'msg';
if ($message && substr($message, 0, 1 + (strlen($trip))) == '/'.$trip) {
$which = 'skip';
$command = @explode(" ",$message);
if(array_key_exists(1,$command)) {
$receiver = User::where('username','like',$command[1])->firstOrFail();
$command = @explode(' ', $message);
if (array_key_exists(1, $command)) {
$receiver = User::where('username', 'like', $command[1])->firstOrFail();
$receiver_id = $receiver->id;
$clone = $command;
array_shift($clone);
array_shift($clone);
$message = trim(implode(" ",$clone));
$message = trim(implode(' ', $clone));
}
$bot_id = 1;
}
$trip = "gift";
if ($message && substr($message, 0, 1 + (strlen($trip))) == "/" . $trip) {
$trip = 'gift';
if ($message && substr($message, 0, 1 + (strlen($trip))) == '/'.$trip) {
$which = 'echo';
$target = 'system';
$message = "/bot gift".substr($message,strlen($trip)+1,strlen($message));
$message = '/bot gift'.substr($message, strlen($trip) + 1, strlen($message));
}
if($target == 'system') {
$runbot = New SystemBot($this->chat);
if ($target == 'system') {
$runbot = new SystemBot($this->chat);
}
if($which == null) {
if ($which == null) {
foreach ($bots as $bot) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == "/" . $bot->command) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == '/'.$bot->command) {
$which = 'echo';
}
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == "!" . $bot->command) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == '!'.$bot->command) {
$which = 'public';
}
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == "@" . $bot->command) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == '@'.$bot->command) {
$message = substr($message, 1 + strlen($bot->command), strlen($message));
$which = 'private';
}
if ($message && $receiver_id == 1 && $bot->id == $bot_id) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == "/" . $bot->command) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == '/'.$bot->command) {
$message = substr($message, 1 + strlen($bot->command), strlen($message));
}
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == "!" . $bot->command) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == '!'.$bot->command) {
$message = substr($message, 1 + strlen($bot->command), strlen($message));
}
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == "@" . $bot->command) {
if ($message && substr($message, 0, 1 + (strlen($bot->command))) == '@'.$bot->command) {
$message = substr($message, 1 + strlen($bot->command), strlen($message));
}
$which = 'message';
}
if($which != null) {
if ($which != null) {
break;
}
}
}
if($which != null && $which != 'skip' && !$runbot) {
if($bot->is_systembot) {
$runbot = New SystemBot($this->chat);
}
else if($bot->is_nerdbot) {
$runbot = New NerdBot($this->chat);
}
else if($bot->is_casinobot) {
$runbot = New CasinoBot($this->chat);
if ($which != null && $which != 'skip' && ! $runbot) {
if ($bot->is_systembot) {
$runbot = new SystemBot($this->chat);
} elseif ($bot->is_nerdbot) {
$runbot = new NerdBot($this->chat);
} elseif ($bot->is_casinobot) {
$runbot = new CasinoBot($this->chat);
}
}
if($runbot) {
if ($runbot) {
return $runbot->process($which, $this->auth->user(), $message, 0);
}
$echo = false;
if($receiver_id && $receiver_id > 0) {
if ($receiver_id && $receiver_id > 0) {
$sender_dirty = 0;
$receiver_dirty = 0;
$sender_echoes = cache()->get('user-echoes' . $user_id);
$receiver_echoes = cache()->get('user-echoes' . $receiver_id);
if (!$sender_echoes || !is_array($sender_echoes) || count($sender_echoes) < 1) {
$sender_echoes = UserEcho::with(['room', 'target','bot'])->whereRaw('user_id = ?', [$user_id])->get();
$sender_echoes = cache()->get('user-echoes'.$user_id);
$receiver_echoes = cache()->get('user-echoes'.$receiver_id);
if (! $sender_echoes || ! is_array($sender_echoes) || count($sender_echoes) < 1) {
$sender_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
}
if (!$receiver_echoes || !is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = UserEcho::with(['room', 'target','bot'])->whereRaw('user_id = ?', [$receiver_id])->get();
if (! $receiver_echoes || ! is_array($receiver_echoes) || count($receiver_echoes) < 1) {
$receiver_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$receiver_id])->get();
}
$sender_listening = false;
foreach ($sender_echoes as $se => $sender_echo) {
@@ -247,12 +242,12 @@ class ChatController extends Controller
$sender_listening = true;
}
}
if (!$sender_listening) {
if (! $sender_listening) {
$sender_port = new UserEcho();
$sender_port->user_id = $user_id;
$sender_port->target_id = $receiver_id;
$sender_port->save();
$sender_echoes = UserEcho::with(['room', 'target','bot'])->whereRaw('user_id = ?', [$user_id])->get();
$sender_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$sender_dirty = 1;
}
$receiver_listening = false;
@@ -261,7 +256,7 @@ class ChatController extends Controller
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserEcho();
$receiver_port->user_id = $receiver_id;
$receiver_port->target_id = $user_id;
@@ -271,24 +266,24 @@ class ChatController extends Controller
}
if ($sender_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $user_id, $sender_echoes, $expiresAt);
event(New Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $receiver_id, $receiver_echoes, $expiresAt);
event(New Chatter('echo', $receiver_id, UserEchoResource::collection($receiver_echoes)));
cache()->put('user-echoes'.$receiver_id, $receiver_echoes, $expiresAt);
event(new Chatter('echo', $receiver_id, UserEchoResource::collection($receiver_echoes)));
}
$sender_dirty = 0;
$receiver_dirty = 0;
$sender_audibles = cache()->get('user-audibles' . $user_id);
$receiver_audibles = cache()->get('user-audibles' . $receiver_id);
if (!$sender_audibles || !is_array($sender_audibles) || count($sender_audibles) < 1) {
$sender_audibles = UserAudible::with(['room', 'target','bot'])->whereRaw('user_id = ?', [$user_id])->get();
$sender_audibles = cache()->get('user-audibles'.$user_id);
$receiver_audibles = cache()->get('user-audibles'.$receiver_id);
if (! $sender_audibles || ! is_array($sender_audibles) || count($sender_audibles) < 1) {
$sender_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
}
if (!$receiver_audibles || !is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = UserAudible::with(['room', 'target','bot'])->whereRaw('user_id = ?', [$receiver_id])->get();
if (! $receiver_audibles || ! is_array($receiver_audibles) || count($receiver_audibles) < 1) {
$receiver_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$receiver_id])->get();
}
$sender_listening = false;
foreach ($sender_audibles as $se => $sender_echo) {
@@ -296,13 +291,13 @@ class ChatController extends Controller
$sender_listening = true;
}
}
if (!$sender_listening) {
if (! $sender_listening) {
$sender_port = new UserAudible();
$sender_port->user_id = $user_id;
$sender_port->target_id = $receiver_id;
$sender_port->status = 0;
$sender_port->save();
$sender_audibles = UserAudible::with(['room', 'target','bot'])->whereRaw('user_id = ?', [$user_id])->get();
$sender_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$sender_dirty = 1;
}
$receiver_listening = false;
@@ -311,7 +306,7 @@ class ChatController extends Controller
$receiver_listening = true;
}
}
if (!$receiver_listening) {
if (! $receiver_listening) {
$receiver_port = new UserAudible();
$receiver_port->user_id = $receiver_id;
$receiver_port->target_id = $user_id;
@@ -322,36 +317,36 @@ class ChatController extends Controller
}
if ($sender_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $user_id, $sender_audibles, $expiresAt);
event(New Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
}
if ($receiver_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $receiver_id, $receiver_audibles, $expiresAt);
event(New Chatter('audible', $receiver_id, UserAudibleResource::collection($receiver_audibles)));
cache()->put('user-audibles'.$receiver_id, $receiver_audibles, $expiresAt);
event(new Chatter('audible', $receiver_id, UserAudibleResource::collection($receiver_audibles)));
}
$ignore = false;
$room_id = 0;
if($bot_id > 0) {
if ($bot_id > 0) {
$ignore = true;
}
$message = $this->chat->privateMessage($user_id, $room_id, $message, $receiver_id, null, $ignore);
}
else {
} else {
$receiver_id = null;
$bot_id = null;
$message = $this->chat->message($user_id, $room_id, $message, $receiver_id, $bot_id);
$this->chat->ping('room',$room_id);
$this->chat->ping('room', $room_id);
}
if (! $save) {
$message->delete();
}
if($save && $echo != false) {
if ($save && $echo != false) {
return new ChatMessageResource($message);
}
return response('success', 200);
}
@@ -364,7 +359,7 @@ class ChatController extends Controller
public function deleteRoomEcho(Request $request, $user_id)
{
$echo = UserEcho::where('user_id','=',$user_id)->where('room_id','=',$request->input('room_id'))->firstOrFail();
$echo = UserEcho::where('user_id', '=', $user_id)->where('room_id', '=', $request->input('room_id'))->firstOrFail();
$echo->delete();
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($user_id);
@@ -378,42 +373,45 @@ class ChatController extends Controller
$sender_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $user_id, $sender_echoes, $expiresAt);
event(New Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
return response($user, 200);
}
public function deleteTargetEcho(Request $request, $user_id)
{
$echo = UserEcho::where('user_id','=',$user_id)->where('target_id','=',$request->input('target_id'))->firstOrFail();
$echo = UserEcho::where('user_id', '=', $user_id)->where('target_id', '=', $request->input('target_id'))->firstOrFail();
$echo->delete();
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($user_id);
$sender_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $user_id, $sender_echoes, $expiresAt);
event(New Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
return response($user, 200);
}
public function deleteBotEcho(Request $request, $user_id)
{
$echo = UserEcho::where('user_id','=',$user_id)->where('bot_id','=',$request->input('bot_id'))->firstOrFail();
$echo = UserEcho::where('user_id', '=', $user_id)->where('bot_id', '=', $request->input('bot_id'))->firstOrFail();
$echo->delete();
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($user_id);
$sender_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $user_id, $sender_echoes, $expiresAt);
event(New Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
cache()->put('user-echoes'.$user_id, $sender_echoes, $expiresAt);
event(new Chatter('echo', $user_id, UserEchoResource::collection($sender_echoes)));
return response($user, 200);
}
public function toggleRoomAudible(Request $request, $user_id)
{
$echo = UserAudible::where('user_id','=',$user_id)->where('room_id','=',$request->input('room_id'))->firstOrFail();
$echo = UserAudible::where('user_id', '=', $user_id)->where('room_id', '=', $request->input('room_id'))->firstOrFail();
$echo->status = ($echo->status == 1 ? 0 : 1);
$echo->save();
@@ -421,14 +419,15 @@ class ChatController extends Controller
$sender_audibles = UserAudible::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $user_id, $sender_audibles, $expiresAt);
event(New Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
return response($user, 200);
}
public function toggleTargetAudible(Request $request, $user_id)
{
$echo = UserAudible::where('user_id','=',$user_id)->where('target_id','=',$request->input('target_id'))->firstOrFail();
$echo = UserAudible::where('user_id', '=', $user_id)->where('target_id', '=', $request->input('target_id'))->firstOrFail();
$echo->status = ($echo->status == 1 ? 0 : 1);
$echo->save();
@@ -436,14 +435,15 @@ class ChatController extends Controller
$sender_audibles = UserAudible::with(['target', 'room', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $user_id, $sender_audibles, $expiresAt);
event(New Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
return response($user, 200);
}
public function toggleBotAudible(Request $request, $user_id)
{
$echo = UserAudible::where('user_id','=',$user_id)->where('bot_id','=',$request->input('bot_id'))->firstOrFail();
$echo = UserAudible::where('user_id', '=', $user_id)->where('bot_id', '=', $request->input('bot_id'))->firstOrFail();
$echo->status = ($echo->status == 1 ? 0 : 1);
$echo->save();
@@ -451,8 +451,9 @@ class ChatController extends Controller
$sender_audibles = UserAudible::with(['bot', 'room', 'bot'])->whereRaw('user_id = ?', [$user_id])->get();
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-audibles' . $user_id, $sender_audibles, $expiresAt);
event(New Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
cache()->put('user-audibles'.$user_id, $sender_audibles, $expiresAt);
event(new Chatter('audible', $user_id, UserAudibleResource::collection($sender_audibles)));
return response($user, 200);
}
@@ -462,7 +463,7 @@ class ChatController extends Controller
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($id);
$status = $this->chat->statusFindOrFail($request->input('status_id'));
$log = "[url=/".$user->slug.".".$user->id."]".$user->username."[/url] has updated their status to [b]".$status->name."[/b]";
$log = '[url=/'.$user->slug.'.'.$user->id.']'.$user->username.'[/url] has updated their status to [b]'.$status->name.'[/b]';
$message = $this->chat->message(1, $user->chatroom->id, $log, null);
$message->save();
@@ -485,8 +486,8 @@ class ChatController extends Controller
$user->save();
$sender_dirty = 0;
$sender_echoes = cache()->get('user-echoes' . $id);
if (!$sender_echoes || !is_array($sender_echoes) || count($sender_echoes) < 1) {
$sender_echoes = cache()->get('user-echoes'.$id);
if (! $sender_echoes || ! is_array($sender_echoes) || count($sender_echoes) < 1) {
$sender_echoes = UserEcho::with(['room', 'target', 'bot'])->whereRaw('user_id = ?', [$id])->get();
}
$sender_listening = false;
@@ -495,7 +496,7 @@ class ChatController extends Controller
$sender_listening = true;
}
}
if (!$sender_listening) {
if (! $sender_listening) {
$sender_port = new UserEcho();
$sender_port->user_id = $id;
$sender_port->room_id = $room->id;
@@ -505,21 +506,24 @@ class ChatController extends Controller
}
if ($sender_dirty == 1) {
$expiresAt = Carbon::now()->addMinutes(60);
cache()->put('user-echoes' . $id, $sender_echoes, $expiresAt);
event(New Chatter('echo', $id, UserEchoResource::collection($sender_echoes)));
cache()->put('user-echoes'.$id, $sender_echoes, $expiresAt);
event(new Chatter('echo', $id, UserEchoResource::collection($sender_echoes)));
}
return response($user, 200);
}
public function updateUserTarget(Request $request, $id)
{
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($id);
return response($user, 200);
}
public function updateBotTarget(Request $request, $id)
{
$user = User::with(['chatStatus', 'chatroom', 'group', 'echoes'])->findOrFail($id);
return response($user, 200);
}
}
@@ -20,7 +20,6 @@ use App\Http\Controllers\Controller;
class BotsController extends Controller
{
/**
* @var Toastr
*/
@@ -42,7 +41,6 @@ class BotsController extends Controller
* @param string $hash
* @return \Illuminate\Http\Response
*/
public function index($hash = null)
{
$bots = Bot::orderBy('position', 'ASC')->get();
@@ -81,7 +79,7 @@ class BotsController extends Controller
$user = auth()->user();
$bot = Bot::findOrFail($id);
if($request->has('command') && $request->input('command') == $bot->command) {
if ($request->has('command') && $request->input('command') == $bot->command) {
$v = validator($request->all(), [
'name' => 'required|min:3|max:255',
'command' => 'required|alpha_dash|min:3|max:255',
@@ -93,8 +91,7 @@ class BotsController extends Controller
'info' => 'sometimes|max:9999',
'about' => 'sometimes|max:9999',
]);
}
else {
} else {
$v = validator($request->all(), [
'name' => 'required|min:3|max:255',
'command' => 'required|alpha_dash|min:3|max:255|unique:bots',
+2 -2
View File
@@ -31,10 +31,10 @@ class ChatMessageResource extends JsonResource
$emojiOne = app()->make(LaravelEmojiOne::class);
$logger = null;
if($this->user_id && $this->user_id == 1) {
if ($this->user_id && $this->user_id == 1) {
$logger = Bbcode::parse('[div class="align-left"][div class="chatTriggers"]'.clean($this->message).'[/div][/div]');
$logger = $emojiOne->toImage($logger);
$logger = str_replace("a href=\"/#","a trigger=\"bot\" class=\"chatTrigger\" href=\"/#",$logger);
$logger = str_replace('a href="/#', 'a trigger="bot" class="chatTrigger" href="/#', $logger);
} else {
$logger = Bbcode::parse('[div class="align-left"]'.clean($this->message).'[/div]');
$logger = $emojiOne->toImage($logger);
+1 -1
View File
@@ -52,7 +52,7 @@ class Message extends Model
}
/**
* A message belongs to a receiver
* A message belongs to a receiver.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
+30 -27
View File
@@ -13,18 +13,18 @@
namespace App\Repositories;
use App\User;
use App\UserEcho;
use App\UserAudible;
use App\Bot;
use App\User;
use App\Message;
use App\Chatroom;
use App\UserEcho;
use App\ChatStatus;
use App\Http\Resources\ChatMessageResource;
use App\Events\Chatter;
use App\Events\Ping;
use App\UserAudible;
use App\Events\Chatter;
use App\Events\MessageSent;
use App\Events\MessageDeleted;
use App\Http\Resources\ChatMessageResource;
class ChatRepository
{
@@ -124,12 +124,13 @@ class ChatRepository
public function ping($type, $id)
{
if($type == 'room') {
$rooms = Chatroom::where('id','>',0)->get();
foreach($rooms as $room) {
if ($type == 'room') {
$rooms = Chatroom::where('id', '>', 0)->get();
foreach ($rooms as $room) {
broadcast(new Ping($room->id, $id));
}
}
return true;
}
@@ -158,7 +159,6 @@ class ChatRepository
public function botMessage($bot_id, $room_id, $message, $receiver = null)
{
$user = $this->user->find($receiver);
if ($user->censor) {
$message = $this->censorMessage($message);
@@ -177,11 +177,11 @@ class ChatRepository
'user.group',
'user.chatStatus',
'receiver.group',
'receiver.chatStatus'
'receiver.chatStatus',
])->find($save->id);
event(New Chatter('new.bot',$receiver,new ChatMessageResource($message)));
event(New Chatter('new.ping',$receiver,['type' => 'bot', 'id' => $bot_id]));
event(new Chatter('new.bot', $receiver, new ChatMessageResource($message)));
event(new Chatter('new.ping', $receiver, ['type' => 'bot', 'id' => $bot_id]));
$message->delete();
}
@@ -204,14 +204,15 @@ class ChatRepository
'user.group',
'user.chatStatus',
'receiver.group',
'receiver.chatStatus'
'receiver.chatStatus',
])->find($save->id);
if($ignore != true) {
event(New Chatter('new.message', $user_id, new ChatMessageResource($message)));
if ($ignore != true) {
event(new Chatter('new.message', $user_id, new ChatMessageResource($message)));
}
event(New Chatter('new.message',$receiver,new ChatMessageResource($message)));
event(New Chatter('new.ping',$receiver,['type' => 'target', 'id' => $user_id]));
event(new Chatter('new.message', $receiver, new ChatMessageResource($message)));
event(new Chatter('new.ping', $receiver, ['type' => 'target', 'id' => $user_id]));
return $message;
}
@@ -232,11 +233,11 @@ class ChatRepository
'chatroom',
'user.chatStatus',
'receiver.group',
'receiver.chatStatus'
'receiver.chatStatus',
])->where(function ($query) use ($room_id) {
$query->where('chatroom_id', '=', $room_id);
})
->orderBy('id','desc')
->orderBy('id', 'desc')
->limit(config('chat.message_limit'))
->get();
}
@@ -249,11 +250,11 @@ class ChatRepository
'chatroom',
'user.chatStatus',
'receiver.group',
'receiver.chatStatus'
'receiver.chatStatus',
])->where(function ($query) use ($sender_id,$bot_id) {
$query->whereRaw('(user_id = ? and bot_id = ?)',[$sender_id,$bot_id])->orWhereRaw('(receiver_id = ? and bot_id = ?)',[$sender_id,$bot_id]);
$query->whereRaw('(user_id = ? and bot_id = ?)', [$sender_id, $bot_id])->orWhereRaw('(receiver_id = ? and bot_id = ?)', [$sender_id, $bot_id]);
})
->orderBy('id','desc')
->orderBy('id', 'desc')
->limit(config('chat.message_limit'))
->get();
}
@@ -266,11 +267,11 @@ class ChatRepository
'chatroom',
'user.chatStatus',
'receiver.group',
'receiver.chatStatus'
'receiver.chatStatus',
])->where(function ($query) use ($sender_id,$target_id) {
$query->whereRaw('(user_id = ? and receiver_id = ?)',[$sender_id,$target_id])->orWhereRaw('(user_id = ? and receiver_id = ?)',[$target_id,$sender_id]);
$query->whereRaw('(user_id = ? and receiver_id = ?)', [$sender_id, $target_id])->orWhereRaw('(user_id = ? and receiver_id = ?)', [$target_id, $sender_id]);
})
->orderBy('id','desc')
->orderBy('id', 'desc')
->limit(config('chat.message_limit'))
->get();
}
@@ -298,11 +299,12 @@ class ChatRepository
public function systemMessage($message, $bot = null)
{
if($bot) {
if ($bot) {
$this->message(1, $this->systemChatroom(), $message, null, $bot);
} else {
$this->message(1, $this->systemChatroom(), $message, null, 1);
}
return $this;
}
@@ -374,7 +376,8 @@ class ChatRepository
return $message;
}
protected function htmlifyMessage($message) {
protected function htmlifyMessage($message)
{
// Soon
return $message;
+1 -1
View File
@@ -88,7 +88,7 @@ class User extends Authenticatable
*/
public function chatStatus()
{
return $this->belongsTo(ChatStatus::class,'chat_status_id','id');
return $this->belongsTo(ChatStatus::class, 'chat_status_id', 'id');
}
/**
+3 -3
View File
@@ -10,9 +10,9 @@
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
* @author HDVinnie
*/
use App\UserEcho;
use Illuminate\Support\Facades\Broadcast;
use App\User;
use Illuminate\Support\Facades\Broadcast;
/*
* |--------------------------------------------------------------------------
* | Broadcast Channels
@@ -32,7 +32,7 @@ Broadcast::channel('chatroom.{id}', function ($user, $id) {
'torrents',
'echoes.target',
'echoes.room',
'group'
'group',
])->find($user->id);
});
Broadcast::channel('chatter.{id}', function ($user, $id) {